|
@@ -24,6 +24,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import sun.misc.Request;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.security.NoSuchAlgorithmException;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
@@ -52,6 +53,9 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|
|
@Resource
|
|
|
SysRoleService sysRoleService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TeachcloudCommonService commonService;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<SysRole> list(String name, Boolean enable, Integer pageNumber, Integer pageSize) {
|
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
@@ -139,6 +143,11 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|
|
sysRolePrivilegeService.removeByRoleId(role.getId());
|
|
|
sysRolePrivilegeService.saveBatch(role);//角色权限
|
|
|
cacheService.updateRolePrivilegeCache(role.getId());
|
|
|
+ //绑定该角色的用户都需要清除鉴权缓存
|
|
|
+ List<SysUserRole> sysUserRoleList = sysUserRoleService.listByRoleId(role.getId());
|
|
|
+ for (SysUserRole s : sysUserRoleList) {
|
|
|
+ commonService.removeUserInfo(s.getUserId());
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
role.setCreateId(sysUser.getId());
|
|
@@ -160,11 +169,18 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public boolean enable(SysRole role) {
|
|
|
+ public boolean enable(SysRole role) throws NoSuchAlgorithmException {
|
|
|
UpdateWrapper<SysRole> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.lambda().set(SysRole::getEnable, role.getEnable()).eq(SysRole::getId, role.getId());
|
|
|
this.update(updateWrapper);
|
|
|
- cacheService.roleCache(role.getId());
|
|
|
+ cacheService.updateRoleCache(role.getId());
|
|
|
+ //如果状态为禁用,需要踢下线重新登录
|
|
|
+ if (!role.getEnable()) {
|
|
|
+ List<SysUserRole> sysUserRoleList = sysUserRoleService.listByRoleId(role.getId());
|
|
|
+ for (SysUserRole s : sysUserRoleList) {
|
|
|
+ commonService.removeUserInfo(s.getUserId());
|
|
|
+ }
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
|