|
@@ -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,17 @@ public class SysRoleFacade extends SysRoleServiceImpl {
|
|
|
@Qualifier("sysRolePermissionServiceImpl")
|
|
|
private SysRolePermissionServiceImpl sysRolePermissionService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private SysUserRoleFacade sysUserRoleFacade;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenFacade tokenFacade;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取角色列表信息
|
|
|
+ *
|
|
|
+ * @return 角色列表信息
|
|
|
+ */
|
|
|
public List<SysRoleDTO> listFac() {
|
|
|
List<SysRole> sysRoleList = this.list(new QueryWrapper<SysRole>()
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
@@ -55,6 +67,11 @@ public class SysRoleFacade extends SysRoleServiceImpl {
|
|
|
return BeanUtil.listCopyTo(sysRoleList, SysRoleDTO.class);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取角色下拉列表信息
|
|
|
+ *
|
|
|
+ * @return 角色下拉列表信息
|
|
|
+ */
|
|
|
public List<SysRoleDTO> listForUser() {
|
|
|
List<SysRole> sysRoleList = this.list(new QueryWrapper<SysRole>()
|
|
|
.eq("is_deleted", IsDeleteEnum.N.getKey())
|
|
@@ -62,6 +79,12 @@ public class SysRoleFacade extends SysRoleServiceImpl {
|
|
|
return BeanUtil.listCopyTo(sysRoleList, SysRoleDTO.class);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取角色菜权限单等数据
|
|
|
+ *
|
|
|
+ * @param sysRoleMenuQueryVO 获取角色菜权限单入参
|
|
|
+ * @return 是否成功
|
|
|
+ */
|
|
|
public List<SysRoleMenuDTO> getRoleMenu(SysRoleMenuQueryVO sysRoleMenuQueryVO) {
|
|
|
List<SysMenuPermissionDTO> sysMenuPermissionDTOList = this.getMenuPermission(sysRoleMenuQueryVO);
|
|
|
List<SysRoleMenuDTO> sysRoleMenuDTOList = new ArrayList<>();
|
|
@@ -115,10 +138,21 @@ public class SysRoleFacade extends SysRoleServiceImpl {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 修改角色菜单权限数据
|
|
|
+ *
|
|
|
+ * @param sysRoleMenuSaveVO 修改角色菜单权限数据入参
|
|
|
+ * @return 是否成功
|
|
|
+ */
|
|
|
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())
|
|
|
.eq("role_id", sysRoleMenuSaveVO.getRoleId())
|
|
@@ -133,7 +167,7 @@ public class SysRoleFacade extends SysRoleServiceImpl {
|
|
|
.set("modifier", userId)
|
|
|
.set("gmt_modified", now)
|
|
|
);
|
|
|
- //新增
|
|
|
+ //新增角色菜单和角色权限
|
|
|
if (ListUtil.isNotEmpty(sysRoleMenuSaveVO.getSysMenuSaveVOList())) {
|
|
|
List<SysRoleMenu> sysRoleMenuList = new ArrayList<>();
|
|
|
for (SysMenuSaveVO sysMenuSaveVO : sysRoleMenuSaveVO.getSysMenuSaveVOList()) {
|
|
@@ -162,6 +196,12 @@ public class SysRoleFacade extends SysRoleServiceImpl {
|
|
|
}
|
|
|
sysRolePermissionService.saveBatch(sysRolePermissionList);
|
|
|
}
|
|
|
+ //清楚该角色的所有用户的token缓存
|
|
|
+ if (ListUtil.isNotEmpty(userIds)) {
|
|
|
+ for (Long id : userIds) {
|
|
|
+ tokenFacade.deleteToken(id.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
return true;
|
|
|
}
|
|
|
}
|