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