|
@@ -8,8 +8,6 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.google.common.reflect.TypeToken;
|
|
|
import com.google.gson.Gson;
|
|
|
import com.qmth.boot.core.enums.Platform;
|
|
|
-import com.qmth.boot.tools.signature.SignatureType;
|
|
|
-import com.qmth.teachcloud.common.SignatureEntityTest;
|
|
|
import com.qmth.teachcloud.common.bean.auth.AuthBean;
|
|
|
import com.qmth.teachcloud.common.bean.auth.ExpireTimeBean;
|
|
|
import com.qmth.teachcloud.common.bean.dto.MenuDto;
|
|
@@ -54,7 +52,7 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
private final static Logger log = LoggerFactory.getLogger(TeachcloudCommonServiceImpl.class);
|
|
|
|
|
|
@Resource
|
|
|
- CacheService cacheService;
|
|
|
+ CommonCacheService commonCacheService;
|
|
|
|
|
|
@Resource
|
|
|
SysUserRoleService sysUserRoleService;
|
|
@@ -97,11 +95,11 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
*/
|
|
|
@Override
|
|
|
public MenuResult getUserMenu(Long userId) {
|
|
|
- SysUser sysUser = cacheService.userCache(userId);
|
|
|
- List<SysUserRole> sysUserRoleList = cacheService.userRolePrivilegeCache(userId);
|
|
|
+ SysUser sysUser = commonCacheService.userCache(userId);
|
|
|
+ List<SysUserRole> sysUserRoleList = commonCacheService.userRolePrivilegeCache(userId);
|
|
|
List<SysRolePrivilege> sysRolePrivilegeList = new ArrayList<>();
|
|
|
for (SysUserRole s : sysUserRoleList) {
|
|
|
- sysRolePrivilegeList.addAll(cacheService.rolePrivilegeCache(s.getRoleId()));
|
|
|
+ sysRolePrivilegeList.addAll(commonCacheService.rolePrivilegeCache(s.getRoleId()));
|
|
|
}
|
|
|
Set<Long> privilegeIds = sysRolePrivilegeList.stream().map(s -> s.getPrivilegeId()).collect(Collectors.toSet());
|
|
|
QueryWrapper<SysPrivilege> sysPrivilegeQueryWrapper = new QueryWrapper<>();
|
|
@@ -165,7 +163,7 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
*/
|
|
|
@Override
|
|
|
public void addUserRolePrivilege(SysUser sysUser, Long roleId) {
|
|
|
- List<SysRolePrivilege> sysRolePrivilegeList = cacheService.rolePrivilegeCache(roleId);
|
|
|
+ List<SysRolePrivilege> sysRolePrivilegeList = commonCacheService.rolePrivilegeCache(roleId);
|
|
|
List<SysUserRole> sysUserRoleList = new ArrayList<>();
|
|
|
sysRolePrivilegeList.forEach(s -> {
|
|
|
sysUserRoleList.add(new SysUserRole(sysUser.getId(), s.getRoleId(), s.getPrivilegeId()));
|
|
@@ -235,18 +233,18 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
public AuthBean getUserAuth(Long userId) {
|
|
|
AuthBean authBean = null;
|
|
|
try {
|
|
|
- CacheService cacheService = SpringContextHolder.getBean(CacheService.class);
|
|
|
- SysUser user = cacheService.userCache(userId);
|
|
|
+ CommonCacheService commonCacheService = SpringContextHolder.getBean(CommonCacheService.class);
|
|
|
+ SysUser user = commonCacheService.userCache(userId);
|
|
|
if (Objects.isNull(user)) {
|
|
|
throw ExceptionResultEnum.USER_NO_DATA.exception();
|
|
|
}
|
|
|
//查询用户角色和权限
|
|
|
- List<SysUserRole> sysUserRoleList = cacheService.userRolePrivilegeCache(user.getId());
|
|
|
+ List<SysUserRole> sysUserRoleList = commonCacheService.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(cacheService.rolePrivilegeCache(l));
|
|
|
+ sysRolePrivilegeList.addAll(commonCacheService.rolePrivilegeCache(l));
|
|
|
}
|
|
|
Set<Long> privilegeIds = sysRolePrivilegeList.stream().map(s -> s.getPrivilegeId()).collect(Collectors.toSet());
|
|
|
QueryWrapper<SysRole> sysRoleQueryWrapper = new QueryWrapper<>();
|
|
@@ -264,8 +262,8 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
List<SysPrivilege> sysPrivilegeList = sysPrivilegeService.list(sysPrivilegeQueryWrapper);
|
|
|
authBean = new AuthBean(sysRoleList, sysPrivilegeList.stream().map(s -> s.getUrl()).collect(Collectors.toSet()));
|
|
|
} else {
|
|
|
- BasicSchool tbSchool = Objects.nonNull(user.getSchoolId()) ? cacheService.schoolCache(user.getSchoolId()) : null;
|
|
|
- SysOrg org = Objects.nonNull(user.getOrgId()) ? cacheService.orgCache(user.getOrgId()) : null;
|
|
|
+ BasicSchool tbSchool = Objects.nonNull(user.getSchoolId()) ? commonCacheService.schoolCache(user.getSchoolId()) : null;
|
|
|
+ SysOrg org = Objects.nonNull(user.getOrgId()) ? commonCacheService.orgCache(user.getOrgId()) : null;
|
|
|
sysPrivilegeQueryWrapper.lambda().in(SysPrivilege::getId, privilegeIds)
|
|
|
.eq(SysPrivilege::getSchoolId, user.getSchoolId())
|
|
|
.eq(SysPrivilege::getType, PrivilegeEnum.URL)
|
|
@@ -305,7 +303,7 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
*/
|
|
|
@Override
|
|
|
public void removeUserInfo(Long userId, boolean all) throws NoSuchAlgorithmException {
|
|
|
- AuthBean authBean = cacheService.userAuthCache(userId);
|
|
|
+ AuthBean authBean = commonCacheService.userAuthCache(userId);
|
|
|
if (Objects.isNull(authBean)) {
|
|
|
throw ExceptionResultEnum.NOT_LOGIN.exception();
|
|
|
}
|
|
@@ -321,10 +319,10 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
tbSessionService.removeById(tbSession.getId());
|
|
|
redisUtil.deleteUserSession(tbSession.getId());
|
|
|
}
|
|
|
- cacheService.removeUserCache(userId);
|
|
|
- cacheService.removeUserAuthCache(userId);
|
|
|
- cacheService.removeUserMenuCache(userId);
|
|
|
- cacheService.removeUserRolePrivilegeCache(userId);
|
|
|
+ commonCacheService.removeUserCache(userId);
|
|
|
+ commonCacheService.removeUserAuthCache(userId);
|
|
|
+ commonCacheService.removeUserMenuCache(userId);
|
|
|
+ commonCacheService.removeUserRolePrivilegeCache(userId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -366,7 +364,7 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
//如果数据库的状态和修改的状态不同
|
|
|
if (Objects.nonNull(dbRole.getEnable()) && dbRole.getEnable().booleanValue() != enable.booleanValue()) {
|
|
|
//更新角色权限
|
|
|
- cacheService.updateRolePrivilegeCache(dbRole.getId());
|
|
|
+ commonCacheService.updateRolePrivilegeCache(dbRole.getId());
|
|
|
updateRoleIds.add(dbRole.getId());
|
|
|
}
|
|
|
}
|
|
@@ -376,8 +374,8 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
List<SysUserRole> sysUserRoleList = sysUserRoleService.list(sysUserRoleQueryWrapper);
|
|
|
Set<Long> userIds = sysUserRoleList.stream().map(s -> s.getUserId()).collect(Collectors.toSet());
|
|
|
for (Long l : userIds) {
|
|
|
- cacheService.updateUserRolePrivilegeCache(l);
|
|
|
- cacheService.updateUserAuthCache(l);
|
|
|
+ commonCacheService.updateUserRolePrivilegeCache(l);
|
|
|
+ commonCacheService.updateUserAuthCache(l);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -744,7 +742,7 @@ public class TeachcloudCommonServiceImpl implements TeachcloudCommonService {
|
|
|
}
|
|
|
//生成token
|
|
|
String token = SystemConstant.getUuid();
|
|
|
- cacheService.userCache(sysUser.getId());
|
|
|
+ commonCacheService.userCache(sysUser.getId());
|
|
|
//添加用户会话缓存
|
|
|
Set<String> roleNames = new HashSet<>(), roleTypes = new HashSet<>();
|
|
|
for (SysRole s : authBean.getRoleList()) {
|