feat: REQ-1650
This commit is contained in:
parent
d78d01180c
commit
9e56ef41d6
@ -35,9 +35,11 @@ public interface SaasRoleGroupApi {
|
||||
ApiResult<SaasRoleGroupVO> getById(@RequestParam("id") Long id);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* 删除角色分组
|
||||
* @param ids 角色分组ID
|
||||
* @return 返回删除角色分组状态
|
||||
*/
|
||||
@PostMapping("/api/saasRoleGroup//api/saasPermissionGoup/delete")
|
||||
ApiResult<Void> delete(@RequestBody@NotEmpty List<Long> ids);
|
||||
@PostMapping("/api/saasRoleGroup/delete")
|
||||
ApiResult<Void> delete(@RequestParam @NotEmpty List<Long> ids);
|
||||
|
||||
}
|
||||
|
||||
@ -4,10 +4,24 @@ import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author zuoqinbo
|
||||
* @version 1.0
|
||||
* @description
|
||||
* @date 2023/12/1 16:37
|
||||
*/
|
||||
public interface SaasRoleGroupService {
|
||||
|
||||
List<SaasRoleGroupVO> getList(QuerySaasRoleGroupReq req);
|
||||
|
||||
/**
|
||||
* 查询自定义角色分组
|
||||
* @param req 角色分组参数
|
||||
* @return 角色分组列表
|
||||
*/
|
||||
List<SaasRoleGroupVO> getRoleGroupList(QuerySaasRoleGroupReq req);
|
||||
|
||||
|
||||
Long saveOrUpdate(SaasRoleGroupVO req);
|
||||
|
||||
void delete(List<Long> ids);
|
||||
|
||||
@ -319,9 +319,10 @@ public class RoleServiceImpl implements RoleService {
|
||||
saasRole.setUpdateAt(now);
|
||||
// 不可能为空
|
||||
List<Long> groupIds = saveOrUpdateRole.getGroupTree().stream().map(SaveOrUpdateRoleVO.GroupInfoVO::getId).sorted().collect(Collectors.toList());
|
||||
//同分组内角色名称不能重复
|
||||
//同分组内角色名称不能重复 //TODO
|
||||
List<SaasRoleGroupRelation> relations = roleGroupRelationDao.lambdaQuery().in(SaasRoleGroupRelation::getSaasRoleGroupId, groupIds)
|
||||
.eq(SaasRoleGroupRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value).list();
|
||||
|
||||
if (CollectionUtils.isNotEmpty(relations)) {
|
||||
List<Long> roleIds = relations.stream().map(SaasRoleGroupRelation::getRoleId).sorted().collect(Collectors.toList());
|
||||
Map<Long, Set<Long>> groupRoleMap = relations.stream().collect(Collectors.groupingBy(SaasRoleGroupRelation::getSaasRoleGroupId, Collectors.mapping(SaasRoleGroupRelation::getRoleId, Collectors.toSet())));
|
||||
|
||||
@ -38,6 +38,11 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
|
||||
} else if (!req.getOuIds().contains(-1L)) {
|
||||
req.getOuIds().add(-1L);
|
||||
}
|
||||
|
||||
return queryRoleGroup(req);
|
||||
}
|
||||
|
||||
private List<SaasRoleGroupVO> queryRoleGroup(QuerySaasRoleGroupReq req){
|
||||
List<SaasRoleGroupRelation> saasRoleGroupRelations = null;
|
||||
if (CollectionUtils.isNotEmpty(req.getRoleIds())) {
|
||||
saasRoleGroupRelations = saasRoleGroupRelationDao.lambdaQuery()
|
||||
@ -60,7 +65,7 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
|
||||
}
|
||||
// 如果参数指定了roleIds, 返回的值就包含在请求的roleIds中,否则返回全量的roleIds
|
||||
if (CollectionUtils.isEmpty(saasRoleGroupRelations)) {
|
||||
saasRoleGroupRelations = saasRoleGroupRelationDao.lambdaQuery()
|
||||
saasRoleGroupRelations = saasRoleGroupRelationDao.lambdaQuery()
|
||||
.in(SaasRoleGroupRelation::getSaasRoleGroupId, groups.stream().map(SaasRoleGroup::getId).collect(Collectors.toList()))
|
||||
.eq(SaasRoleGroupRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value).list();
|
||||
}
|
||||
@ -74,9 +79,18 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
|
||||
target.setRoleIds(groupRoleMap.get(e.getId()));
|
||||
return target;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
return results;
|
||||
}
|
||||
@Override
|
||||
public List<SaasRoleGroupVO> getRoleGroupList(QuerySaasRoleGroupReq req) {
|
||||
if (CollectionUtils.isEmpty(req.getWorkspaceIds())) {
|
||||
req.setWorkspaceIds(Arrays.asList(-1L));
|
||||
}
|
||||
if (CollectionUtils.isEmpty(req.getOuIds())) {
|
||||
req.setOuIds(Arrays.asList(-1L));
|
||||
}
|
||||
return queryRoleGroup(req);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long saveOrUpdate(SaasRoleGroupVO req) {
|
||||
@ -99,7 +113,7 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
|
||||
.eq(SaasRoleGroupRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
||||
.count();
|
||||
if (relationCount > 0) {
|
||||
throw new ServiceException("分组关联角色,不能删除");
|
||||
throw new ServiceException("该角色分组有关联角色,不能进行删除!");
|
||||
}
|
||||
saasRoleGroupDao.delete(ids);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user