| | |
| | | import com.se.nsl.service.RegionService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.models.auth.In; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | |
| | | @Api(tags = "1ï¼æ¨æ¼åºå") |
| | | @Slf4j |
| | |
| | | */ |
| | | @ApiOperation(value = "deleteByIds") |
| | | @DeleteMapping("/deleteByIds") |
| | | public R<Object> deleteByIds(java.util.List<Integer> ids) { |
| | | public R<Object> deleteByIds(@RequestParam List<Integer> ids) { |
| | | try { |
| | | return success(regionService.deleteByIds(ids)); |
| | | } catch (Exception ex) { |
| | |
| | | * @return ä¿®æ¹æåçè®°å½æ° |
| | | */ |
| | | @ApiOperation(value = "updateById") |
| | | @PutMapping("/updateById") |
| | | public R<Object> updateById(Region region) { |
| | | @PutMapping(value = "/updateById", produces = "application/json; charset=UTF-8") |
| | | public R<Object> updateById(@RequestBody Region region) { |
| | | try { |
| | | return success(regionService.updateById(region)); |
| | | } catch (Exception ex) { |
| | |
| | | package com.se.nsl.domain.po; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.netty.util.internal.StringUtil; |
| | |
| | | private Short type; |
| | | |
| | | @ApiModelProperty("空é´ä½ç½®") |
| | | @TableField(value = "st_astext(geom)", select = true) |
| | | private String geom; |
| | | |
| | | public Region() { |
| | |
| | | this.geom = geom; |
| | | } |
| | | |
| | | public void setGeomWkt(String wkt) { |
| | | this.geom = StringUtil.isNullOrEmpty(wkt) ? "null" : String.format("ST_GeomFromText('%s')", wkt.trim()); |
| | | public void setGeomText() { |
| | | this.geom = StringUtil.isNullOrEmpty(this.geom) ? "null" : String.format("ST_GeomFromText('%s')", this.geom.trim()); |
| | | } |
| | | } |
| | |
| | | @ApiModelProperty("夿³¨") |
| | | private String bak; |
| | | |
| | | @TableField(select = false) |
| | | @ApiModelProperty("空é´ä½ç½®") |
| | | @TableField(value = "st_astext(geom)", select = true) |
| | | private String geom; |
| | | |
| | | public Simu() { |
| | |
| | | this.geom = geom; |
| | | } |
| | | |
| | | public void setGeomWkt(String wkt) { |
| | | this.geom = StringUtil.isNullOrEmpty(wkt) ? "null" : String.format("ST_GeomFromText('%s')", wkt.trim()); |
| | | public void setGeomText() { |
| | | this.geom = StringUtil.isNullOrEmpty(this.geom) ? "null" : String.format("ST_GeomFromText('%s')", this.geom.trim()); |
| | | } |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.se.nsl.domain.po.Region; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | @SuppressWarnings("ALL") |
| | | public interface RegionMapper extends BaseMapper<Region> { |
| | | int inserts(@Param("list") List<Region> list); |
| | | |
| | | int updates(@Param("list") List<Region> list); |
| | | } |
| | |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import com.se.nsl.domain.po.Simu; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.apache.ibatis.annotations.Param; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | @SuppressWarnings("ALL") |
| | | public interface SimuMapper extends BaseMapper<Simu> { |
| | | int inserts(@Param("list") List<Simu> list); |
| | | |
| | | int updates(@Param("list") List<Simu> list); |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | |
| | | * @return æ°å¢æåçè®°å½æ° |
| | | */ |
| | | public int insert(Region region) { |
| | | return regionMapper.insert(region); |
| | | region.setGeomText(); |
| | | return regionMapper.inserts(Arrays.asList(region)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @return ä¿®æ¹æåçè®°å½æ° |
| | | */ |
| | | public int updateById(Region region) { |
| | | return regionMapper.updateById(region); |
| | | region.setGeomText(); |
| | | return regionMapper.updates(Arrays.asList(region)); |
| | | } |
| | | } |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | |
| | | * @param Simu æ¨æ¼æ¨¡æå¯¹è±¡ |
| | | * @return æ°å¢æåçè®°å½æ° |
| | | */ |
| | | public int insert(Simu Simu) { |
| | | return simuMapper.insert(Simu); |
| | | public int insert(Simu simu) { |
| | | simu.setGeomText(); |
| | | return simuMapper.inserts(Collections.singletonList(simu)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @param Simu æ¨æ¼æ¨¡æå¯¹è±¡ |
| | | * @return ä¿®æ¹æåçè®°å½æ° |
| | | */ |
| | | public int updateById(Simu Simu) { |
| | | return simuMapper.updateById(Simu); |
| | | public int updateById(Simu simu) { |
| | | simu.setGeomText(); |
| | | return simuMapper.updates(Arrays.asList(simu)); |
| | | } |
| | | } |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.se.nsl.mapper.RegionMapper"> |
| | | <insert id="inserts" parameterType="com.se.nsl.domain.po.Region"> |
| | | insert into nsl.region(name, type, geom) values |
| | | <foreach collection="list" item="item" index="index" separator=","> |
| | | (#{item.name}, #{item.type}, ${item.geom}) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <update id="updates" parameterType="com.se.nsl.domain.po.Region"> |
| | | <foreach collection="list" item="item" separator=";"> |
| | | update nsl.region |
| | | set name = #{item.name}, |
| | | type = #{item.type}, |
| | | geom = ${item.geom} |
| | | where id = #{item.id} |
| | | </foreach> |
| | | </update> |
| | | </mapper> |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.se.nsl.mapper.SimuPoMapper"> |
| | | <select id="selectMaxId" resultType="java.lang.Integer"> |
| | | select coalesce(max(id), 0) from bs.simu; |
| | | </select> |
| | | <mapper namespace="com.se.nsl.mapper.SimuMapper"> |
| | | <insert id="inserts" parameterType="com.se.nsl.domain.po.Simu"> |
| | | insert into nsl.simu ( |
| | | name, service_name, type, area_type, data, status, result, create_time, create_user, bak, geom) |
| | | values |
| | | <foreach collection="list" item="item" separator=","> |
| | | ( |
| | | #{item.name}, |
| | | #{item.serviceName}, |
| | | #{item.type}, |
| | | #{item.areaType}, |
| | | #{item.data}, |
| | | #{item.status}, |
| | | #{item.result}, |
| | | now(), |
| | | #{item.createUser}, |
| | | #{item.bak}, |
| | | ${item.geom} |
| | | ) |
| | | </foreach> |
| | | </insert> |
| | | |
| | | <update id="updates" parameterType="com.se.nsl.domain.po.Simu"> |
| | | <foreach collection="list" item="item" separator=";"> |
| | | update nsl.simu |
| | | set name=#{item.name}, |
| | | service_name=#{item.serviceName}, |
| | | type=#{item.type}, |
| | | area_type=#{item.areaType}, |
| | | data=#{item.data}, |
| | | status=#{item.status}, |
| | | result=#{item.result}, |
| | | update_time=now(), |
| | | update_user=#{item.updateUser}, |
| | | bak=#{item.bak}, |
| | | geom=${item.geom} |
| | | where id = #{item.id} |
| | | </foreach> |
| | | </update> |
| | | </mapper> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <?xml version="1.0" encoding="UTF-8" ?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.se.nsl.mapper.SimuPoMapper"> |
| | | <select id="selectMaxId" resultType="java.lang.Integer"> |
| | | select coalesce(max(id), 0) from bs.simu; |
| | | </select> |
| | | </mapper> |