|
@@ -2,6 +2,7 @@ package com.qmth.sop.business.cache.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.google.gson.reflect.TypeToken;
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
|
+import com.qmth.boot.core.cache.service.CacheService;
|
|
import com.qmth.sop.business.bean.auth.AuthBean;
|
|
import com.qmth.sop.business.bean.auth.AuthBean;
|
|
import com.qmth.sop.business.bean.dto.MenuDto;
|
|
import com.qmth.sop.business.bean.dto.MenuDto;
|
|
import com.qmth.sop.business.bean.dto.MenuPrivilegeDto;
|
|
import com.qmth.sop.business.bean.dto.MenuPrivilegeDto;
|
|
@@ -45,8 +46,8 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
@Resource
|
|
@Resource
|
|
SysConfigService sysConfigService;
|
|
SysConfigService sysConfigService;
|
|
|
|
|
|
- // @Resource
|
|
|
|
- // CacheService cacheService;
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ CacheService cacheService;
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
SysUserRoleService sysUserRoleService;
|
|
SysUserRoleService sysUserRoleService;
|
|
@@ -96,7 +97,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
@Override
|
|
@Override
|
|
// @CachePut(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0", condition = "#result != null")
|
|
// @CachePut(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0", condition = "#result != null")
|
|
public SysUser updateUserCache(Long userId) {
|
|
public SysUser updateUserCache(Long userId) {
|
|
- // cacheService.evict(SystemConstant.USER_ACCOUNT_CACHE, String.valueOf(userId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.USER_ACCOUNT_CACHE, String.valueOf(userId));
|
|
return userCacheCommon(userId);
|
|
return userCacheCommon(userId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -107,16 +108,16 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
private SysUser userCacheCommon(Long userId) {
|
|
private SysUser userCacheCommon(Long userId) {
|
|
- // SysUser sysUser = (SysUser) cacheService.get(SystemConstant.USER_ACCOUNT_CACHE, String.valueOf(userId));
|
|
|
|
- // if (Objects.isNull(sysUser)) {
|
|
|
|
- // sysUser = sysUserService.getById(userId);
|
|
|
|
- // if (Objects.nonNull(sysUser)) {
|
|
|
|
- // cacheService.put(SystemConstant.USER_ACCOUNT_CACHE, String.valueOf(userId), sysUser);
|
|
|
|
- // } else {
|
|
|
|
- // throw ExceptionResultEnum.ERROR.exception("userId[" + userId + "]用户不存在");
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- return sysUserService.getById(userId);
|
|
|
|
|
|
+ SysUser sysUser = (SysUser) cacheService.get(SystemConstant.USER_ACCOUNT_CACHE, String.valueOf(userId));
|
|
|
|
+ if (Objects.isNull(sysUser)) {
|
|
|
|
+ sysUser = sysUserService.getById(userId);
|
|
|
|
+ if (Objects.nonNull(sysUser)) {
|
|
|
|
+ cacheService.put(SystemConstant.USER_ACCOUNT_CACHE, String.valueOf(userId), sysUser);
|
|
|
|
+ } else {
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("userId[" + userId + "]用户不存在");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return sysUser;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -127,7 +128,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
@Override
|
|
@Override
|
|
// @CacheEvict(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0")
|
|
// @CacheEvict(value = SystemConstant.USER_ACCOUNT_CACHE, key = "#p0")
|
|
public void removeUserCache(Long userId) {
|
|
public void removeUserCache(Long userId) {
|
|
- // cacheService.evict(SystemConstant.USER_ACCOUNT_CACHE, String.valueOf(userId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.USER_ACCOUNT_CACHE, String.valueOf(userId));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -137,15 +138,15 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
private SysConfig sysConfigCacheCommon(String key) {
|
|
private SysConfig sysConfigCacheCommon(String key) {
|
|
- // SysConfig sysConfig = (SysConfig) cacheService.get(SystemConstant.SYS_CONFIG_CACHE, key);
|
|
|
|
- // if (Objects.isNull(sysConfig)) {
|
|
|
|
- // sysConfig = sysConfigService.getOne(
|
|
|
|
- // new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getConfigKey, key));
|
|
|
|
- // if (Objects.nonNull(sysConfig)) {
|
|
|
|
- // cacheService.put(SystemConstant.SYS_CONFIG_CACHE, key, sysConfig);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- return sysConfigService.getOne(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getConfigKey, key));
|
|
|
|
|
|
+ SysConfig sysConfig = (SysConfig) cacheService.get(SystemConstant.SYS_CONFIG_CACHE, key);
|
|
|
|
+ if (Objects.isNull(sysConfig)) {
|
|
|
|
+ sysConfig = sysConfigService.getOne(
|
|
|
|
+ new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getConfigKey, key));
|
|
|
|
+ if (Objects.nonNull(sysConfig)) {
|
|
|
|
+ cacheService.put(SystemConstant.SYS_CONFIG_CACHE, key, sysConfig);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return sysConfig;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -169,7 +170,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
@Override
|
|
@Override
|
|
// @CachePut(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0", condition = "#result != null")
|
|
// @CachePut(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0", condition = "#result != null")
|
|
public SysConfig updateSysConfigCache(String key) {
|
|
public SysConfig updateSysConfigCache(String key) {
|
|
- // cacheService.evict(SystemConstant.SYS_CONFIG_CACHE, key);
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.SYS_CONFIG_CACHE, key);
|
|
return sysConfigCacheCommon(key);
|
|
return sysConfigCacheCommon(key);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -181,7 +182,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
@Override
|
|
@Override
|
|
// @CacheEvict(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0")
|
|
// @CacheEvict(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0")
|
|
public void removeSysConfigCache(String key) {
|
|
public void removeSysConfigCache(String key) {
|
|
- // cacheService.evict(SystemConstant.SYS_CONFIG_CACHE, key);
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.SYS_CONFIG_CACHE, key);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -193,7 +194,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
@Override
|
|
@Override
|
|
public void updateSysConfigCacheForDb(String key, SysConfig sysConfig) {
|
|
public void updateSysConfigCacheForDb(String key, SysConfig sysConfig) {
|
|
// cacheManager.getCache(SystemConstant.SYS_CONFIG_CACHE).put(key, sysConfig);
|
|
// cacheManager.getCache(SystemConstant.SYS_CONFIG_CACHE).put(key, sysConfig);
|
|
- // cacheService.put(SystemConstant.SYS_CONFIG_CACHE, key, sysConfig);
|
|
|
|
|
|
+ cacheService.put(SystemConstant.SYS_CONFIG_CACHE, key, sysConfig);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -204,16 +205,15 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
private SysConfig sysConfigCacheCommon(Long orgId, String key) {
|
|
private SysConfig sysConfigCacheCommon(Long orgId, String key) {
|
|
- // SysConfig sysConfig = (SysConfig) cacheService.get(SystemConstant.SYS_CONFIG_CACHE, orgId + "_" + key);
|
|
|
|
- // if (Objects.isNull(sysConfig)) {
|
|
|
|
- // sysConfig = sysConfigService.getOne(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getOrgId, orgId)
|
|
|
|
- // .eq(SysConfig::getConfigKey, key));
|
|
|
|
- // if (Objects.nonNull(sysConfig)) {
|
|
|
|
- // cacheService.put(SystemConstant.SYS_CONFIG_CACHE, orgId + "_" + key, sysConfig);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- return sysConfigService.getOne(
|
|
|
|
- new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getOrgId, orgId).eq(SysConfig::getConfigKey, key));
|
|
|
|
|
|
+ SysConfig sysConfig = (SysConfig) cacheService.get(SystemConstant.SYS_CONFIG_CACHE, orgId + "_" + key);
|
|
|
|
+ if (Objects.isNull(sysConfig)) {
|
|
|
|
+ sysConfig = sysConfigService.getOne(new QueryWrapper<SysConfig>().lambda().eq(SysConfig::getOrgId, orgId)
|
|
|
|
+ .eq(SysConfig::getConfigKey, key));
|
|
|
|
+ if (Objects.nonNull(sysConfig)) {
|
|
|
|
+ cacheService.put(SystemConstant.SYS_CONFIG_CACHE, orgId + "_" + key, sysConfig);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return sysConfig;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -239,7 +239,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
@Override
|
|
@Override
|
|
// @CachePut(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0 + '-' + #p1", condition = "#result != null")
|
|
// @CachePut(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0 + '-' + #p1", condition = "#result != null")
|
|
public SysConfig updateSysConfigCache(Long orgId, String key) {
|
|
public SysConfig updateSysConfigCache(Long orgId, String key) {
|
|
- // cacheService.evict(SystemConstant.SYS_CONFIG_CACHE, orgId + "_" + key);
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.SYS_CONFIG_CACHE, orgId + "_" + key);
|
|
return sysConfigCacheCommon(orgId, key);
|
|
return sysConfigCacheCommon(orgId, key);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -252,7 +252,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
@Override
|
|
@Override
|
|
// @CacheEvict(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0 + '-' + #p1")
|
|
// @CacheEvict(value = SystemConstant.SYS_CONFIG_CACHE, key = "#p0 + '-' + #p1")
|
|
public void removeSysConfigCache(Long orgId, String key) {
|
|
public void removeSysConfigCache(Long orgId, String key) {
|
|
- // cacheService.evict(SystemConstant.SYS_CONFIG_CACHE, orgId + "_" + key);
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.SYS_CONFIG_CACHE, orgId + "_" + key);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -299,56 +299,56 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public AuthBean userAuthCache(Long userId) {
|
|
public AuthBean userAuthCache(Long userId) {
|
|
- // AuthBean authBean = (AuthBean) cacheService.get(SystemConstant.USER_OAUTH_CACHE, String.valueOf(userId));
|
|
|
|
- // if (Objects.isNull(authBean)) {
|
|
|
|
- AuthBean authBean = null;
|
|
|
|
- try {
|
|
|
|
- SysUser user = this.userCache(userId);
|
|
|
|
- Optional.ofNullable(user).orElseThrow(() -> ExceptionResultEnum.USER_NO_DATA.exception());
|
|
|
|
- //查询用户角色和权限
|
|
|
|
- List<SysUserRole> sysUserRoleList = this.userRolePrivilegeCache(user.getId());
|
|
|
|
- if (Objects.nonNull(sysUserRoleList) && sysUserRoleList.size() > 0) {
|
|
|
|
- Set<Long> roleIds = sysUserRoleList.stream().map(s -> s.getRoleId()).collect(Collectors.toSet());
|
|
|
|
- List<SysRolePrivilege> sysRolePrivilegeList = new ArrayList<>();
|
|
|
|
- for (Long l : roleIds) {
|
|
|
|
- sysRolePrivilegeList.addAll(this.rolePrivilegeCache(l));
|
|
|
|
- }
|
|
|
|
- Set<Long> privilegeIds = sysRolePrivilegeList.stream().map(s -> s.getPrivilegeId())
|
|
|
|
- .collect(Collectors.toSet());
|
|
|
|
- List<SysRole> sysRoleList = sysRoleService.list(
|
|
|
|
- new QueryWrapper<SysRole>().lambda().in(SysRole::getId, roleIds).eq(SysRole::getEnable, true));
|
|
|
|
- int count = Objects.nonNull(sysRoleList) && sysRoleList.size() > 0 ?
|
|
|
|
- (int) sysRoleList.stream()
|
|
|
|
- .filter(s -> Objects.equals(s.getName(), RoleTypeEnum.ADMIN.getDesc())).count() :
|
|
|
|
- 0;
|
|
|
|
- QueryWrapper<SysPrivilege> sysPrivilegeQueryWrapper = new QueryWrapper<>();
|
|
|
|
- if (count > 0) {//超级系统管理员
|
|
|
|
- sysPrivilegeQueryWrapper.lambda().eq(SysPrivilege::getType, PrivilegeEnum.URL)
|
|
|
|
- .eq(SysPrivilege::getProperty, PrivilegePropertyEnum.AUTH);
|
|
|
|
- List<SysPrivilege> sysPrivilegeList = sysPrivilegeService.list(sysPrivilegeQueryWrapper);
|
|
|
|
- authBean = new AuthBean(sysRoleList,
|
|
|
|
- sysPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toSet()));
|
|
|
|
- } else {
|
|
|
|
- SysOrg org = Objects.nonNull(user.getOrgId()) ? this.orgCache(user.getOrgId()) : null;
|
|
|
|
- List<SysPrivilege> sysPrivilegeList = new ArrayList<>();
|
|
|
|
- if (privilegeIds.size() > 0) {
|
|
|
|
- sysPrivilegeQueryWrapper.lambda().in(SysPrivilege::getId, privilegeIds)
|
|
|
|
- .eq(SysPrivilege::getType, PrivilegeEnum.URL)
|
|
|
|
|
|
+ AuthBean authBean = (AuthBean) cacheService.get(SystemConstant.USER_OAUTH_CACHE, String.valueOf(userId));
|
|
|
|
+ if (Objects.isNull(authBean)) {
|
|
|
|
+ try {
|
|
|
|
+ SysUser user = this.userCache(userId);
|
|
|
|
+ Optional.ofNullable(user).orElseThrow(() -> ExceptionResultEnum.USER_NO_DATA.exception());
|
|
|
|
+ //查询用户角色和权限
|
|
|
|
+ List<SysUserRole> sysUserRoleList = this.userRolePrivilegeCache(user.getId());
|
|
|
|
+ if (Objects.nonNull(sysUserRoleList) && sysUserRoleList.size() > 0) {
|
|
|
|
+ Set<Long> roleIds = sysUserRoleList.stream().map(s -> s.getRoleId()).collect(Collectors.toSet());
|
|
|
|
+ List<SysRolePrivilege> sysRolePrivilegeList = new ArrayList<>();
|
|
|
|
+ for (Long l : roleIds) {
|
|
|
|
+ sysRolePrivilegeList.addAll(this.rolePrivilegeCache(l));
|
|
|
|
+ }
|
|
|
|
+ Set<Long> privilegeIds = sysRolePrivilegeList.stream().map(s -> s.getPrivilegeId())
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
+ List<SysRole> sysRoleList = sysRoleService.list(
|
|
|
|
+ new QueryWrapper<SysRole>().lambda().in(SysRole::getId, roleIds)
|
|
|
|
+ .eq(SysRole::getEnable, true));
|
|
|
|
+ int count = Objects.nonNull(sysRoleList) && sysRoleList.size() > 0 ?
|
|
|
|
+ (int) sysRoleList.stream()
|
|
|
|
+ .filter(s -> Objects.equals(s.getName(), RoleTypeEnum.ADMIN.getDesc())).count() :
|
|
|
|
+ 0;
|
|
|
|
+ QueryWrapper<SysPrivilege> sysPrivilegeQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ if (count > 0) {//超级系统管理员
|
|
|
|
+ sysPrivilegeQueryWrapper.lambda().eq(SysPrivilege::getType, PrivilegeEnum.URL)
|
|
.eq(SysPrivilege::getProperty, PrivilegePropertyEnum.AUTH);
|
|
.eq(SysPrivilege::getProperty, PrivilegePropertyEnum.AUTH);
|
|
- sysPrivilegeList = sysPrivilegeService.list(sysPrivilegeQueryWrapper);
|
|
|
|
|
|
+ List<SysPrivilege> sysPrivilegeList = sysPrivilegeService.list(sysPrivilegeQueryWrapper);
|
|
|
|
+ authBean = new AuthBean(sysRoleList,
|
|
|
|
+ sysPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toSet()));
|
|
|
|
+ } else {
|
|
|
|
+ SysOrg org = Objects.nonNull(user.getOrgId()) ? this.orgCache(user.getOrgId()) : null;
|
|
|
|
+ List<SysPrivilege> sysPrivilegeList = new ArrayList<>();
|
|
|
|
+ if (privilegeIds.size() > 0) {
|
|
|
|
+ sysPrivilegeQueryWrapper.lambda().in(SysPrivilege::getId, privilegeIds)
|
|
|
|
+ .eq(SysPrivilege::getType, PrivilegeEnum.URL)
|
|
|
|
+ .eq(SysPrivilege::getProperty, PrivilegePropertyEnum.AUTH);
|
|
|
|
+ sysPrivilegeList = sysPrivilegeService.list(sysPrivilegeQueryWrapper);
|
|
|
|
+ }
|
|
|
|
+ authBean = new AuthBean(sysRoleList,
|
|
|
|
+ sysPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toSet()), org);
|
|
}
|
|
}
|
|
- authBean = new AuthBean(sysRoleList,
|
|
|
|
- sysPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toSet()), org);
|
|
|
|
}
|
|
}
|
|
|
|
+ if (Objects.nonNull(authBean)) {
|
|
|
|
+ cacheService.put(SystemConstant.USER_OAUTH_CACHE, String.valueOf(userId), authBean);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error(SystemConstant.LOG_ERROR, e);
|
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("添加用户鉴权缓存失败");
|
|
}
|
|
}
|
|
- // if (Objects.nonNull(authBean)) {
|
|
|
|
- // cacheService.put(SystemConstant.USER_OAUTH_CACHE, String.valueOf(userId), authBean);
|
|
|
|
- // }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error(SystemConstant.LOG_ERROR, e);
|
|
|
|
- throw ExceptionResultEnum.ERROR.exception("添加用户鉴权缓存失败");
|
|
|
|
}
|
|
}
|
|
- // }
|
|
|
|
return authBean;
|
|
return authBean;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -360,7 +360,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public AuthBean updateUserAuthCache(Long userId) {
|
|
public AuthBean updateUserAuthCache(Long userId) {
|
|
- // cacheService.evict(SystemConstant.USER_OAUTH_CACHE, String.valueOf(userId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.USER_OAUTH_CACHE, String.valueOf(userId));
|
|
return userAuthCache(userId);
|
|
return userAuthCache(userId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -371,7 +371,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removeUserAuthCache(Long userId) {
|
|
public void removeUserAuthCache(Long userId) {
|
|
- // cacheService.evict(SystemConstant.USER_OAUTH_CACHE, String.valueOf(userId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.USER_OAUTH_CACHE, String.valueOf(userId));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -393,7 +393,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public List<SysUserRole> updateUserRolePrivilegeCache(Long userId) {
|
|
public List<SysUserRole> updateUserRolePrivilegeCache(Long userId) {
|
|
- // cacheService.evict(SystemConstant.USER_ROLE_PRIVILEGE_CACHE, String.valueOf(userId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.USER_ROLE_PRIVILEGE_CACHE, String.valueOf(userId));
|
|
return userRoleCacheCommon(userId);
|
|
return userRoleCacheCommon(userId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -404,7 +404,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removeUserRolePrivilegeCache(Long userId) {
|
|
public void removeUserRolePrivilegeCache(Long userId) {
|
|
- // cacheService.evict(SystemConstant.USER_ROLE_PRIVILEGE_CACHE, String.valueOf(userId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.USER_ROLE_PRIVILEGE_CACHE, String.valueOf(userId));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -426,7 +426,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public SysOrg updateOrgCache(Long orgId) {
|
|
public SysOrg updateOrgCache(Long orgId) {
|
|
- // cacheService.evict(SystemConstant.ORG_CACHE, String.valueOf(orgId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.ORG_CACHE, String.valueOf(orgId));
|
|
return orgCacheCommon(orgId);
|
|
return orgCacheCommon(orgId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -437,7 +437,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removeOrgCache(Long orgId) {
|
|
public void removeOrgCache(Long orgId) {
|
|
- // cacheService.evict(SystemConstant.ORG_CACHE, String.valueOf(orgId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.ORG_CACHE, String.valueOf(orgId));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -459,7 +459,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public List<SysRolePrivilege> updateRolePrivilegeCache(Long roleId) {
|
|
public List<SysRolePrivilege> updateRolePrivilegeCache(Long roleId) {
|
|
- // cacheService.evict(SystemConstant.ROLE_PRIVILEGE_CACHE, String.valueOf(roleId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.ROLE_PRIVILEGE_CACHE, String.valueOf(roleId));
|
|
return rolePrivilegeCacheCommon(roleId);
|
|
return rolePrivilegeCacheCommon(roleId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -470,7 +470,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removeRolePrivilegeCache(Long roleId) {
|
|
public void removeRolePrivilegeCache(Long roleId) {
|
|
- // cacheService.evict(SystemConstant.ROLE_PRIVILEGE_CACHE, String.valueOf(roleId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.ROLE_PRIVILEGE_CACHE, String.valueOf(roleId));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -492,7 +492,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public Set<String> updatePrivilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum) {
|
|
public Set<String> updatePrivilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum) {
|
|
- // cacheService.evict(SystemConstant.PRIVILEGE_URL_CACHE, privilegePropertyEnum.name());
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.PRIVILEGE_URL_CACHE, privilegePropertyEnum.name());
|
|
return privilegeUrlCacheCommon(privilegePropertyEnum);
|
|
return privilegeUrlCacheCommon(privilegePropertyEnum);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -503,7 +503,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removePrivilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum) {
|
|
public void removePrivilegeUrlCache(PrivilegePropertyEnum privilegePropertyEnum) {
|
|
- // cacheService.evict(SystemConstant.PRIVILEGE_URL_CACHE, privilegePropertyEnum.name());
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.PRIVILEGE_URL_CACHE, privilegePropertyEnum.name());
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -523,7 +523,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public List<FormWidgetResult> updateFormWidgetCache() {
|
|
public List<FormWidgetResult> updateFormWidgetCache() {
|
|
- // cacheService.evict(SystemConstant.FORM_WIDGET_CACHE, SystemConstant.FORM_WIDGET_CACHE);
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.FORM_WIDGET_CACHE, SystemConstant.FORM_WIDGET_CACHE);
|
|
return formWidgetCacheCommon();
|
|
return formWidgetCacheCommon();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -532,7 +532,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removeFormWidgetCache() {
|
|
public void removeFormWidgetCache() {
|
|
- // cacheService.evict(SystemConstant.FORM_WIDGET_CACHE, SystemConstant.FORM_WIDGET_CACHE);
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.FORM_WIDGET_CACHE, SystemConstant.FORM_WIDGET_CACHE);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -554,7 +554,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public TDFormWidget updateFormWidgetCache(Long id) {
|
|
public TDFormWidget updateFormWidgetCache(Long id) {
|
|
- // cacheService.evict(SystemConstant.FORM_WIDGET_CACHE, String.valueOf(id));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.FORM_WIDGET_CACHE, String.valueOf(id));
|
|
return formWidgetCacheCommon(id);
|
|
return formWidgetCacheCommon(id);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -565,7 +565,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removeFormWidgetCache(Long id) {
|
|
public void removeFormWidgetCache(Long id) {
|
|
- // cacheService.evict(SystemConstant.FORM_WIDGET_CACHE, String.valueOf(id));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.FORM_WIDGET_CACHE, String.valueOf(id));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -587,7 +587,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public List<TDTableProp> updateTablePropCache(Long widgetId) {
|
|
public List<TDTableProp> updateTablePropCache(Long widgetId) {
|
|
- // cacheService.evict(SystemConstant.TABLE_PROP_CACHE, String.valueOf(widgetId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.TABLE_PROP_CACHE, String.valueOf(widgetId));
|
|
return tablePropCacheCommon(widgetId);
|
|
return tablePropCacheCommon(widgetId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -598,7 +598,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removeTablePropCache(Long widgetId) {
|
|
public void removeTablePropCache(Long widgetId) {
|
|
- // cacheService.evict(SystemConstant.TABLE_PROP_CACHE, String.valueOf(widgetId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.TABLE_PROP_CACHE, String.valueOf(widgetId));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -620,7 +620,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public MenuResult updateUserMenuCache(Long userId) {
|
|
public MenuResult updateUserMenuCache(Long userId) {
|
|
- // cacheService.evict(SystemConstant.USER_MENU_CACHE, String.valueOf(userId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.USER_MENU_CACHE, String.valueOf(userId));
|
|
return userMenuCommon(userId);
|
|
return userMenuCommon(userId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -631,7 +631,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removeUserMenuCache(Long userId) {
|
|
public void removeUserMenuCache(Long userId) {
|
|
- // cacheService.evict(SystemConstant.USER_MENU_CACHE, String.valueOf(userId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.USER_MENU_CACHE, String.valueOf(userId));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -653,7 +653,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public SysRole updateRoleCache(Long roleId) {
|
|
public SysRole updateRoleCache(Long roleId) {
|
|
- // cacheService.evict(SystemConstant.ROLE_CACHE, String.valueOf(roleId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.ROLE_CACHE, String.valueOf(roleId));
|
|
return roleCacheCommon(roleId);
|
|
return roleCacheCommon(roleId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -664,7 +664,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removeRoleCache(Long roleId) {
|
|
public void removeRoleCache(Long roleId) {
|
|
- // cacheService.evict(SystemConstant.ROLE_CACHE, String.valueOf(roleId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.ROLE_CACHE, String.valueOf(roleId));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -697,7 +697,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public BasicSchool updateSchoolCache(Long schoolId) {
|
|
public BasicSchool updateSchoolCache(Long schoolId) {
|
|
- // cacheService.evict(SystemConstant.SCHOOL_CACHE, String.valueOf(schoolId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.SCHOOL_CACHE, String.valueOf(schoolId));
|
|
return schoolCacheCommon(schoolId);
|
|
return schoolCacheCommon(schoolId);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -709,7 +709,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public BasicSchool updateSchoolCache(String code) {
|
|
public BasicSchool updateSchoolCache(String code) {
|
|
- // cacheService.evict(SystemConstant.SCHOOL_CODE_CACHE, code);
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.SCHOOL_CODE_CACHE, code);
|
|
return schoolCacheCommon(code);
|
|
return schoolCacheCommon(code);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -720,7 +720,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removeSchoolCache(Long schoolId) {
|
|
public void removeSchoolCache(Long schoolId) {
|
|
- // cacheService.evict(SystemConstant.SCHOOL_CACHE, String.valueOf(schoolId));
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.SCHOOL_CACHE, String.valueOf(schoolId));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -730,7 +730,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removeSchoolCache(String code) {
|
|
public void removeSchoolCache(String code) {
|
|
- // cacheService.evict(SystemConstant.SCHOOL_CODE_CACHE, code);
|
|
|
|
|
|
+ cacheService.evict(SystemConstant.SCHOOL_CODE_CACHE, code);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -738,7 +738,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removeSchoolIdCache() {
|
|
public void removeSchoolIdCache() {
|
|
- // cacheService.clear(SystemConstant.SCHOOL_CACHE);
|
|
|
|
|
|
+ cacheService.clear(SystemConstant.SCHOOL_CACHE);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -746,7 +746,7 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void removeSchoolCodeCache() {
|
|
public void removeSchoolCodeCache() {
|
|
- // cacheService.clear(SystemConstant.SCHOOL_CODE_CACHE);
|
|
|
|
|
|
+ cacheService.clear(SystemConstant.SCHOOL_CODE_CACHE);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -756,14 +756,14 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
protected BasicSchool schoolCacheCommon(Long schoolId) {
|
|
protected BasicSchool schoolCacheCommon(Long schoolId) {
|
|
- // BasicSchool basicSchool = (BasicSchool) cacheService.get(SystemConstant.SCHOOL_CACHE, String.valueOf(schoolId));
|
|
|
|
- // if (Objects.isNull(basicSchool)) {
|
|
|
|
- // basicSchool = basicSchoolService.getById(schoolId);
|
|
|
|
- // if (Objects.nonNull(basicSchool)) {
|
|
|
|
- // cacheService.put(SystemConstant.SCHOOL_CACHE, String.valueOf(schoolId), basicSchool);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- return basicSchoolService.getById(schoolId);
|
|
|
|
|
|
+ BasicSchool basicSchool = (BasicSchool) cacheService.get(SystemConstant.SCHOOL_CACHE, String.valueOf(schoolId));
|
|
|
|
+ if (Objects.isNull(basicSchool)) {
|
|
|
|
+ basicSchool = basicSchoolService.getById(schoolId);
|
|
|
|
+ if (Objects.nonNull(basicSchool)) {
|
|
|
|
+ cacheService.put(SystemConstant.SCHOOL_CACHE, String.valueOf(schoolId), basicSchool);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return basicSchool;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -773,15 +773,15 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
protected BasicSchool schoolCacheCommon(String code) {
|
|
protected BasicSchool schoolCacheCommon(String code) {
|
|
- // BasicSchool basicSchool = (BasicSchool) cacheService.get(SystemConstant.SCHOOL_CODE_CACHE, code);
|
|
|
|
- // if (Objects.isNull(basicSchool)) {
|
|
|
|
- // basicSchool = basicSchoolService.getOne(
|
|
|
|
- // new QueryWrapper<BasicSchool>().lambda().eq(BasicSchool::getCode, code));
|
|
|
|
- // if (Objects.nonNull(basicSchool)) {
|
|
|
|
- // cacheService.put(SystemConstant.SCHOOL_CODE_CACHE, code, basicSchool);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- return basicSchoolService.getOne(new QueryWrapper<BasicSchool>().lambda().eq(BasicSchool::getCode, code));
|
|
|
|
|
|
+ BasicSchool basicSchool = (BasicSchool) cacheService.get(SystemConstant.SCHOOL_CODE_CACHE, code);
|
|
|
|
+ if (Objects.isNull(basicSchool)) {
|
|
|
|
+ basicSchool = basicSchoolService.getOne(
|
|
|
|
+ new QueryWrapper<BasicSchool>().lambda().eq(BasicSchool::getCode, code));
|
|
|
|
+ if (Objects.nonNull(basicSchool)) {
|
|
|
|
+ cacheService.put(SystemConstant.SCHOOL_CODE_CACHE, code, basicSchool);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return basicSchool;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -791,14 +791,14 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
protected SysRole roleCacheCommon(Long roleId) {
|
|
protected SysRole roleCacheCommon(Long roleId) {
|
|
- // SysRole sysRole = (SysRole) cacheService.get(SystemConstant.ROLE_CACHE, String.valueOf(roleId));
|
|
|
|
- // if (Objects.isNull(sysRole)) {
|
|
|
|
- // sysRole = sysRoleService.getById(roleId);
|
|
|
|
- // if (Objects.nonNull(sysRole)) {
|
|
|
|
- // cacheService.put(SystemConstant.ROLE_CACHE, String.valueOf(roleId), sysRole);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- return sysRoleService.getById(roleId);
|
|
|
|
|
|
+ SysRole sysRole = (SysRole) cacheService.get(SystemConstant.ROLE_CACHE, String.valueOf(roleId));
|
|
|
|
+ if (Objects.isNull(sysRole)) {
|
|
|
|
+ sysRole = sysRoleService.getById(roleId);
|
|
|
|
+ if (Objects.nonNull(sysRole)) {
|
|
|
|
+ cacheService.put(SystemConstant.ROLE_CACHE, String.valueOf(roleId), sysRole);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return sysRole;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -808,76 +808,77 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
protected MenuResult userMenuCommon(Long userId) {
|
|
protected MenuResult userMenuCommon(Long userId) {
|
|
- // MenuResult menuResult = (MenuResult) cacheService.get(SystemConstant.USER_MENU_CACHE, String.valueOf(userId));
|
|
|
|
- // if (Objects.isNull(menuResult)) {
|
|
|
|
- List<SysUserRole> sysUserRoleList = this.userRolePrivilegeCache(userId);
|
|
|
|
- List<SysRolePrivilege> sysRolePrivilegeList = new ArrayList<>();
|
|
|
|
- for (SysUserRole s : sysUserRoleList) {
|
|
|
|
- SysRole sysRole = this.roleCache(s.getRoleId());
|
|
|
|
- if (Objects.nonNull(sysRole) && sysRole.getEnable()) {
|
|
|
|
- sysRolePrivilegeList.addAll(this.rolePrivilegeCache(s.getRoleId()));
|
|
|
|
|
|
+ MenuResult menuResult = (MenuResult) cacheService.get(SystemConstant.USER_MENU_CACHE, String.valueOf(userId));
|
|
|
|
+ if (Objects.isNull(menuResult)) {
|
|
|
|
+ List<SysUserRole> sysUserRoleList = this.userRolePrivilegeCache(userId);
|
|
|
|
+ List<SysRolePrivilege> sysRolePrivilegeList = new ArrayList<>();
|
|
|
|
+ for (SysUserRole s : sysUserRoleList) {
|
|
|
|
+ SysRole sysRole = this.roleCache(s.getRoleId());
|
|
|
|
+ if (Objects.nonNull(sysRole) && sysRole.getEnable()) {
|
|
|
|
+ sysRolePrivilegeList.addAll(this.rolePrivilegeCache(s.getRoleId()));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- Set<Long> privilegeIds = sysRolePrivilegeList.stream().map(s -> s.getPrivilegeId()).collect(Collectors.toSet());
|
|
|
|
- QueryWrapper<SysPrivilege> sysPrivilegeQueryWrapper = new QueryWrapper<>();
|
|
|
|
- sysPrivilegeQueryWrapper.lambda().eq(SysPrivilege::getEnable, true).eq(SysPrivilege::getFrontDisplay, true)
|
|
|
|
- .orderByAsc(SysPrivilege::getSequence);
|
|
|
|
-
|
|
|
|
- if (!privilegeIds.isEmpty()) {
|
|
|
|
- sysPrivilegeQueryWrapper.lambda().in(SysPrivilege::getId, privilegeIds);
|
|
|
|
- }
|
|
|
|
- List<SysPrivilege> sysPrivilegeList = sysPrivilegeService.list(sysPrivilegeQueryWrapper);
|
|
|
|
- List<MenuDto> menuDtoList = GsonUtil.fromJson(JacksonUtil.parseJson(sysPrivilegeList),
|
|
|
|
- new TypeToken<List<MenuDto>>() {
|
|
|
|
-
|
|
|
|
- }.getType());
|
|
|
|
- LinkedMultiValueMap<Long, MenuDto> linkedMultiValueMap = new LinkedMultiValueMap<>();
|
|
|
|
- List<MenuPrivilegeDto> menuPrivilegeDtoList = new ArrayList<>();
|
|
|
|
- for (MenuDto m : menuDtoList) {
|
|
|
|
- if (Objects.isNull(m.getParentId()) || m.getType() == PrivilegeEnum.MENU) {
|
|
|
|
- menuPrivilegeDtoList.add(GsonUtil.fromJson(GsonUtil.toJson(m), MenuPrivilegeDto.class));
|
|
|
|
- } else {
|
|
|
|
- if (!linkedMultiValueMap.containsKey(m.getParentId())) {
|
|
|
|
- linkedMultiValueMap.add(m.getParentId(), m);
|
|
|
|
|
|
+ Set<Long> privilegeIds = sysRolePrivilegeList.stream().map(s -> s.getPrivilegeId())
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
+ QueryWrapper<SysPrivilege> sysPrivilegeQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ sysPrivilegeQueryWrapper.lambda().eq(SysPrivilege::getEnable, true).eq(SysPrivilege::getFrontDisplay, true)
|
|
|
|
+ .orderByAsc(SysPrivilege::getSequence);
|
|
|
|
+
|
|
|
|
+ if (!privilegeIds.isEmpty()) {
|
|
|
|
+ sysPrivilegeQueryWrapper.lambda().in(SysPrivilege::getId, privilegeIds);
|
|
|
|
+ }
|
|
|
|
+ List<SysPrivilege> sysPrivilegeList = sysPrivilegeService.list(sysPrivilegeQueryWrapper);
|
|
|
|
+ List<MenuDto> menuDtoList = GsonUtil.fromJson(JacksonUtil.parseJson(sysPrivilegeList),
|
|
|
|
+ new TypeToken<List<MenuDto>>() {
|
|
|
|
+
|
|
|
|
+ }.getType());
|
|
|
|
+ LinkedMultiValueMap<Long, MenuDto> linkedMultiValueMap = new LinkedMultiValueMap<>();
|
|
|
|
+ List<MenuPrivilegeDto> menuPrivilegeDtoList = new ArrayList<>();
|
|
|
|
+ for (MenuDto m : menuDtoList) {
|
|
|
|
+ if (Objects.isNull(m.getParentId()) || m.getType() == PrivilegeEnum.MENU) {
|
|
|
|
+ menuPrivilegeDtoList.add(GsonUtil.fromJson(GsonUtil.toJson(m), MenuPrivilegeDto.class));
|
|
} else {
|
|
} else {
|
|
- List<MenuDto> menuDtos = linkedMultiValueMap.get(m.getParentId());
|
|
|
|
- menuDtos.add(m);
|
|
|
|
- linkedMultiValueMap.put(m.getParentId(), menuDtos);
|
|
|
|
|
|
+ if (!linkedMultiValueMap.containsKey(m.getParentId())) {
|
|
|
|
+ linkedMultiValueMap.add(m.getParentId(), m);
|
|
|
|
+ } else {
|
|
|
|
+ List<MenuDto> menuDtos = linkedMultiValueMap.get(m.getParentId());
|
|
|
|
+ menuDtos.add(m);
|
|
|
|
+ linkedMultiValueMap.put(m.getParentId(), menuDtos);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }
|
|
|
|
- for (MenuPrivilegeDto m : menuPrivilegeDtoList) {
|
|
|
|
- List<MenuDto> menuDtos = linkedMultiValueMap.get(m.getId());
|
|
|
|
- List<MenuDto> urls = null, buttons = null, links = null, lists = null, conditions = null;
|
|
|
|
- if (Objects.nonNull(menuDtos)) {
|
|
|
|
- for (MenuDto menuDto : menuDtos) {
|
|
|
|
- if (menuDto.getType() == PrivilegeEnum.BUTTON) {
|
|
|
|
- buttons = Objects.isNull(buttons) ? new ArrayList<>() : buttons;
|
|
|
|
- buttons.add(GsonUtil.fromJson(GsonUtil.toJson(menuDto), MenuPrivilegeDto.class));
|
|
|
|
- m.setButtons(buttons);
|
|
|
|
- } else if (menuDto.getType() == PrivilegeEnum.LINK) {
|
|
|
|
- links = Objects.isNull(links) ? new ArrayList<>() : links;
|
|
|
|
- links.add(GsonUtil.fromJson(GsonUtil.toJson(menuDto), MenuPrivilegeDto.class));
|
|
|
|
- m.setLinks(links);
|
|
|
|
- } else if (menuDto.getType() == PrivilegeEnum.URL) {
|
|
|
|
- urls = Objects.isNull(urls) ? new ArrayList<>() : urls;
|
|
|
|
- urls.add(GsonUtil.fromJson(GsonUtil.toJson(menuDto), MenuPrivilegeDto.class));
|
|
|
|
- m.setUrls(urls);
|
|
|
|
- } else if (menuDto.getType() == PrivilegeEnum.LIST) {
|
|
|
|
- lists = Objects.isNull(lists) ? new ArrayList<>() : lists;
|
|
|
|
- lists.add(GsonUtil.fromJson(GsonUtil.toJson(menuDto), MenuPrivilegeDto.class));
|
|
|
|
- m.setLists(lists);
|
|
|
|
- } else if (menuDto.getType() == PrivilegeEnum.CONDITION) {
|
|
|
|
- conditions = Objects.isNull(conditions) ? new ArrayList<>() : conditions;
|
|
|
|
- conditions.add(GsonUtil.fromJson(GsonUtil.toJson(menuDto), MenuPrivilegeDto.class));
|
|
|
|
- m.setConditions(conditions);
|
|
|
|
|
|
+ for (MenuPrivilegeDto m : menuPrivilegeDtoList) {
|
|
|
|
+ List<MenuDto> menuDtos = linkedMultiValueMap.get(m.getId());
|
|
|
|
+ List<MenuDto> urls = null, buttons = null, links = null, lists = null, conditions = null;
|
|
|
|
+ if (Objects.nonNull(menuDtos)) {
|
|
|
|
+ for (MenuDto menuDto : menuDtos) {
|
|
|
|
+ if (menuDto.getType() == PrivilegeEnum.BUTTON) {
|
|
|
|
+ buttons = Objects.isNull(buttons) ? new ArrayList<>() : buttons;
|
|
|
|
+ buttons.add(GsonUtil.fromJson(GsonUtil.toJson(menuDto), MenuPrivilegeDto.class));
|
|
|
|
+ m.setButtons(buttons);
|
|
|
|
+ } else if (menuDto.getType() == PrivilegeEnum.LINK) {
|
|
|
|
+ links = Objects.isNull(links) ? new ArrayList<>() : links;
|
|
|
|
+ links.add(GsonUtil.fromJson(GsonUtil.toJson(menuDto), MenuPrivilegeDto.class));
|
|
|
|
+ m.setLinks(links);
|
|
|
|
+ } else if (menuDto.getType() == PrivilegeEnum.URL) {
|
|
|
|
+ urls = Objects.isNull(urls) ? new ArrayList<>() : urls;
|
|
|
|
+ urls.add(GsonUtil.fromJson(GsonUtil.toJson(menuDto), MenuPrivilegeDto.class));
|
|
|
|
+ m.setUrls(urls);
|
|
|
|
+ } else if (menuDto.getType() == PrivilegeEnum.LIST) {
|
|
|
|
+ lists = Objects.isNull(lists) ? new ArrayList<>() : lists;
|
|
|
|
+ lists.add(GsonUtil.fromJson(GsonUtil.toJson(menuDto), MenuPrivilegeDto.class));
|
|
|
|
+ m.setLists(lists);
|
|
|
|
+ } else if (menuDto.getType() == PrivilegeEnum.CONDITION) {
|
|
|
|
+ conditions = Objects.isNull(conditions) ? new ArrayList<>() : conditions;
|
|
|
|
+ conditions.add(GsonUtil.fromJson(GsonUtil.toJson(menuDto), MenuPrivilegeDto.class));
|
|
|
|
+ m.setConditions(conditions);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ menuResult = new MenuResult(userId, menuPrivilegeDtoList);
|
|
|
|
+ cacheService.put(SystemConstant.USER_MENU_CACHE, String.valueOf(userId), menuResult);
|
|
}
|
|
}
|
|
- MenuResult menuResult = new MenuResult(userId, menuPrivilegeDtoList);
|
|
|
|
- // cacheService.put(SystemConstant.USER_MENU_CACHE, String.valueOf(userId), menuResult);
|
|
|
|
- // }
|
|
|
|
return menuResult;
|
|
return menuResult;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -887,16 +888,16 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
protected List<TDTableProp> tablePropCacheCommon(Long widgetId) {
|
|
protected List<TDTableProp> tablePropCacheCommon(Long widgetId) {
|
|
- // List<TDTableProp> tablePropList = (List<TDTableProp>) cacheService.get(SystemConstant.TABLE_PROP_CACHE,
|
|
|
|
- // String.valueOf(widgetId));
|
|
|
|
- // if (CollectionUtils.isEmpty(tablePropList)) {
|
|
|
|
- // tablePropList = tdTablePropService.list(
|
|
|
|
- // new QueryWrapper<TDTableProp>().lambda().eq(TDTableProp::getWidgetId, widgetId));
|
|
|
|
- // if (!CollectionUtils.isEmpty(tablePropList)) {
|
|
|
|
- // cacheService.put(SystemConstant.TABLE_PROP_CACHE, String.valueOf(widgetId), tablePropList);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- return tdTablePropService.list(new QueryWrapper<TDTableProp>().lambda().eq(TDTableProp::getWidgetId, widgetId));
|
|
|
|
|
|
+ List<TDTableProp> tablePropList = (List<TDTableProp>) cacheService.get(SystemConstant.TABLE_PROP_CACHE,
|
|
|
|
+ String.valueOf(widgetId));
|
|
|
|
+ if (CollectionUtils.isEmpty(tablePropList)) {
|
|
|
|
+ tablePropList = tdTablePropService.list(
|
|
|
|
+ new QueryWrapper<TDTableProp>().lambda().eq(TDTableProp::getWidgetId, widgetId));
|
|
|
|
+ if (!CollectionUtils.isEmpty(tablePropList)) {
|
|
|
|
+ cacheService.put(SystemConstant.TABLE_PROP_CACHE, String.valueOf(widgetId), tablePropList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return tablePropList;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -906,15 +907,15 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
protected TDFormWidget formWidgetCacheCommon(Long id) {
|
|
protected TDFormWidget formWidgetCacheCommon(Long id) {
|
|
- // TDFormWidget tdFormWidget = (TDFormWidget) cacheService.get(SystemConstant.FORM_WIDGET_CACHE,
|
|
|
|
- // String.valueOf(id));
|
|
|
|
- // if (Objects.isNull(tdFormWidget)) {
|
|
|
|
- // tdFormWidget = tdFormWidgetService.getById(id);
|
|
|
|
- // if (Objects.nonNull(tdFormWidget)) {
|
|
|
|
- // cacheService.put(SystemConstant.FORM_WIDGET_CACHE, String.valueOf(id), tdFormWidget);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- return tdFormWidgetService.getById(id);
|
|
|
|
|
|
+ TDFormWidget tdFormWidget = (TDFormWidget) cacheService.get(SystemConstant.FORM_WIDGET_CACHE,
|
|
|
|
+ String.valueOf(id));
|
|
|
|
+ if (Objects.isNull(tdFormWidget)) {
|
|
|
|
+ tdFormWidget = tdFormWidgetService.getById(id);
|
|
|
|
+ if (Objects.nonNull(tdFormWidget)) {
|
|
|
|
+ cacheService.put(SystemConstant.FORM_WIDGET_CACHE, String.valueOf(id), tdFormWidget);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return tdFormWidget;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -923,9 +924,8 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
protected List<FormWidgetResult> formWidgetCacheCommon() {
|
|
protected List<FormWidgetResult> formWidgetCacheCommon() {
|
|
- // List<FormWidgetResult> formWidgetResultList = (List<FormWidgetResult>) cacheService.get(
|
|
|
|
- // SystemConstant.FORM_WIDGET_CACHE, SystemConstant.FORM_WIDGET_CACHE);
|
|
|
|
- List<FormWidgetResult> formWidgetResultList = null;
|
|
|
|
|
|
+ List<FormWidgetResult> formWidgetResultList = (List<FormWidgetResult>) cacheService.get(
|
|
|
|
+ SystemConstant.FORM_WIDGET_CACHE, SystemConstant.FORM_WIDGET_CACHE);
|
|
if (CollectionUtils.isEmpty(formWidgetResultList)) {
|
|
if (CollectionUtils.isEmpty(formWidgetResultList)) {
|
|
List<TDFormWidget> tdFormWidgetList = tdFormWidgetService.list(
|
|
List<TDFormWidget> tdFormWidgetList = tdFormWidgetService.list(
|
|
new QueryWrapper<TDFormWidget>().select(" DISTINCT code "));
|
|
new QueryWrapper<TDFormWidget>().select(" DISTINCT code "));
|
|
@@ -934,8 +934,8 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
new TypeToken<List<FormWidgetResult>>() {
|
|
new TypeToken<List<FormWidgetResult>>() {
|
|
|
|
|
|
}.getType());
|
|
}.getType());
|
|
- // cacheService.put(SystemConstant.FORM_WIDGET_CACHE, SystemConstant.FORM_WIDGET_CACHE,
|
|
|
|
- // formWidgetResultList);
|
|
|
|
|
|
+ cacheService.put(SystemConstant.FORM_WIDGET_CACHE, SystemConstant.FORM_WIDGET_CACHE,
|
|
|
|
+ formWidgetResultList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return formWidgetResultList;
|
|
return formWidgetResultList;
|
|
@@ -948,16 +948,15 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
protected Set<String> privilegeUrlCacheCommon(PrivilegePropertyEnum privilegePropertyEnum) {
|
|
protected Set<String> privilegeUrlCacheCommon(PrivilegePropertyEnum privilegePropertyEnum) {
|
|
- // Set<String> privilegeUrlSet = (Set<String>) cacheService.get(SystemConstant.PRIVILEGE_URL_CACHE,
|
|
|
|
- // privilegePropertyEnum.name());
|
|
|
|
- Set<String> privilegeUrlSet = null;
|
|
|
|
|
|
+ Set<String> privilegeUrlSet = (Set<String>) cacheService.get(SystemConstant.PRIVILEGE_URL_CACHE,
|
|
|
|
+ privilegePropertyEnum.name());
|
|
if (CollectionUtils.isEmpty(privilegeUrlSet)) {
|
|
if (CollectionUtils.isEmpty(privilegeUrlSet)) {
|
|
List<SysPrivilege> sysPrivilegeList = sysPrivilegeService.list(
|
|
List<SysPrivilege> sysPrivilegeList = sysPrivilegeService.list(
|
|
new QueryWrapper<SysPrivilege>().lambda().eq(SysPrivilege::getType, PrivilegeEnum.URL)
|
|
new QueryWrapper<SysPrivilege>().lambda().eq(SysPrivilege::getType, PrivilegeEnum.URL)
|
|
.eq(SysPrivilege::getProperty, privilegePropertyEnum).eq(SysPrivilege::getEnable, true));
|
|
.eq(SysPrivilege::getProperty, privilegePropertyEnum).eq(SysPrivilege::getEnable, true));
|
|
if (!CollectionUtils.isEmpty(sysPrivilegeList)) {
|
|
if (!CollectionUtils.isEmpty(sysPrivilegeList)) {
|
|
privilegeUrlSet = sysPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toSet());
|
|
privilegeUrlSet = sysPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toSet());
|
|
- // cacheService.put(SystemConstant.PRIVILEGE_URL_CACHE, privilegePropertyEnum.name(), privilegeUrlSet);
|
|
|
|
|
|
+ cacheService.put(SystemConstant.PRIVILEGE_URL_CACHE, privilegePropertyEnum.name(), privilegeUrlSet);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return privilegeUrlSet;
|
|
return privilegeUrlSet;
|
|
@@ -970,14 +969,14 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
protected SysOrg orgCacheCommon(Long orgId) {
|
|
protected SysOrg orgCacheCommon(Long orgId) {
|
|
- // SysOrg sysOrg = (SysOrg) cacheService.get(SystemConstant.ORG_CACHE, String.valueOf(orgId));
|
|
|
|
- // if (Objects.isNull(sysOrg)) {
|
|
|
|
- // sysOrg = sysOrgService.getById(orgId);
|
|
|
|
- // if (Objects.nonNull(sysOrg)) {
|
|
|
|
- // cacheService.put(SystemConstant.ORG_CACHE, String.valueOf(orgId), sysOrg);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- return sysOrgService.getById(orgId);
|
|
|
|
|
|
+ SysOrg sysOrg = (SysOrg) cacheService.get(SystemConstant.ORG_CACHE, String.valueOf(orgId));
|
|
|
|
+ if (Objects.isNull(sysOrg)) {
|
|
|
|
+ sysOrg = sysOrgService.getById(orgId);
|
|
|
|
+ if (Objects.nonNull(sysOrg)) {
|
|
|
|
+ cacheService.put(SystemConstant.ORG_CACHE, String.valueOf(orgId), sysOrg);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return sysOrg;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -987,16 +986,15 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
protected List<SysUserRole> userRoleCacheCommon(Long userId) {
|
|
protected List<SysUserRole> userRoleCacheCommon(Long userId) {
|
|
- // List<SysUserRole> sysUserRoleList = (List<SysUserRole>) cacheService.get(
|
|
|
|
- // SystemConstant.USER_ROLE_PRIVILEGE_CACHE, String.valueOf(userId));
|
|
|
|
- List<SysUserRole> sysUserRoleList = null;
|
|
|
|
|
|
+ List<SysUserRole> sysUserRoleList = (List<SysUserRole>) cacheService.get(
|
|
|
|
+ SystemConstant.USER_ROLE_PRIVILEGE_CACHE, String.valueOf(userId));
|
|
if (CollectionUtils.isEmpty(sysUserRoleList)) {
|
|
if (CollectionUtils.isEmpty(sysUserRoleList)) {
|
|
sysUserRoleList = sysUserRoleService.list(
|
|
sysUserRoleList = sysUserRoleService.list(
|
|
new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, userId)
|
|
new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, userId)
|
|
.eq(SysUserRole::getEnable, true));
|
|
.eq(SysUserRole::getEnable, true));
|
|
- // if (!CollectionUtils.isEmpty(sysUserRoleList)) {
|
|
|
|
- // cacheService.put(SystemConstant.USER_ROLE_PRIVILEGE_CACHE, String.valueOf(userId), sysUserRoleList);
|
|
|
|
- // }
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(sysUserRoleList)) {
|
|
|
|
+ cacheService.put(SystemConstant.USER_ROLE_PRIVILEGE_CACHE, String.valueOf(userId), sysUserRoleList);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return sysUserRoleList;
|
|
return sysUserRoleList;
|
|
}
|
|
}
|
|
@@ -1008,15 +1006,14 @@ public class CommonCacheServiceImpl implements CommonCacheService {
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
protected List<SysRolePrivilege> rolePrivilegeCacheCommon(Long roleId) {
|
|
protected List<SysRolePrivilege> rolePrivilegeCacheCommon(Long roleId) {
|
|
- // List<SysRolePrivilege> sysRolePrivilegeList = (List<SysRolePrivilege>) cacheService.get(
|
|
|
|
- // SystemConstant.ROLE_PRIVILEGE_CACHE, String.valueOf(roleId));
|
|
|
|
- List<SysRolePrivilege> sysRolePrivilegeList = null;
|
|
|
|
|
|
+ List<SysRolePrivilege> sysRolePrivilegeList = (List<SysRolePrivilege>) cacheService.get(
|
|
|
|
+ SystemConstant.ROLE_PRIVILEGE_CACHE, String.valueOf(roleId));
|
|
if (CollectionUtils.isEmpty(sysRolePrivilegeList)) {
|
|
if (CollectionUtils.isEmpty(sysRolePrivilegeList)) {
|
|
sysRolePrivilegeList = sysRolePrivilegeService.list(
|
|
sysRolePrivilegeList = sysRolePrivilegeService.list(
|
|
new QueryWrapper<SysRolePrivilege>().lambda().eq(SysRolePrivilege::getRoleId, roleId));
|
|
new QueryWrapper<SysRolePrivilege>().lambda().eq(SysRolePrivilege::getRoleId, roleId));
|
|
- // if (!CollectionUtils.isEmpty(sysRolePrivilegeList)) {
|
|
|
|
- // cacheService.put(SystemConstant.ROLE_PRIVILEGE_CACHE, String.valueOf(roleId), sysRolePrivilegeList);
|
|
|
|
- // }
|
|
|
|
|
|
+ if (!CollectionUtils.isEmpty(sysRolePrivilegeList)) {
|
|
|
|
+ cacheService.put(SystemConstant.ROLE_PRIVILEGE_CACHE, String.valueOf(roleId), sysRolePrivilegeList);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
return sysRolePrivilegeList;
|
|
return sysRolePrivilegeList;
|
|
}
|
|
}
|