DistrictGlossoryService.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. package com.goafanti.common.service;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import org.slf4j.Logger;
  5. import org.slf4j.LoggerFactory;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.cache.annotation.CacheEvict;
  8. import org.springframework.cache.annotation.Cacheable;
  9. import org.springframework.stereotype.Service;
  10. import com.goafanti.common.bo.AreaBo;
  11. import com.goafanti.common.bo.CityBo;
  12. import com.goafanti.common.bo.ProvinceBo;
  13. import com.goafanti.common.dao.DistrictGlossoryMapper;
  14. import com.goafanti.common.model.DistrictGlossory;
  15. import com.goafanti.common.utils.LoggerUtils;
  16. @Service
  17. public class DistrictGlossoryService {
  18. private static final Logger logger = LoggerFactory.getLogger(DistrictGlossoryService.class);
  19. @Autowired
  20. private DistrictGlossoryMapper districtGlossoryMapper;
  21. public DistrictGlossory selectByPrimaryKey(Integer id) {
  22. return districtGlossoryMapper.selectByPrimaryKey(id);
  23. }
  24. @Cacheable(value = "DistrictGlossoryCache", key = "'DistrictGlossory:'+#pid")
  25. public List<DistrictGlossory> list(Integer pid) {
  26. LoggerUtils.debug(logger, "缓存地区列表:[%s]", pid);
  27. return districtGlossoryMapper.findByPid(pid);
  28. }
  29. @CacheEvict(value = "DistrictGlossoryCache", key = "'DistrictGlossory:'+#pid")
  30. public void clear(Integer pid) {
  31. LoggerUtils.debug(logger, "清除地区列表缓存:[%s]", pid);
  32. }
  33. public String selectNameById(Integer id) {
  34. return districtGlossoryMapper.selectNameById(id);
  35. }
  36. public List<ProvinceBo> getProvince(){
  37. List<ProvinceBo> provinces=districtGlossoryMapper.getProvince();
  38. List<CityBo> city=districtGlossoryMapper.getCity();
  39. List<AreaBo> Area=districtGlossoryMapper.getArea();
  40. for(ProvinceBo one:provinces){
  41. List <CityBo> cc=new ArrayList<CityBo>();
  42. int pbid = one.getId();
  43. for(CityBo two:city){
  44. List <AreaBo> aa=new ArrayList<AreaBo>();
  45. int cbid=two.getId();
  46. int cbpid=two.getPid();
  47. if(cbpid==pbid){
  48. for(AreaBo three:Area){
  49. int abpid=three.getPid();
  50. if(abpid==cbid){
  51. aa.add(three);
  52. two.setAreaList(aa);
  53. }
  54. }
  55. cc.add(two);
  56. one.setCityList(cc);
  57. }
  58. }
  59. }
  60. return provinces;
  61. }
  62. }