fix bug
This commit is contained in:
Vendored
+40
@@ -31,6 +31,10 @@ import org.springblade.core.tool.utils.SpringUtil;
|
||||
import org.springblade.system.pojo.entity.Region;
|
||||
import org.springblade.system.feign.ISysClient;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import static org.springblade.core.cache.constant.CacheConstant.SYS_CACHE;
|
||||
|
||||
/**
|
||||
@@ -50,6 +54,8 @@ public class RegionCache {
|
||||
public static final int VILLAGE_LEVEL = 5;
|
||||
|
||||
private static final String REGION_CODE = "region:code:";
|
||||
private static final String REGION_TREE_CACHE = "region:tree";
|
||||
private static final String REGION_LAZY_TREE = "lazy-tree:";
|
||||
|
||||
private static ISysClient sysClient;
|
||||
|
||||
@@ -73,4 +79,38 @@ public class RegionCache {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取行政区划懒加载树
|
||||
*
|
||||
* @param parentCode 父区划编号
|
||||
* @param param 查询参数
|
||||
* @param loader 数据加载器
|
||||
* @return 懒加载树
|
||||
*/
|
||||
public static List<Map<String, Object>> getLazyTree(
|
||||
String parentCode,
|
||||
Map<String, Object> param,
|
||||
Callable<List<Map<String, Object>>> loader) {
|
||||
Map<String, Object> query = param == null ? Map.of() : param;
|
||||
String cacheKey = String.join("|",
|
||||
cacheKeyPart(parentCode),
|
||||
cacheKeyPart(query.get("code")),
|
||||
cacheKeyPart(query.get("name")),
|
||||
cacheKeyPart(query.get("regionLevel"))
|
||||
);
|
||||
return CacheUtil.get(REGION_TREE_CACHE, REGION_LAZY_TREE, cacheKey, loader, Boolean.FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 清除行政区划懒加载树缓存
|
||||
*/
|
||||
public static void clearLazyTree() {
|
||||
CacheUtil.clear(REGION_TREE_CACHE, Boolean.FALSE);
|
||||
}
|
||||
|
||||
private static String cacheKeyPart(Object value) {
|
||||
String text = value == null ? "" : String.valueOf(value);
|
||||
return text.length() + ":" + text;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user