18 changed files with 396 additions and 19 deletions
@ -0,0 +1,28 @@ |
|||||
|
package com.yxt.supervise.system.region; |
||||
|
|
||||
|
import com.yxt.common.core.domain.BaseEntity; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/30 14:14 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Data |
||||
|
public class Region extends BaseEntity { |
||||
|
|
||||
|
private static final long serialVersionUID = -8228110479168648565L; |
||||
|
@ApiModelProperty(value = "上级sid") |
||||
|
private String pSid; |
||||
|
@ApiModelProperty(value = "级别") |
||||
|
private Integer level; |
||||
|
@ApiModelProperty(value = "名称,区域名称") |
||||
|
private String name; |
||||
|
@ApiModelProperty(value = "行政区划代码") |
||||
|
private String districtCode; |
||||
|
@ApiModelProperty(value = "sid全路径") |
||||
|
private String sidPath; |
||||
|
@ApiModelProperty(value = "排序号") |
||||
|
private Integer sortNo; |
||||
|
} |
@ -0,0 +1,36 @@ |
|||||
|
package com.yxt.supervise.system.region; |
||||
|
|
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import io.swagger.annotations.ApiOperation; |
||||
|
import org.springframework.cloud.openfeign.FeignClient; |
||||
|
import org.springframework.web.bind.annotation.GetMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestParam; |
||||
|
import org.springframework.web.bind.annotation.ResponseBody; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/30 14:19 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@FeignClient( |
||||
|
contextId = "supervise-system-Region", |
||||
|
name = "supervise-system", |
||||
|
path = "v1/regions", |
||||
|
fallback = RegionFeignFallback.class) |
||||
|
public interface RegionFeign { |
||||
|
|
||||
|
@ApiOperation("获取省") |
||||
|
@ResponseBody |
||||
|
@GetMapping("/getProvince") |
||||
|
public ResultBean getProvince(); |
||||
|
|
||||
|
@ApiOperation("根据省sid获取该省的所有市") |
||||
|
@ResponseBody |
||||
|
@GetMapping("/getCity") |
||||
|
public ResultBean getCity(@RequestParam("sid") String sid); |
||||
|
|
||||
|
@ApiOperation("根据市sid获取该市的所有县区") |
||||
|
@ResponseBody |
||||
|
@GetMapping("/getCounty") |
||||
|
public ResultBean getCounty(@RequestParam("sid") String sid); |
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
package com.yxt.supervise.system.region; |
||||
|
|
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/30 14:21 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Component |
||||
|
public class RegionFeignFallback { |
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
package com.yxt.supervise.system.region; |
||||
|
|
||||
|
import com.yxt.common.core.vo.Vo; |
||||
|
import io.swagger.annotations.ApiModelProperty; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/30 14:27 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Data |
||||
|
public class RegionListVo implements Vo { |
||||
|
private static final long serialVersionUID = 8014259465244029276L; |
||||
|
|
||||
|
@ApiModelProperty(value = "sid") |
||||
|
private String sid; |
||||
|
@ApiModelProperty(value = "上级sid") |
||||
|
private String pSid; |
||||
|
@ApiModelProperty(value = "级别") |
||||
|
private Integer level; |
||||
|
@ApiModelProperty(value = "名称,区域名称") |
||||
|
private String name; |
||||
|
@ApiModelProperty(value = "行政区划代码") |
||||
|
private String districtCode; |
||||
|
@ApiModelProperty(value = "sid全路径") |
||||
|
private String sidPath; |
||||
|
@ApiModelProperty(value = "排序号") |
||||
|
private Integer sortNo; |
||||
|
} |
@ -0,0 +1,37 @@ |
|||||
|
package com.yxt.supervise.system.region; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/30 14:24 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface RegionMapper extends BaseMapper<Region> { |
||||
|
/** |
||||
|
* 获取省 |
||||
|
* |
||||
|
* @return |
||||
|
*/ |
||||
|
List<RegionListVo> getProvinceList(); |
||||
|
|
||||
|
/** |
||||
|
* 获取省下的市 |
||||
|
* |
||||
|
* @param sid 省sid |
||||
|
* @return |
||||
|
*/ |
||||
|
List<RegionListVo> getCity(String sid); |
||||
|
|
||||
|
/** |
||||
|
* 获取市下的县区 |
||||
|
* |
||||
|
* @param sid 市sid |
||||
|
* @return |
||||
|
*/ |
||||
|
List<RegionListVo> getCounty(String sid); |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
<?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.yxt.supervise.system.region.RegionMapper"> |
||||
|
<select id="getProvinceList" resultType="com.yxt.supervise.system.region.RegionListVo"> |
||||
|
SELECT name, sid, pSid, districtCode, sidPath |
||||
|
FROM region |
||||
|
WHERE level = 1 |
||||
|
AND pSid = 0 |
||||
|
</select> |
||||
|
|
||||
|
<select id="getCity" resultType="com.yxt.supervise.system.region.RegionListVo"> |
||||
|
SELECT name, sid, pSid, districtCode, sidPath |
||||
|
FROM region |
||||
|
WHERE level = 2 |
||||
|
AND pSid = #{sid} |
||||
|
ORDER BY sortNo + 0 |
||||
|
</select> |
||||
|
|
||||
|
<select id="getCounty" resultType="com.yxt.supervise.system.region.RegionListVo"> |
||||
|
SELECT name, sid, pSid, districtCode, sidPath |
||||
|
FROM region |
||||
|
WHERE level = 3 |
||||
|
AND pSid = #{sid} |
||||
|
</select> |
||||
|
</mapper> |
@ -0,0 +1,36 @@ |
|||||
|
package com.yxt.supervise.system.region; |
||||
|
|
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import io.swagger.annotations.Api; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/30 14:23 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Controller |
||||
|
@RequestMapping("v1/regions") |
||||
|
@Api(tags = "区域管理") |
||||
|
public class RegionRest implements RegionFeign{ |
||||
|
|
||||
|
@Autowired |
||||
|
private RegionService regionService; |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean getProvince() { |
||||
|
return regionService.getProvince(); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean getCity(String sid) { |
||||
|
return regionService.getCity(sid); |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public ResultBean getCounty(String sid) { |
||||
|
return regionService.getCounty(sid); |
||||
|
} |
||||
|
} |
@ -0,0 +1,51 @@ |
|||||
|
package com.yxt.supervise.system.region; |
||||
|
|
||||
|
import com.yxt.common.base.service.MybatisBaseService; |
||||
|
import com.yxt.common.core.result.ResultBean; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* @Author dimengzhe |
||||
|
* @Date 2023/1/30 14:24 |
||||
|
* @Description |
||||
|
*/ |
||||
|
@Service |
||||
|
public class RegionService extends MybatisBaseService<RegionMapper, Region> { |
||||
|
|
||||
|
/** |
||||
|
* 获取省 |
||||
|
* |
||||
|
* @return |
||||
|
*/ |
||||
|
public ResultBean getProvince() { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
List<RegionListVo> regionList = baseMapper.getProvinceList(); |
||||
|
return rb.success().setData(regionList); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取省下的市 |
||||
|
* |
||||
|
* @param sid 省sid |
||||
|
* @return |
||||
|
*/ |
||||
|
public ResultBean getCity(String sid) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
List<RegionListVo> regionList = baseMapper.getCity(sid); |
||||
|
return rb.success().setData(regionList); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取市下的县区 |
||||
|
* |
||||
|
* @param sid 市sid |
||||
|
* @return |
||||
|
*/ |
||||
|
public ResultBean getCounty(String sid) { |
||||
|
ResultBean rb = ResultBean.fireFail(); |
||||
|
List<RegionListVo> regionList = baseMapper.getCounty(sid); |
||||
|
return rb.success().setData(regionList); |
||||
|
} |
||||
|
} |
Loading…
Reference in new issue