|
|
|
|
@ -16,6 +16,7 @@ |
|
|
|
|
*/ |
|
|
|
|
package org.springblade.common.cache; |
|
|
|
|
|
|
|
|
|
import org.springblade.common.constant.BusinessConstant; |
|
|
|
|
import org.springblade.core.cache.utils.CacheUtil; |
|
|
|
|
import org.springblade.core.tool.utils.SpringUtil; |
|
|
|
|
import org.springblade.core.tool.utils.StringPool; |
|
|
|
|
@ -80,7 +81,7 @@ public class SysCache { |
|
|
|
|
* @return 菜单 |
|
|
|
|
*/ |
|
|
|
|
public static Menu getMenu(Long id) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, MENU_ID, id, () -> menuService.getById(id)); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, MENU_ID, id, () -> menuService.getById(id), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -90,7 +91,7 @@ public class SysCache { |
|
|
|
|
* @return 部门 |
|
|
|
|
*/ |
|
|
|
|
public static Dept getDept(Long id) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, DEPT_ID, id, () -> deptService.getById(id)); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, DEPT_ID, id, () -> deptService.getById(id), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -101,7 +102,7 @@ public class SysCache { |
|
|
|
|
* @return 部门id |
|
|
|
|
*/ |
|
|
|
|
public static String getDeptIds(String tenantId, String deptNames) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, DEPT_NAME, tenantId + StringPool.DASH + deptNames, () -> deptService.getDeptIds(tenantId, deptNames)); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, DEPT_NAME, tenantId + StringPool.DASH + deptNames, () -> deptService.getDeptIds(tenantId, deptNames), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -112,7 +113,7 @@ public class SysCache { |
|
|
|
|
* @return 部门id |
|
|
|
|
*/ |
|
|
|
|
public static String getDeptIdsByFuzzy(String tenantId, String deptNames) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, DEPT_NAME_FUZZY, tenantId + StringPool.DASH + deptNames, () -> deptService.getDeptIdsByFuzzy(tenantId, deptNames)); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, DEPT_NAME_FUZZY, tenantId + StringPool.DASH + deptNames, () -> deptService.getDeptIdsByFuzzy(tenantId, deptNames), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -122,7 +123,7 @@ public class SysCache { |
|
|
|
|
* @return 部门名 |
|
|
|
|
*/ |
|
|
|
|
public static String getDeptName(Long id) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, DEPT_NAME_ID, id, () -> deptService.getById(id).getDeptName()); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, DEPT_NAME_ID, id, () -> deptService.getById(id).getDeptName(), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -133,7 +134,7 @@ public class SysCache { |
|
|
|
|
* @return 部门名 |
|
|
|
|
*/ |
|
|
|
|
public static List<String> getDeptNames(String deptIds) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, DEPT_NAMES_ID, deptIds, () -> deptService.getDeptNames(deptIds)); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, DEPT_NAMES_ID, deptIds, () -> deptService.getDeptNames(deptIds), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -143,7 +144,7 @@ public class SysCache { |
|
|
|
|
* @return 子部门 |
|
|
|
|
*/ |
|
|
|
|
public static List<Dept> getDeptChild(Long deptId) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, DEPT_CHILD_ID, deptId, () -> deptService.getDeptChild(deptId)); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, DEPT_CHILD_ID, deptId, () -> deptService.getDeptChild(deptId), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -156,7 +157,7 @@ public class SysCache { |
|
|
|
|
if (deptId == null) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
List<Long> deptIdList = CacheUtil.get(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, List.class); |
|
|
|
|
List<Long> deptIdList = CacheUtil.get(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, List.class, BusinessConstant.TENANT_MODE); |
|
|
|
|
if (deptIdList == null) { |
|
|
|
|
deptIdList = new ArrayList<>(); |
|
|
|
|
List<Dept> deptChild = getDeptChild(deptId); |
|
|
|
|
@ -165,7 +166,7 @@ public class SysCache { |
|
|
|
|
deptIdList.addAll(collect); |
|
|
|
|
} |
|
|
|
|
deptIdList.add(deptId); |
|
|
|
|
CacheUtil.put(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, deptIdList); |
|
|
|
|
CacheUtil.put(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, deptIdList, BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
return deptIdList; |
|
|
|
|
} |
|
|
|
|
@ -177,7 +178,7 @@ public class SysCache { |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public static Post getPost(Long id) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, POST_ID, id, () -> postService.getById(id)); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, POST_ID, id, () -> postService.getById(id), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -188,7 +189,7 @@ public class SysCache { |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public static String getPostIds(String tenantId, String postNames) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, POST_NAME, tenantId + StringPool.DASH + postNames, () -> postService.getPostIds(tenantId, postNames)); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, POST_NAME, tenantId + StringPool.DASH + postNames, () -> postService.getPostIds(tenantId, postNames), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -199,7 +200,7 @@ public class SysCache { |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public static String getPostIdsByFuzzy(String tenantId, String postNames) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, POST_NAME_FUZZY, tenantId + StringPool.DASH + postNames, () -> postService.getPostIdsByFuzzy(tenantId, postNames)); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, POST_NAME_FUZZY, tenantId + StringPool.DASH + postNames, () -> postService.getPostIdsByFuzzy(tenantId, postNames), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -209,7 +210,7 @@ public class SysCache { |
|
|
|
|
* @return 岗位名 |
|
|
|
|
*/ |
|
|
|
|
public static String getPostName(Long id) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, POST_NAME_ID, id, () -> postService.getById(id).getPostName()); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, POST_NAME_ID, id, () -> postService.getById(id).getPostName(), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -219,7 +220,7 @@ public class SysCache { |
|
|
|
|
* @return 岗位名 |
|
|
|
|
*/ |
|
|
|
|
public static List<String> getPostNames(String postIds) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, POST_NAMES_ID, postIds, () -> postService.getPostNames(postIds)); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, POST_NAMES_ID, postIds, () -> postService.getPostNames(postIds), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -229,7 +230,7 @@ public class SysCache { |
|
|
|
|
* @return Role |
|
|
|
|
*/ |
|
|
|
|
public static Role getRole(Long id) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, ROLE_ID, id, () -> roleService.getById(id)); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, ROLE_ID, id, () -> roleService.getById(id), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -240,7 +241,7 @@ public class SysCache { |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
public static String getRoleIds(String tenantId, String roleNames) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, ROLE_NAME, tenantId + StringPool.DASH + roleNames, () -> roleService.getRoleIds(tenantId, roleNames)); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, ROLE_NAME, tenantId + StringPool.DASH + roleNames, () -> roleService.getRoleIds(tenantId, roleNames), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -250,7 +251,7 @@ public class SysCache { |
|
|
|
|
* @return 角色名 |
|
|
|
|
*/ |
|
|
|
|
public static String getRoleName(Long id) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, ROLE_NAME_ID, id, () -> roleService.getById(id).getRoleName()); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, ROLE_NAME_ID, id, () -> roleService.getById(id).getRoleName(), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -260,7 +261,7 @@ public class SysCache { |
|
|
|
|
* @return 角色名 |
|
|
|
|
*/ |
|
|
|
|
public static List<String> getRoleNames(String roleIds) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, ROLE_NAMES_ID, roleIds, () -> roleService.getRoleNames(roleIds)); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, ROLE_NAMES_ID, roleIds, () -> roleService.getRoleNames(roleIds), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -270,7 +271,7 @@ public class SysCache { |
|
|
|
|
* @return 角色别名 |
|
|
|
|
*/ |
|
|
|
|
public static String getRoleAlias(Long id) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, ROLE_ALIAS_ID, id, () -> roleService.getById(id).getRoleAlias()); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, ROLE_ALIAS_ID, id, () -> roleService.getById(id).getRoleAlias(), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -280,7 +281,7 @@ public class SysCache { |
|
|
|
|
* @return 角色别名 |
|
|
|
|
*/ |
|
|
|
|
public static List<String> getRoleAliases(String roleIds) { |
|
|
|
|
return CacheUtil.get(SYS_CACHE, ROLE_ALIASES_ID, roleIds, () -> roleService.getRoleAliases(roleIds)); |
|
|
|
|
return CacheUtil.get(SYS_CACHE, ROLE_ALIASES_ID, roleIds, () -> roleService.getRoleAliases(roleIds), BusinessConstant.TENANT_MODE); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|