Browse Source

导航菜单添加缓存

release
jianjun 4 years ago
parent
commit
7589b5a6b2
  1. 3
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 11
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java
  3. 9
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovMenuServiceImpl.java

3
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); 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;
}
} }

11
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovMenuRedis.java

@ -71,4 +71,13 @@ public class GovMenuRedis {
return (Set<String>)redisUtils.get(key); return (Set<String>)redisUtils.get(key);
} }
} public void setCustomerMenuList(String customerId, Integer type, List<GovMenuDTO> govMenuDTOS) {
String key = RedisKeys.getCustomerMenuList(customerId, type);
redisUtils.set(key,govMenuDTOS,RedisUtils.DEFAULT_EXPIRE);
}
public List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type) {
String key = RedisKeys.getCustomerMenuList(customerId, type);
return (List<GovMenuDTO>)redisUtils.get(key);
}
}

9
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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.util.*; import java.util.*;
@ -208,9 +209,15 @@ public class GovMenuServiceImpl extends BaseServiceImpl<GovMenuDao, GovMenuEntit
* @Date 15:51 2021-03-16 * @Date 15:51 2021-03-16
**/ **/
private List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type) { private List<GovMenuDTO> getCustomerMenuList(String customerId, Integer type) {
List<GovMenuDTO> govMenuDTOS = govMenuRedis.getCustomerMenuList(customerId,type);
if (!CollectionUtils.isEmpty(govMenuDTOS)){
return govMenuDTOS;
}
List<GovMenuEntity> menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage()); List<GovMenuEntity> menuList = baseDao.getCustomerMenuList(customerId, type, HttpContextUtils.getLanguage());
List<GovMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class); List<GovMenuDTO> dtoList = ConvertUtils.sourceToTarget(menuList, GovMenuDTO.class);
return TreeUtils.buildTree(dtoList); govMenuDTOS = TreeUtils.buildTree(dtoList);
govMenuRedis.setCustomerMenuList(customerId,type,govMenuDTOS);
return govMenuDTOS;
} }
@Override @Override

Loading…
Cancel
Save