| | |
| | | import com.moral.entity.Area; |
| | | import com.moral.entity.City; |
| | | import com.moral.entity.Province; |
| | | import com.moral.entity.Town; |
| | | import com.moral.entity.Village; |
| | | import com.moral.mapper.AreaMapper; |
| | | import com.moral.mapper.CityMapper; |
| | | import com.moral.mapper.ProvinceMapper; |
| | | import com.moral.mapper.TownMapper; |
| | | import com.moral.mapper.VillageMapper; |
| | | import com.moral.service.AreaService; |
| | | import org.springframework.stereotype.Service; |
| | | import tk.mybatis.mapper.entity.Example; |
| | |
| | | CityMapper cityMapper; |
| | | @Resource |
| | | AreaMapper areaMapper; |
| | | |
| | | @Resource |
| | | private TownMapper townMapper; |
| | | |
| | | @Resource |
| | | private VillageMapper villageMapper; |
| | | |
| | | @Override |
| | | public List<Province> getProvinces() { |
| | |
| | | String cityCode = codeStr.substring(0,4)+"00"; |
| | | City city = cityMapper.selectByPrimaryKey(Integer.valueOf(cityCode)); |
| | | Area area = areaMapper.selectByPrimaryKey(code); |
| | | fullName = province.getProvinceName()+city.getCityName()+area.getAreaName(); |
| | | fullName = province.getProvinceName().replaceAll(" ", "") |
| | | +" "+city.getCityName().replaceAll(" ", "") |
| | | +" "+area.getAreaName().replaceAll(" ", ""); |
| | | } else if(!codeStr.endsWith("0000")){ |
| | | // 此时为 地级市code |
| | | String provinceCode = codeStr.substring(0,2)+"0000"; |
| | | Province province = provinceMapper.selectByPrimaryKey(Integer.valueOf(provinceCode)); |
| | | City city = cityMapper.selectByPrimaryKey(code); |
| | | fullName = province.getProvinceName()+city.getCityName(); |
| | | fullName = province.getProvinceName().replaceAll(" ", "") |
| | | +" "+city.getCityName().replaceAll(" ", ""); |
| | | } else { |
| | | // 此时为 省code |
| | | Province province = provinceMapper.selectByPrimaryKey(code); |
| | | fullName = province.getProvinceName(); |
| | | fullName = province.getProvinceName().replaceAll(" ", ""); |
| | | } |
| | | return fullName; |
| | | } |
| | | |
| | | @Override |
| | | public List<Town> getTowns(Integer areaCode) { |
| | | Example example = new Example(Town.class); |
| | | example.or().andEqualTo("areaCode",areaCode); |
| | | return townMapper.selectByExample(example); |
| | | } |
| | | |
| | | @Override |
| | | public List<Village> getVillages(Long townCode) { |
| | | Example example = new Example(Village.class); |
| | | example.createCriteria().andEqualTo("townCode",townCode); |
| | | return villageMapper.selectByExample(example); |
| | | } |
| | | } |