|
@@ -9,6 +9,7 @@ import com.diagbot.dto.SysRoleMenuDTO;
|
|
|
import com.diagbot.entity.SysRole;
|
|
|
import com.diagbot.entity.SysRoleMenu;
|
|
|
import com.diagbot.entity.SysRolePermission;
|
|
|
+import com.diagbot.entity.SysUserRole;
|
|
|
import com.diagbot.enums.IsDeleteEnum;
|
|
|
import com.diagbot.service.impl.SysRoleMenuServiceImpl;
|
|
|
import com.diagbot.service.impl.SysRolePermissionServiceImpl;
|
|
@@ -22,7 +23,6 @@ import com.diagbot.vo.SysMenuSaveVO;
|
|
|
import com.diagbot.vo.SysPermissionSaveVO;
|
|
|
import com.diagbot.vo.SysRoleMenuQueryVO;
|
|
|
import com.diagbot.vo.SysRoleMenuSaveVO;
|
|
|
-import com.diagbot.vo.SysRoleQueryVO;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.stereotype.Component;
|
|
@@ -31,6 +31,7 @@ import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description:
|
|
@@ -47,6 +48,12 @@ public class SysRoleFacade extends SysRoleServiceImpl {
|
|
|
@Qualifier("sysRolePermissionServiceImpl")
|
|
|
private SysRolePermissionServiceImpl sysRolePermissionService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysUserRoleFacade sysUserRoleFacade;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenFacade tokenFacade;
|
|
|
+
|
|
|
public List<SysRoleDTO> listFac() {
|
|
|
List<SysRole> sysRoleList = this.list(new QueryWrapper<SysRole>()
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
@@ -118,6 +125,11 @@ public class SysRoleFacade extends SysRoleServiceImpl {
|
|
|
public Boolean saveRoleMenu(SysRoleMenuSaveVO sysRoleMenuSaveVO) {
|
|
|
Date now = DateUtil.now();
|
|
|
String userId = SysUserUtils.getCurrentPrincipleID();
|
|
|
+ //查询该角色的所有用户
|
|
|
+ List<Long> userIds = sysUserRoleFacade.list(new QueryWrapper<SysUserRole>()
|
|
|
+ .eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
|
+ .eq("role_id", sysRoleMenuSaveVO.getRoleId())
|
|
|
+ ).stream().distinct().map(SysUserRole::getUserId).collect(Collectors.toList());
|
|
|
//删除
|
|
|
sysRoleMenuService.update(new UpdateWrapper<SysRoleMenu>()
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
@@ -162,6 +174,12 @@ public class SysRoleFacade extends SysRoleServiceImpl {
|
|
|
}
|
|
|
sysRolePermissionService.saveBatch(sysRolePermissionList);
|
|
|
}
|
|
|
+ //清楚该角色的所有用户的token缓存
|
|
|
+ if (ListUtil.isNotEmpty(userIds)) {
|
|
|
+ for (Long id : userIds) {
|
|
|
+ tokenFacade.deleteToken(id.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
}
|