mirror of
https://gitee.com/orangeform/orange-admin.git
synced 2026-01-17 18:46:36 +08:00
commit:同步2.2版本
This commit is contained in:
@@ -28,6 +28,10 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class RedisDictionaryCache<K, V> implements DictionaryCache<K, V> {
|
||||
|
||||
/**
|
||||
* 字典数据前缀,便于Redis工具分组显示。
|
||||
*/
|
||||
protected static final String DICT_PREFIX = "DICT-TABLE:";
|
||||
/**
|
||||
* redisson客户端。
|
||||
*/
|
||||
@@ -89,7 +93,8 @@ public class RedisDictionaryCache<K, V> implements DictionaryCache<K, V> {
|
||||
Class<V> valueClazz,
|
||||
Function<V, K> idGetter) {
|
||||
this.redissonClient = redissonClient;
|
||||
this.dataMap = redissonClient.getMap(dictionaryName + ApplicationConstant.DICT_CACHE_NAME_SUFFIX);
|
||||
this.dataMap = redissonClient.getMap(
|
||||
DICT_PREFIX + dictionaryName + ApplicationConstant.DICT_CACHE_NAME_SUFFIX);
|
||||
this.lock = new ReentrantReadWriteLock();
|
||||
this.valueClazz = valueClazz;
|
||||
this.idGetter = idGetter;
|
||||
|
||||
@@ -29,6 +29,10 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
public class RedisTenantDictionaryCache<K, V> implements DictionaryCache<K, V> {
|
||||
|
||||
/**
|
||||
* 字典数据前缀,便于Redis工具分组显示。
|
||||
*/
|
||||
protected static final String TENANT_DICT_PREFIX = "TENANT-DICT-TABLE:";
|
||||
/**
|
||||
* redisson客户端。
|
||||
*/
|
||||
@@ -102,8 +106,8 @@ public class RedisTenantDictionaryCache<K, V> implements DictionaryCache<K, V> {
|
||||
protected RMap<K, String> getTenantDataMap() {
|
||||
Long tenantId = TokenData.takeFromRequest().getTenantId();
|
||||
StringBuilder s = new StringBuilder(64);
|
||||
s.append(dictionaryName).append("-")
|
||||
.append(tenantId).append(ApplicationConstant.TREE_DICT_CACHE_NAME_SUFFIX);
|
||||
s.append(TENANT_DICT_PREFIX).append(dictionaryName).append("-")
|
||||
.append(tenantId).append(ApplicationConstant.DICT_CACHE_NAME_SUFFIX);
|
||||
return redissonClient.getMap(s.toString());
|
||||
}
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ public class RedisTenantTreeDictionaryCache<K, V> extends RedisTenantDictionaryC
|
||||
protected RListMultimap<K, String> getTenantTreeDataMap() {
|
||||
Long tenantId = TokenData.takeFromRequest().getTenantId();
|
||||
StringBuilder s = new StringBuilder(64);
|
||||
s.append(dictionaryName).append("-")
|
||||
s.append(TENANT_DICT_PREFIX).append(dictionaryName).append("-")
|
||||
.append(tenantId).append(ApplicationConstant.TREE_DICT_CACHE_NAME_SUFFIX);
|
||||
return redissonClient.getListMultimap(s.toString());
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class RedisTreeDictionaryCache<K, V> extends RedisDictionaryCache<K, V> {
|
||||
Function<V, K> parentIdGetter) {
|
||||
super(redissonClient, dictionaryName, valueClazz, idGetter);
|
||||
this.allTreeMap = redissonClient.getListMultimap(
|
||||
dictionaryName + ApplicationConstant.TREE_DICT_CACHE_NAME_SUFFIX);
|
||||
DICT_PREFIX + dictionaryName + ApplicationConstant.TREE_DICT_CACHE_NAME_SUFFIX);
|
||||
this.parentIdGetter = parentIdGetter;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.orangeforms.common.redis.cache;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.orangeforms.common.core.object.TokenData;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.Cache;
|
||||
@@ -43,6 +44,28 @@ public class SessionCacheHelper {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 缓存当前Session可以下载的文件集合。
|
||||
*
|
||||
* @param filenameSet 后台服务本地存储的文件名,而不是上传时的原始文件名。
|
||||
*/
|
||||
public void putSessionDownloadableFileNameSet(Set<String> filenameSet) {
|
||||
if (CollUtil.isEmpty(filenameSet)) {
|
||||
return;
|
||||
}
|
||||
Set<String> sessionUploadFileSet = null;
|
||||
Cache cache = cacheManager.getCache(RedissonCacheConfig.CacheEnum.UPLOAD_FILENAME_CACHE.name());
|
||||
Cache.ValueWrapper valueWrapper = cache.get(TokenData.takeFromRequest().getSessionId());
|
||||
if (valueWrapper != null) {
|
||||
sessionUploadFileSet = (Set<String>) valueWrapper.get();
|
||||
}
|
||||
if (sessionUploadFileSet == null) {
|
||||
sessionUploadFileSet = new HashSet<>();
|
||||
}
|
||||
sessionUploadFileSet.addAll(filenameSet);
|
||||
cache.put(TokenData.takeFromRequest().getSessionId(), sessionUploadFileSet);
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断参数中的文件名,是否有当前session上传。
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user