feat(REQ-2488): 查询角色接口调整
This commit is contained in:
parent
934609e657
commit
3998210c6f
@ -73,6 +73,10 @@ public class ListRoleReq {
|
||||
* 是否需要角色对应的用户信息
|
||||
*/
|
||||
private Boolean needRoleUser;
|
||||
/**
|
||||
* 是否需要预设角色,因为预设角色的workspaceId和ouId为-1
|
||||
*/
|
||||
private Boolean needPresetRole;
|
||||
|
||||
/**
|
||||
* workspaceId和ouId配对查询
|
||||
|
||||
@ -167,6 +167,12 @@ public interface RoleService extends IService<SaasRole> {
|
||||
@CriteriaField(ignore = true)
|
||||
private Boolean needPermissionRelation;
|
||||
|
||||
/**
|
||||
* 是否需要预设角色,因为预设角色的workspaceId和ouId为-1
|
||||
*/
|
||||
@CriteriaField(ignore = true)
|
||||
private Boolean needPresetRole;
|
||||
|
||||
/**
|
||||
* 查询菜单树节点类型
|
||||
*/
|
||||
|
||||
@ -110,6 +110,11 @@ import static cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelation.
|
||||
public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
|
||||
implements RoleService {
|
||||
|
||||
private static final ListRoleUserRelationParam.WorkspaceOuPair PRESET_WORKSPACE_OU_PAIR = ListRoleUserRelationParam.WorkspaceOuPair.builder()
|
||||
.ouId(-1L)
|
||||
.workspaceId(-1L)
|
||||
.build();
|
||||
|
||||
@Autowired
|
||||
SaasRoleUserRelationDao roleUserRelationDao;
|
||||
@Autowired
|
||||
@ -1137,9 +1142,16 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
|
||||
public cn.axzo.foundation.page.PageResp<SaasRoleRes> page(PageSaasRoleParam param) {
|
||||
QueryWrapper<SaasRole> wrapper = QueryWrapperHelper.fromBean(param, SaasRole.class);
|
||||
wrapper.eq("is_delete", 0);
|
||||
if (CollectionUtils.isNotEmpty(param.getWorkspaceOuPairs())) {
|
||||
List<ListRoleUserRelationParam.WorkspaceOuPair> workspaceOuPairs = Lists.newArrayList();
|
||||
if (Boolean.TRUE.equals(param.getNeedPresetRole())) {
|
||||
workspaceOuPairs.add(PRESET_WORKSPACE_OU_PAIR);
|
||||
}
|
||||
CollectionUtils.addAll(workspaceOuPairs, Optional.ofNullable(param.getWorkspaceOuPairs())
|
||||
.map(List::listIterator)
|
||||
.orElseGet(Collections::emptyListIterator));
|
||||
if (CollectionUtils.isNotEmpty(workspaceOuPairs)) {
|
||||
wrapper.and(j -> {
|
||||
for (ListRoleUserRelationParam.WorkspaceOuPair workspaceOuPair : param.getWorkspaceOuPairs()) {
|
||||
for (ListRoleUserRelationParam.WorkspaceOuPair workspaceOuPair : workspaceOuPairs) {
|
||||
j.or(k -> {
|
||||
k.eq(Objects.nonNull(workspaceOuPair.getOuId()), "ou_id", workspaceOuPair.getOuId());
|
||||
k.eq(Objects.nonNull(workspaceOuPair.getWorkspaceId()), "workspace_id", workspaceOuPair.getWorkspaceId());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user