Commit 6907b6ca authored by 蔡镇泽's avatar 蔡镇泽

省市区查询接口修改

parent 647bcbd7
...@@ -31,11 +31,11 @@ public class DisableController { ...@@ -31,11 +31,11 @@ public class DisableController {
* 省市区 * 省市区
* *
* @param districtLevel 区域级别:1省2地级市3县 * @param districtLevel 区域级别:1省2地级市3县
* @param districtName 上级区域名 * @param districtCode 上级区域代码
*/ */
@RequestMapping("/district") @RequestMapping("/district")
public Result<List<ChFndDistrict>> district(String districtLevel, String districtName) { public Result<List<ChFndDistrict>> district(String districtLevel, String districtCode) {
List<ChFndDistrict> districts = disableService.district(districtLevel, districtName); List<ChFndDistrict> districts = disableService.district(districtLevel, districtCode);
return Result.success(districts); return Result.success(districts);
} }
......
...@@ -52,9 +52,9 @@ public interface DisableService { ...@@ -52,9 +52,9 @@ public interface DisableService {
* 省市区 * 省市区
* *
* @param districtLevel 区域级别:1省2地级市3县 * @param districtLevel 区域级别:1省2地级市3县
* @param districtName 上级区域名 * @param districtCode 上级区域代码
*/ */
List<ChFndDistrict> district(String districtLevel, String districtName); List<ChFndDistrict> district(String districtLevel, String districtCode);
List<ChFndOrgan> fndOrganRoot(); List<ChFndOrgan> fndOrganRoot();
......
...@@ -95,41 +95,33 @@ public class DisableServiceImpl implements DisableService { ...@@ -95,41 +95,33 @@ public class DisableServiceImpl implements DisableService {
} }
@Override @Override
public List<ChFndDistrict> district(String districtLevel, String districtName) { public List<ChFndDistrict> district(String districtLevel, String districtCode) {
if ("4".equals(districtLevel)) { if ("4".equals(districtLevel)) {
//查询区代码 //查询街道
QueryWrapper<ChFndDistrict> queryWrapper = new QueryWrapper<>(); QueryWrapper<ChFndStreet> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("IS_VALID", "Y"); queryWrapper.eq("IS_VALID", 0);
queryWrapper.eq("DISTRICT_NAME", districtName); queryWrapper.eq("AREA_CODE", districtCode);
ChFndDistrict chFndDistrict = districtMapper.selectOne(queryWrapper); List<ChFndStreet> fndStreets = fndStreetMapper.selectList(queryWrapper);
QueryWrapper<ChFndStreet> queryWrapper1 = new QueryWrapper<>();
queryWrapper1.eq("IS_VALID", 0);
queryWrapper1.eq("AREA_CODE", chFndDistrict.getDistrictCode());
List<ChFndStreet> fndStreets = fndStreetMapper.selectList(queryWrapper1);
List<ChFndDistrict> resuts = new ArrayList<>(); List<ChFndDistrict> resuts = new ArrayList<>();
for (ChFndStreet chFndStreet : fndStreets) { for (ChFndStreet chFndStreet : fndStreets) {
ChFndDistrict chFndDistrict1 = new ChFndDistrict(); ChFndDistrict chFndDistrict = new ChFndDistrict();
chFndDistrict1.setDistrictCode(chFndStreet.getStreetCode()); chFndDistrict.setDistrictCode(chFndStreet.getStreetCode());
chFndDistrict1.setDistrictName(chFndStreet.getStreetName()); chFndDistrict.setDistrictName(chFndStreet.getStreetName());
chFndDistrict1.setParentDistirctCode(chFndStreet.getAreaCode()); chFndDistrict.setParentDistirctCode(chFndStreet.getAreaCode());
resuts.add(chFndDistrict1); resuts.add(chFndDistrict);
} }
return resuts; return resuts;
} else { } else {
QueryWrapper<ChFndDistrict> queryWrapper = new QueryWrapper<>(); QueryWrapper<ChFndDistrict> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("IS_VALID", "Y"); queryWrapper.eq("IS_VALID", "Y");
queryWrapper.eq("DISTRICT_LEVEL", districtLevel);
if ("1".equals(districtLevel)) { if ("1".equals(districtLevel)) {
//查出所有的省 //查出所有的省
queryWrapper.eq("DISTRICT_LEVEL", districtLevel);
return districtMapper.selectList(queryWrapper); return districtMapper.selectList(queryWrapper);
} else { } else {
queryWrapper.eq("DISTRICT_NAME", districtName); //查询市/县
ChFndDistrict chFndDistrict = districtMapper.selectOne(queryWrapper); queryWrapper.eq("PARENT_DISTIRCT_CODE", districtCode);
QueryWrapper<ChFndDistrict> queryWrapper2 = new QueryWrapper<>(); return districtMapper.selectList(queryWrapper);
queryWrapper2.eq("IS_VALID", "Y");
queryWrapper2.eq("PARENT_DISTIRCT_CODE", chFndDistrict.getDistrictCode());
return districtMapper.selectList(queryWrapper2);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment