mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 05:12:07 +08:00
1、组织套餐下的权限菜单id支持缓存、修改套餐内容或组织更换套餐时刷新对应缓存;2、增加组织套餐下菜单的过滤:登录系统展现菜单、接口权限串校验、角色管理给角色授权的可选菜单列表;
This commit is contained in:
+17
-1
@@ -1,5 +1,6 @@
|
||||
package com.cf.imes.framework.organ.core.redis;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import com.cf.imes.framework.redis.core.TimeoutRedisCacheManager;
|
||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -8,6 +9,9 @@ import org.springframework.data.redis.cache.RedisCacheConfiguration;
|
||||
import org.springframework.data.redis.cache.RedisCacheManager;
|
||||
import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 多组织的 {@link RedisCacheManager} 实现类
|
||||
*
|
||||
@@ -18,6 +22,13 @@ import org.springframework.data.redis.cache.RedisCacheWriter;
|
||||
@Slf4j
|
||||
public class OrganRedisCacheManager extends TimeoutRedisCacheManager {
|
||||
|
||||
// 不需要拼接组织id的redis-key列表
|
||||
private static final List<String> ignoreOrganIdKeyList = new ArrayList<>();
|
||||
|
||||
static {
|
||||
ignoreOrganIdKeyList.add("tenant_package_menu_ids");
|
||||
}
|
||||
|
||||
public OrganRedisCacheManager(RedisCacheWriter cacheWriter,
|
||||
RedisCacheConfiguration defaultCacheConfiguration) {
|
||||
super(cacheWriter, defaultCacheConfiguration);
|
||||
@@ -25,9 +36,14 @@ public class OrganRedisCacheManager extends TimeoutRedisCacheManager {
|
||||
|
||||
@Override
|
||||
public Cache getCache(String name) {
|
||||
// key带#代表设置了ttl,只保留#前的部分作为key
|
||||
if (name.contains("#")) {
|
||||
name = CharSequenceUtil.subBefore(name, "#", false);
|
||||
}
|
||||
// 如果开启多组织,则 name 拼接组织后缀
|
||||
if (!OrganContextHolder.isIgnore()
|
||||
&& OrganContextHolder.getOrganId() != null) {
|
||||
&& OrganContextHolder.getOrganId() != null
|
||||
&& !ignoreOrganIdKeyList.contains(name)) {
|
||||
name = name + ":" + OrganContextHolder.getOrganId();
|
||||
}
|
||||
|
||||
|
||||
+6
-3
@@ -41,12 +41,15 @@ public class TimeoutRedisCacheManager extends RedisCacheManager {
|
||||
// 核心:通过修改 cacheConfig 的过期时间,实现自定义过期时间
|
||||
if (cacheConfig != null) {
|
||||
// 移除 # 后面的 : 以及后面的内容,避免影响解析
|
||||
names[1] = CharSequenceUtil.subBefore(names[1], StrPool.COLON, false);
|
||||
String ttlStr = CharSequenceUtil.subBefore(names[1], StrPool.COLON, false); // 获得 ttlStr 时间部分
|
||||
names[1] = CharSequenceUtil.subAfter(names[1], ttlStr, false); // 移除掉 ttlStr 时间部分
|
||||
// 解析时间
|
||||
Duration duration = parseDuration(names[1]);
|
||||
Duration duration = parseDuration(ttlStr);
|
||||
cacheConfig = cacheConfig.entryTtl(duration);
|
||||
}
|
||||
return super.createRedisCache(name, cacheConfig);
|
||||
|
||||
// 创建 RedisCache 对象,需要忽略掉 ttlStr
|
||||
return super.createRedisCache(names[0] + names[1], cacheConfig);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user