|
@@ -18,6 +18,8 @@ import com.qmth.teachcloud.common.mapper.SysRoleMapper;
|
|
import com.qmth.teachcloud.common.service.*;
|
|
import com.qmth.teachcloud.common.service.*;
|
|
import com.qmth.teachcloud.common.util.ResultUtil;
|
|
import com.qmth.teachcloud.common.util.ResultUtil;
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
@@ -38,6 +40,7 @@ import java.util.stream.Collectors;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
|
public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> implements SysRoleService {
|
|
|
|
+ private final static Logger log = LoggerFactory.getLogger(SysRoleServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private SysUserRoleService sysUserRoleService;
|
|
private SysUserRoleService sysUserRoleService;
|
|
@@ -132,6 +135,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
public boolean saveRoleNew(SysRole role) {
|
|
public boolean saveRoleNew(SysRole role) {
|
|
|
|
+ long start = System.currentTimeMillis();
|
|
try {
|
|
try {
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
Long schoolId = Objects.nonNull(ServletUtil.getRequestHeaderSchoolIdByNotVaild()) ? Long.valueOf(ServletUtil.getRequestHeaderSchoolIdByNotVaild().toString()) : null;
|
|
Long schoolId = Objects.nonNull(ServletUtil.getRequestHeaderSchoolIdByNotVaild()) ? Long.valueOf(ServletUtil.getRequestHeaderSchoolIdByNotVaild().toString()) : null;
|
|
@@ -164,7 +168,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|
commonCacheService.updateRoleCache(role.getId());
|
|
commonCacheService.updateRoleCache(role.getId());
|
|
if (count != sysRolePrivilegeList.size() || count != finalRelatedSet.size()) {
|
|
if (count != sysRolePrivilegeList.size() || count != finalRelatedSet.size()) {
|
|
// 删除权限前先更新涉及特殊权限用户 -> 需要重新同步
|
|
// 删除权限前先更新涉及特殊权限用户 -> 需要重新同步
|
|
- List<SysRolePrivilege> dbRolePriList = sysRolePrivilegeService.listByRoleId(role.getId());
|
|
|
|
|
|
+ List<SysRolePrivilege> dbRolePriList = commonCacheService.rolePrivilegeCache(role.getId());
|
|
this.updateUserPushStats(dbRolePriList.stream().map(SysRolePrivilege::getPrivilegeId).distinct().collect(Collectors.toList()),
|
|
this.updateUserPushStats(dbRolePriList.stream().map(SysRolePrivilege::getPrivilegeId).distinct().collect(Collectors.toList()),
|
|
Arrays.asList(role.getPrivilegeIds()),
|
|
Arrays.asList(role.getPrivilegeIds()),
|
|
role.getId(),
|
|
role.getId(),
|
|
@@ -174,9 +178,7 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
|
|
commonCacheService.updateRolePrivilegeCache(role.getId());
|
|
commonCacheService.updateRolePrivilegeCache(role.getId());
|
|
//绑定该角色的用户都需要清除鉴权缓存
|
|
//绑定该角色的用户都需要清除鉴权缓存
|
|
List<SysUserRole> sysUserRoleList = sysUserRoleService.listByRoleId(role.getId());
|
|
List<SysUserRole> sysUserRoleList = sysUserRoleService.listByRoleId(role.getId());
|
|
- for (SysUserRole s : sysUserRoleList) {
|
|
|
|
- commonService.removeUserInfo(s.getUserId(), true);
|
|
|
|
- }
|
|
|
|
|
|
+ commonService.removeUserInfoBatch(sysUserRoleList.stream().map(s -> s.getUserId()).collect(Collectors.toList()), true);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
role.insertInfo(sysUser.getId());
|
|
role.insertInfo(sysUser.getId());
|