public Map<String,Object> getAreaAddress(){
List<AddressDto> result=new ArrayList<>();
//先获取省份
List<AreaDto> areaList=orderMapper.getAreaAddress();
for (AreaDto areaDto : areaList) {
AddressDto addressDto=new AddressDto();
//一级
addressDto.setCode(areaDto.getCode());
addressDto.setName(areaDto.getName());
//获取市
List<AreaDto> cityList=orderMapper.getProviceCity(areaDto.getCode());
//二级
List<AddressDto> twoCity=new ArrayList<>();
for (AreaDto area : cityList) {
AddressDto address=new AddressDto();
address.setCode(area.getCode());
address.setName(area.getName());
List<AreaDto> countyList=orderMapper.getCountyByCity(area.getCode());
//三级
List<AddressDto> threeCounty=new ArrayList<>();
for (AreaDto county : countyList) {
AddressDto theCounty=new AddressDto();
theCounty.setCode(county.getCode());
theCounty.setName(county.getName());
threeCounty.add(theCounty);
}
address.setChild(threeCounty);
twoCity.add(address);
}
addressDto.setChild(twoCity);
result.add(addressDto);
}
return returnResult(0, "成功", result);
}
获取省市区便捷地址
猜你喜欢
转载自blog.csdn.net/qq_35781178/article/details/81102485
今日推荐
周排行