From cc595b0aa24773735417accd0158da6ac98a6db0 Mon Sep 17 00:00:00 2001 From: 101captain <237651143@qq.com> Date: 星期四, 30 六月 2022 14:47:56 +0800 Subject: [PATCH] Merge branch 'huacheng' into huacheng_test --- springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/BcRegionServiceImpl.java | 32 ++++++++++++++++++++++++++++++++ 1 files changed, 32 insertions(+), 0 deletions(-) diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/BcRegionServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/BcRegionServiceImpl.java index 0e60ec0..866d8af 100644 --- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/BcRegionServiceImpl.java +++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/BcRegionServiceImpl.java @@ -1,13 +1,19 @@ package com.panzhihua.service_community.service.impl; +import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.panzhihua.common.model.dtos.property.CommonPage; import com.panzhihua.common.model.vos.R; +import com.panzhihua.common.model.vos.community.ProvinceCityReturnVO; import com.panzhihua.service_community.entity.BcRegion; import com.panzhihua.service_community.dao.BcRegionDao; import com.panzhihua.service_community.service.BcRegionService; import lombok.extern.slf4j.Slf4j; +import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; /** * 行政区划表(BcRegion)表服务实现类 @@ -20,9 +26,35 @@ @Slf4j @Service public class BcRegionServiceImpl extends ServiceImpl<BcRegionDao, BcRegion> implements BcRegionService { + @Resource + private StringRedisTemplate stringRedisTemplate; @Override public R pageList(String province, String city, String country,String town) { return R.ok(this.baseMapper.selectByName(province,city,country,town)); } + + @Override + public R levelList() { + if(stringRedisTemplate.hasKey("levelList")){ + return R.ok(stringRedisTemplate.opsForValue().get("levelList")); + } + else { + List<ProvinceCityReturnVO> firstLevel=this.baseMapper.selectFirst(); + firstLevel.forEach(provinceCityReturnVO -> { + List<ProvinceCityReturnVO> secondLevel=this.baseMapper.selectSecond(provinceCityReturnVO.getName()); + secondLevel.forEach(provinceCityReturnVO1 -> { + List<ProvinceCityReturnVO> thirdLevel=this.baseMapper.selectThird(provinceCityReturnVO1.getName()); + thirdLevel.forEach(provinceCityReturnVO2 -> { + List<ProvinceCityReturnVO> fourthLevel=this.baseMapper.selectFourth(provinceCityReturnVO2.getName()); + provinceCityReturnVO2.setProvinceCityReturnVOList(fourthLevel); + }); + provinceCityReturnVO1.setProvinceCityReturnVOList(thirdLevel); + }); + provinceCityReturnVO.setProvinceCityReturnVOList(secondLevel); + }); + stringRedisTemplate.opsForValue().set("levelList", JSON.toJSONString(firstLevel)); + return R.ok(firstLevel); + } + } } -- Gitblit v1.7.1