package com.panzhihua.service_community.service.impl; import java.util.ArrayList; import java.util.List; import javax.annotation.Resource; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.util.ObjectUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.panzhihua.common.model.vos.R; import com.panzhihua.common.model.vos.community.ComMngStructAreaCityVO; import com.panzhihua.common.model.vos.community.ComMngStructAreaDistrictVO; import com.panzhihua.common.model.vos.community.ComMngStructAreaProvinceVO; import com.panzhihua.service_community.dao.ComMngStructAreaDistrictDAO; import com.panzhihua.service_community.model.dos.ComMngStructAreaDistrictDO; import com.panzhihua.service_community.service.ComMngStructAreaDistrictService; /** * @program: springcloud_k8s_panzhihuazhihuishequ * @description: 地址 * @author: huang.hongfa weixin hhf9596 qq 959656820 * @create: 2021-01-27 15:02 **/ @Service public class ComMngStructAreaDistrictServiceImpl implements ComMngStructAreaDistrictService { @Resource private ComMngStructAreaDistrictDAO comMngStructAreaDistrictDAO; /** * 查询城市下属所有地区列表 * * @param cityAdcode * 城市地址编码 * @return 地区列表 */ @Override public R listAreaDistrict(Long cityAdcode) { List comMngStructAreaProvinceVOS = new ArrayList<>(); ComMngStructAreaProvinceVO comMngStructAreaProvinceVO = new ComMngStructAreaProvinceVO(); comMngStructAreaProvinceVO.setId(23L); comMngStructAreaProvinceVO.setProvinceAdcode(510000); comMngStructAreaProvinceVO.setProvinceName("四川省"); List comMngStructAreaCityVOS = new ArrayList<>(); ComMngStructAreaCityVO comMngStructAreaCityVO = new ComMngStructAreaCityVO(); comMngStructAreaCityVO.setCityAdcode(510400); comMngStructAreaCityVO.setCityName("攀枝花市"); comMngStructAreaCityVO.setId(256L); comMngStructAreaCityVO.setProvinceAdcode(510000); comMngStructAreaCityVO.setProvinceId(23L); List comMngStructAreaDistrictDOS = comMngStructAreaDistrictDAO.selectList(new QueryWrapper().lambda() .eq(ComMngStructAreaDistrictDO::getCityAdcode, cityAdcode)); List comMngStructAreaDistrictVOS = new ArrayList<>(); if (!ObjectUtils.isEmpty(comMngStructAreaDistrictDOS)) { comMngStructAreaDistrictDOS.forEach(comMngStructAreaDistrictDO -> { ComMngStructAreaDistrictVO comMngStructAreaDistrictVO = new ComMngStructAreaDistrictVO(); BeanUtils.copyProperties(comMngStructAreaDistrictDO, comMngStructAreaDistrictVO); comMngStructAreaDistrictVOS.add(comMngStructAreaDistrictVO); }); } comMngStructAreaCityVO.setComMngStructAreaDistrictVOS(comMngStructAreaDistrictVOS); comMngStructAreaCityVOS.add(comMngStructAreaCityVO); comMngStructAreaProvinceVO.setComMngStructAreaCityVOS(comMngStructAreaCityVOS); comMngStructAreaProvinceVOS.add(comMngStructAreaProvinceVO); return R.ok(comMngStructAreaDistrictVOS); } }