15 changed files with 495 additions and 22 deletions
@ -0,0 +1,79 @@
|
||||
package com.air.facilities.controller; |
||||
|
||||
import com.air.facilities.dto.FacilitiesDTO; |
||||
import com.air.facilities.entity.Facilities; |
||||
import com.air.facilities.service.FacilitiesService; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.cinderella.framework.common.core.util.R; |
||||
import com.cinderella.framework.common.data.mybatis.QueryPage; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import lombok.extern.slf4j.Slf4j; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @program: back-end |
||||
* @description: |
||||
* @author: cyz |
||||
* @create: 2022-07-07 15:49 |
||||
**/ |
||||
@RestController |
||||
@RequestMapping("/facilities") |
||||
@Api(tags = "城市周边") |
||||
@Slf4j |
||||
public class FacilitiesController { |
||||
|
||||
@Autowired |
||||
private FacilitiesService facilitiesService; |
||||
|
||||
|
||||
@ApiOperation(value = "添加") |
||||
@PostMapping("/add") |
||||
public R<Facilities> addFacilities(@RequestBody FacilitiesDTO facilitiesDTO){ |
||||
log.info("-----------------------------------"+facilitiesDTO); |
||||
facilitiesService.addFacilities(facilitiesDTO); |
||||
return R.ok(); |
||||
} |
||||
|
||||
@ApiOperation(value = "修改") |
||||
@PutMapping("/update") |
||||
public R<Facilities> updateFacilities(@RequestBody FacilitiesDTO facilitiesDTO){ |
||||
log.info("===================="+facilitiesDTO); |
||||
facilitiesService.updateFacilities(facilitiesDTO); |
||||
return R.ok(); |
||||
} |
||||
@ApiOperation(value = "查询全部") |
||||
@GetMapping("/list") |
||||
public R<Page<Facilities>> selectFacilitiesList(QueryPage queryPage, Facilities facilities){ |
||||
log.info(""+facilities); Page<Facilities> page = queryPage.toPage(); |
||||
|
||||
List<Facilities> facilities1 = facilitiesService.selectAllFacilitiesPage(page, facilities); |
||||
return R.ok(page.setRecords(facilities1), "查询成功"); |
||||
} |
||||
|
||||
@ApiOperation(value = "根据ID查询") |
||||
@GetMapping("/list/{id}") |
||||
public R<Facilities> selectFacilitiesId(@PathVariable("id") String id){ |
||||
|
||||
return R.ok(); |
||||
} |
||||
@ApiOperation(value = "删除") |
||||
@DeleteMapping("/delete/{ids}") |
||||
public R<Facilities> deleteFacilities(@PathVariable String[] ids){ |
||||
facilitiesService.deleteFacilities(ids); |
||||
return R.ok(); |
||||
} |
||||
|
||||
|
||||
@ApiOperation(value = "查询周边类型集合") |
||||
@GetMapping("/selectTypeList") |
||||
public R<List<Facilities>> selectTypeList(){ |
||||
List<Facilities> facilities = facilitiesService.selectTypeList(); |
||||
return R.ok(facilities); |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,43 @@
|
||||
package com.air.facilities.dto; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import io.swagger.models.auth.In; |
||||
import lombok.Data; |
||||
|
||||
import javax.validation.constraints.NotNull; |
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* @program: back-end |
||||
* @description: |
||||
* @author: cyz |
||||
* @create: 2022-07-08 13:41 |
||||
**/ |
||||
@Data |
||||
public class FacilitiesDTO { |
||||
|
||||
private Integer gid; |
||||
@ApiModelProperty(value="名字") |
||||
@NotNull(message = "地区名字不能为空") |
||||
private String name; |
||||
@ApiModelProperty(value="类型名称") |
||||
private String typecn; |
||||
@ApiModelProperty(value="备注") |
||||
private String remark; |
||||
@ApiModelProperty(value="经度")//经度值必须在(-180,180]范围内。正值位于本初子午线以东。
|
||||
@NotNull(message = "经度不能为空") |
||||
private BigDecimal lon; |
||||
@ApiModelProperty(value="纬度")//纬度值必须在[-90,90]范围内。正值位于赤道以北。
|
||||
@NotNull(message = "纬度不能为空") |
||||
private BigDecimal lat; |
||||
@ApiModelProperty(value="类型标识") |
||||
private String type; |
||||
@ApiModelProperty(value="坐标点") |
||||
private String geom; |
||||
@ApiModelProperty(value="计算坐标对象") |
||||
private String miniGeom; |
||||
|
||||
@ApiModelProperty(value = "旧类型") |
||||
private String oldType; |
||||
} |
@ -0,0 +1,49 @@
|
||||
package com.air.facilities.entity; |
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId; |
||||
import com.baomidou.mybatisplus.annotation.TableName; |
||||
import com.baomidou.mybatisplus.extension.activerecord.Model; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiModel; |
||||
import io.swagger.annotations.ApiModelProperty; |
||||
import lombok.Data; |
||||
import lombok.EqualsAndHashCode; |
||||
|
||||
import java.math.BigDecimal; |
||||
|
||||
/** |
||||
* @program: back-end |
||||
* @description: 城市周边 |
||||
* @author: cyz |
||||
* @create: 2022-07-07 15:18 |
||||
**/ |
||||
@Data |
||||
@TableName("facilities") |
||||
@EqualsAndHashCode(callSuper = true) |
||||
@ApiModel(value = "周边设施") |
||||
public class Facilities extends Model<Facilities> { |
||||
|
||||
private static final long serialVersionUID = 1L; |
||||
|
||||
@TableId |
||||
@ApiModelProperty(value="gid") |
||||
private Integer gid; |
||||
@ApiModelProperty(value="id") |
||||
private Double id; |
||||
@ApiModelProperty(value="名字") |
||||
private String name; |
||||
@ApiModelProperty(value="类型名称") |
||||
private String typecn; |
||||
@ApiModelProperty(value="备注") |
||||
private String remark; |
||||
@ApiModelProperty(value="经度")//经度值必须在(-180,180]范围内。正值位于本初子午线以东。
|
||||
private BigDecimal lon; |
||||
@ApiModelProperty(value="纬度")//纬度值必须在[-90,90]范围内。正值位于赤道以北。
|
||||
private BigDecimal lat; |
||||
@ApiModelProperty(value="类型标识") |
||||
private String type; |
||||
@ApiModelProperty(value="坐标点") |
||||
private String geom; |
||||
@ApiModelProperty(value="计算坐标对象") |
||||
private String miniGeom; |
||||
} |
@ -0,0 +1,47 @@
|
||||
package com.air.facilities.mapper; |
||||
|
||||
import com.air.facilities.entity.Facilities; |
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
||||
import org.apache.ibatis.annotations.Param; |
||||
import org.springframework.stereotype.Repository; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @program: back-end |
||||
* @description: |
||||
* @author: cyz |
||||
* @create: 2022-07-07 15:41 |
||||
**/ |
||||
@Repository //告诉容器你是持久层的 @Repository是spring提供的注释,能够将该类注册成Bean
|
||||
public interface FacilitiesMapper extends BaseMapper<Facilities> { |
||||
|
||||
/** |
||||
* 查询全部周边信息 |
||||
* @param facilities |
||||
* @return |
||||
*/ |
||||
List<Facilities> getAllFacilities(Page page ,@Param("facilities")Facilities facilities); |
||||
|
||||
|
||||
/** |
||||
* 查询周边类型集合 |
||||
* @return |
||||
*/ |
||||
List<Facilities> selectTypeList(); |
||||
|
||||
/** |
||||
* 删除数据 |
||||
* @param ids |
||||
* @return |
||||
*/ |
||||
int delFacilities(String[] ids); |
||||
|
||||
|
||||
int insertFacilities(Facilities facilities); |
||||
|
||||
|
||||
int updateFacilities(Facilities facilities); |
||||
} |
@ -0,0 +1,56 @@
|
||||
package com.air.facilities.service; |
||||
|
||||
import com.air.facilities.dto.FacilitiesDTO; |
||||
import com.air.facilities.entity.Facilities; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
||||
import java.util.List; |
||||
|
||||
public interface FacilitiesService extends IService<Facilities> { |
||||
|
||||
/** |
||||
* 查询全部周边信息 |
||||
* @param facilities |
||||
* @return |
||||
*/ |
||||
List<Facilities> selectAllFacilitiesPage(Page page, Facilities facilities); |
||||
|
||||
/** |
||||
* 根据ID查询具体信息 |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
Facilities getFacilitiesId(String id); |
||||
|
||||
/** |
||||
* 修改周边信息 |
||||
* @param facilities |
||||
* @return |
||||
*/ |
||||
int putFacilities(Facilities facilities); |
||||
|
||||
/** |
||||
* 删除周边信息 |
||||
* |
||||
* @param ids@return |
||||
*/ |
||||
int deleteFacilities(String[] ids); |
||||
|
||||
/** |
||||
* 添加周边信息 |
||||
* @param facilities |
||||
* @return |
||||
*/ |
||||
int addFacilities(FacilitiesDTO facilities); |
||||
|
||||
/** |
||||
* 查询周边类型集合 |
||||
* @return |
||||
*/ |
||||
List<Facilities> selectTypeList(); |
||||
|
||||
|
||||
int updateFacilities(FacilitiesDTO facilitiesDTO); |
||||
|
||||
} |
@ -0,0 +1,130 @@
|
||||
package com.air.facilities.service.impl; |
||||
|
||||
import cn.hutool.core.util.StrUtil; |
||||
import com.air.facilities.dto.FacilitiesDTO; |
||||
import com.air.facilities.entity.Facilities; |
||||
import com.air.facilities.mapper.FacilitiesMapper; |
||||
import com.air.facilities.service.FacilitiesService; |
||||
import com.air.land.entity.LandListed; |
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.beans.BeanUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @program: back-end |
||||
* @description: |
||||
* @author: cyz |
||||
* @create: 2022-07-07 15:44 |
||||
**/ |
||||
@Service |
||||
public class FacilitiesServiceImpl extends ServiceImpl<FacilitiesMapper, Facilities> implements FacilitiesService { |
||||
|
||||
@Autowired |
||||
private FacilitiesMapper facilitiesMapper; |
||||
|
||||
/** |
||||
* 查询全部数据 |
||||
* @param facilities |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<Facilities> selectAllFacilitiesPage(Page page, Facilities facilities) { |
||||
List<Facilities> allFacilities = facilitiesMapper.getAllFacilities(page, facilities); |
||||
return allFacilities; |
||||
} |
||||
|
||||
/** |
||||
* 根据ID查询具体信息 |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public Facilities getFacilitiesId(String id) { |
||||
Facilities facilities = facilitiesMapper.selectById(id); |
||||
return facilities; |
||||
} |
||||
|
||||
/** |
||||
* 修改周边信息 |
||||
* @param facilities |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public int putFacilities(Facilities facilities) { |
||||
|
||||
return facilitiesMapper.update(facilities,null); |
||||
} |
||||
|
||||
/** |
||||
* 删除周边信息 |
||||
* |
||||
* @param ids@return |
||||
*/ |
||||
@Override |
||||
public int deleteFacilities(String[] ids) { |
||||
return facilitiesMapper.delFacilities(ids); |
||||
} |
||||
|
||||
/** |
||||
* 添加 |
||||
* @param facilitiesDTO |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public int addFacilities(FacilitiesDTO facilitiesDTO) { |
||||
Facilities facilities = new Facilities(); |
||||
BeanUtils.copyProperties(facilitiesDTO,facilities); |
||||
String srt = "POINT("+facilitiesDTO.getLon()+" "+facilitiesDTO.getLat()+")"; |
||||
facilities.setGeom(srt); |
||||
if(StrUtil.isNotBlank(facilitiesDTO.getOldType())){ |
||||
List<Facilities> facilities1 = facilitiesMapper.selectList(Wrappers.<Facilities>query().lambda(). |
||||
eq(StringUtils.isNotEmpty(facilitiesDTO.getOldType()), Facilities::getType, facilitiesDTO.getOldType())); |
||||
if(facilities1.size() > 0){ |
||||
facilities.setType(facilities1.get(0).getType()); |
||||
facilities.setTypecn(facilities1.get(0).getTypecn()); |
||||
} |
||||
|
||||
} |
||||
return facilitiesMapper.insertFacilities(facilities); |
||||
} |
||||
|
||||
/** |
||||
* 查询周边类型集合 |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public List<Facilities> selectTypeList() { |
||||
|
||||
return facilitiesMapper.selectTypeList(); |
||||
} |
||||
|
||||
/** |
||||
* 修改 |
||||
* @param facilitiesDTO |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public int updateFacilities(FacilitiesDTO facilitiesDTO) { |
||||
Facilities facilities = new Facilities(); |
||||
BeanUtils.copyProperties(facilitiesDTO,facilities); |
||||
String srt = "POINT("+facilitiesDTO.getLon()+" "+facilitiesDTO.getLat()+")"; |
||||
facilities.setGeom(srt); |
||||
facilities.setGid(facilitiesDTO.getGid()); |
||||
if(StrUtil.isNotBlank(facilitiesDTO.getOldType())){ |
||||
List<Facilities> facilities1 = facilitiesMapper.selectList(Wrappers.<Facilities>query().lambda(). |
||||
eq(StringUtils.isNotEmpty(facilitiesDTO.getOldType()), Facilities::getType, facilitiesDTO.getOldType())); |
||||
if(facilities1.size() > 0){ |
||||
facilities.setType(facilities1.get(0).getType()); |
||||
facilities.setTypecn(facilities1.get(0).getTypecn()); |
||||
} |
||||
|
||||
} |
||||
return facilitiesMapper.updateFacilities(facilities); |
||||
} |
||||
} |
@ -0,0 +1,65 @@
|
||||
<?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.air.facilities.mapper.FacilitiesMapper"> |
||||
<select id="getAllFacilities" resultType="com.air.facilities.entity.Facilities"> |
||||
select gid,id,name,typecn,remark,lon,lat,type,geom,mini_geom from facilities |
||||
<where> |
||||
<if test="facilities.name != null and facilities.name != ''"> and name like concat('%', #{facilities.name},'%') </if> |
||||
<if test="facilities.typecn != null and facilities.typecn != ''"> and typecn =#{facilities.typecn} </if> |
||||
|
||||
</where> |
||||
</select> |
||||
<select id="selectTypeList" resultType="com.air.facilities.entity.Facilities"> |
||||
select DISTINCT typecn,type from facilities |
||||
</select> |
||||
|
||||
<delete id="delFacilities" parameterType="String"> |
||||
delete from facilities where gid in |
||||
<foreach item="id" collection="array" open="(" separator="," close=")"> |
||||
#{id} |
||||
</foreach> |
||||
</delete> |
||||
|
||||
<insert id="insertFacilities"> |
||||
insert into facilities |
||||
<trim prefix="(" suffix=")" suffixOverrides=","> |
||||
<if test="name != null">name,</if> |
||||
<if test="typecn != null">typecn,</if> |
||||
<if test="remark != null">remark,</if> |
||||
created_time, |
||||
<if test="lon != null">lon,</if> |
||||
<if test="lat != null">lat,</if> |
||||
<if test="type != null">type,</if> |
||||
<if test="geom != null">geom,</if> |
||||
<if test="miniGeom != null">mini_geom,</if> |
||||
</trim> |
||||
<trim prefix="values (" suffix=")" suffixOverrides=","> |
||||
<if test="name != null">#{name},</if> |
||||
<if test="typecn != null">#{typecn},</if> |
||||
<if test="remark != null">#{remark},</if> |
||||
now(), |
||||
<if test="lon != null">#{lon},</if> |
||||
<if test="lat != null">#{lat},</if> |
||||
<if test="type != null">#{type},</if> |
||||
<if test="geom != null">ST_GeomFromText(#{geom}),</if> |
||||
<if test="miniGeom != null">#{miniGeom},</if> |
||||
</trim> |
||||
</insert> |
||||
<update id="updateFacilities" > |
||||
update facilities |
||||
<trim prefix="SET" suffixOverrides=","> |
||||
<if test="name != null">name = #{name},</if> |
||||
<if test="typecn != null"> typecn =#{typecn},</if> |
||||
<if test="remark != null">remark =#{remark},</if> |
||||
<if test="lon != null">lon = #{lon},</if> |
||||
<if test="lat != null">lat = #{lat},</if> |
||||
<if test="type != null">type = #{type},</if> |
||||
<if test="geom != null">geom = ST_GeomFromText(#{geom}),</if> |
||||
<if test="miniGeom != null">miniGeom = #{miniGeom},</if> |
||||
</trim> |
||||
where gid = #{gid} |
||||
</update> |
||||
|
||||
</mapper> |
Loading…
Reference in new issue