From 7589b5a6b2d771bd42416fd8ce445bb058ce0edb Mon Sep 17 00:00:00 2001 From: jianjun Date: Thu, 24 Feb 2022 17:23:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=BC=E8=88=AA=E8=8F=9C=E5=8D=95=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/commons/tools/redis/RedisKeys.java | 3 +++ .../src/main/java/com/epmet/redis/GovMenuRedis.java | 11 ++++++++++- .../com/epmet/service/impl/GovMenuServiceImpl.java | 9 ++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index fe03008b81..876cc61ccd 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -733,4 +733,7 @@ public class RedisKeys { return rootPrefix.concat("temporary:").concat("temporaryResult:").concat(customerId).concat(":").concat(userId); } + public static String getCustomerMenuList(String customerId, Integer type) { + return rootPrefix.concat("oper:access:nav:customerId:").concat(customerId)+type; + } } diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java index 361d6c3014..8f6a61da6c 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java @@ -71,4 +71,13 @@ public class GovMenuRedis { return (Set)redisUtils.get(key); } -} \ No newline at end of file + public void setCustomerMenuList(String customerId, Integer type, List govMenuDTOS) { + String key = RedisKeys.getCustomerMenuList(customerId, type); + redisUtils.set(key,govMenuDTOS,RedisUtils.DEFAULT_EXPIRE); + } + + public List getCustomerMenuList(String customerId, Integer type) { + String key = RedisKeys.getCustomerMenuList(customerId, type); + return (List)redisUtils.get(key); + } +} diff --git a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java index 4e4c142b55..8eb3bcf5e2 100644 --- a/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java +++ b/epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java @@ -42,6 +42,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.util.CollectionUtils; import java.util.*; @@ -208,9 +209,15 @@ public class GovMenuServiceImpl extends BaseServiceImpl getCustomerMenuList(String customerId, Integer type) { + List govMenuDTOS = govMenuRedis.getCustomerMenuList(customerId,type); + if (!CollectionUtils.isEmpty(govMenuDTOS)){ + return govMenuDTOS; + } List menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage()); List dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); - return TreeUtils.buildTree(dtoList); + govMenuDTOS = TreeUtils.buildTree(dtoList); + govMenuRedis.setCustomerMenuList(customerId,type,govMenuDTOS); + return govMenuDTOS; } @Override