Browse Source

菜单缓存必须全干掉

release
jianjun 3 years ago
parent
commit
d46e8e1154
  1. 10
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java
  2. 10
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java
  3. 5
      epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java

10
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java

@ -734,6 +734,14 @@ public class RedisKeys {
}
public static String getCustomerMenuList(String customerId, Integer type) {
return rootPrefix.concat("oper:access:nav:customerId:").concat(customerId).concat(":type:")+type;
return getCustomerMenuListPrefix().concat(customerId).concat(":type:")+type;
}
/**
* desc:菜单缓存前缀
* @return
*/
public static String getCustomerMenuListPrefix() {
return rootPrefix.concat("oper:access:nav:customerId:");
}
}

10
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/redis/GovCustomerMenuRedis.java

@ -17,6 +17,7 @@
package com.epmet.redis;
import com.epmet.commons.tools.constant.StrConstant;
import com.epmet.commons.tools.redis.RedisKeys;
import com.epmet.commons.tools.redis.RedisUtils;
import com.epmet.dto.GovMenuDTO;
@ -66,18 +67,13 @@ public class GovCustomerMenuRedis {
/**
* desc:删除客户菜单缓存
* @param customerId
* @param type
* @see com.epmet.enums.MenuTypeEnum
*/
public void delCustomerMenu(String customerId, Integer type) {
if (checkParam(customerId, type)) {
String key = RedisKeys.getCustomerMenuList(customerId, type);
public void delAllCustomerMenu() {
String key = RedisKeys.getCustomerMenuListPrefix().concat(StrConstant.STAR);
redisUtils.delete(key);
}
}
private boolean checkParam(String customerId, Integer type) {
if (StringUtils.isBlank(customerId) || type == null){
log.warn("checkParam fail, param is null");

5
epmet-module/gov-access/gov-access-server/src/main/java/com/epmet/service/impl/GovCustomerMenuServiceImpl.java

@ -28,7 +28,6 @@ import com.epmet.dao.GovCustomerMenuDao;
import com.epmet.dto.GovCustomerMenuDTO;
import com.epmet.dto.form.MenuConfigFormDTO;
import com.epmet.entity.GovCustomerMenuEntity;
import com.epmet.enums.MenuTypeEnum;
import com.epmet.redis.GovCustomerMenuRedis;
import com.epmet.service.GovCustomerMenuService;
import org.apache.commons.lang3.StringUtils;
@ -119,8 +118,8 @@ public class GovCustomerMenuServiceImpl extends BaseServiceImpl<GovCustomerMenuD
}
insertBatch(entities);
}
//删除缓存
formDTO.getCustomerIds().forEach(customerId-> govCustomerMenuRedis.delCustomerMenu(customerId, MenuTypeEnum.MENU.value()));
//删除全部客户缓存
govCustomerMenuRedis.delAllCustomerMenu();
}
@Override

Loading…
Cancel
Save