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

省市区查询接口修改

parent 647bcbd7
......@@ -31,11 +31,11 @@ public class DisableController {
* 省市区
*
* @param districtLevel 区域级别:1省2地级市3县
* @param districtName 上级区域名
* @param districtCode 上级区域代码
*/
@RequestMapping("/district")
public Result<List<ChFndDistrict>> district(String districtLevel, String districtName) {
List<ChFndDistrict> districts = disableService.district(districtLevel, districtName);
public Result<List<ChFndDistrict>> district(String districtLevel, String districtCode) {
List<ChFndDistrict> districts = disableService.district(districtLevel, districtCode);
return Result.success(districts);
}
......
......@@ -52,9 +52,9 @@ public interface DisableService {
* 省市区
*
* @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();
......
......@@ -95,41 +95,33 @@ public class DisableServiceImpl implements DisableService {
}
@Override
public List<ChFndDistrict> district(String districtLevel, String districtName) {
public List<ChFndDistrict> district(String districtLevel, String districtCode) {
if ("4".equals(districtLevel)) {
//查询区代码
QueryWrapper<ChFndDistrict> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("IS_VALID", "Y");
queryWrapper.eq("DISTRICT_NAME", districtName);
ChFndDistrict chFndDistrict = districtMapper.selectOne(queryWrapper);
QueryWrapper<ChFndStreet> queryWrapper1 = new QueryWrapper<>();
queryWrapper1.eq("IS_VALID", 0);
queryWrapper1.eq("AREA_CODE", chFndDistrict.getDistrictCode());
List<ChFndStreet> fndStreets = fndStreetMapper.selectList(queryWrapper1);
//查询街道
QueryWrapper<ChFndStreet> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("IS_VALID", 0);
queryWrapper.eq("AREA_CODE", districtCode);
List<ChFndStreet> fndStreets = fndStreetMapper.selectList(queryWrapper);
List<ChFndDistrict> resuts = new ArrayList<>();
for (ChFndStreet chFndStreet : fndStreets) {
ChFndDistrict chFndDistrict1 = new ChFndDistrict();
chFndDistrict1.setDistrictCode(chFndStreet.getStreetCode());
chFndDistrict1.setDistrictName(chFndStreet.getStreetName());
chFndDistrict1.setParentDistirctCode(chFndStreet.getAreaCode());
resuts.add(chFndDistrict1);
ChFndDistrict chFndDistrict = new ChFndDistrict();
chFndDistrict.setDistrictCode(chFndStreet.getStreetCode());
chFndDistrict.setDistrictName(chFndStreet.getStreetName());
chFndDistrict.setParentDistirctCode(chFndStreet.getAreaCode());
resuts.add(chFndDistrict);
}
return resuts;
} else {
QueryWrapper<ChFndDistrict> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("IS_VALID", "Y");
queryWrapper.eq("DISTRICT_LEVEL", districtLevel);
if ("1".equals(districtLevel)) {
//查出所有的省
queryWrapper.eq("DISTRICT_LEVEL", districtLevel);
return districtMapper.selectList(queryWrapper);
} else {
queryWrapper.eq("DISTRICT_NAME", districtName);
ChFndDistrict chFndDistrict = districtMapper.selectOne(queryWrapper);
QueryWrapper<ChFndDistrict> queryWrapper2 = new QueryWrapper<>();
queryWrapper2.eq("IS_VALID", "Y");
queryWrapper2.eq("PARENT_DISTIRCT_CODE", chFndDistrict.getDistrictCode());
return districtMapper.selectList(queryWrapper2);
//查询市/县
queryWrapper.eq("PARENT_DISTIRCT_CODE", districtCode);
return districtMapper.selectList(queryWrapper);
}
}
}
......
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