Merge branch 'feature/REQ-3057' into 'release-20241211'
Feature/req 3057 See merge request universal/infrastructure/backend/tyr!377
This commit is contained in:
commit
f94737d173
@ -3,6 +3,7 @@ package cn.axzo.tyr.client.model.roleuser.req;
|
||||
import cn.axzo.foundation.dao.support.wrapper.CriteriaField;
|
||||
import cn.axzo.foundation.dao.support.wrapper.Operator;
|
||||
import cn.axzo.tyr.client.common.enums.FeatureResourceType;
|
||||
import cn.axzo.tyr.client.common.enums.RoleTypeEnum;
|
||||
import cn.axzo.tyr.client.model.enums.IdentityType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@ -137,6 +138,9 @@ public class ListRoleUserRelationParam {
|
||||
@CriteriaField(ignore = true)
|
||||
private List<BatchPerson> batchPersons;
|
||||
|
||||
@CriteriaField(ignore = true)
|
||||
private Set<RoleTypeEnum> roleTypes;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
|
||||
@ -4,6 +4,7 @@ import cn.axzo.basics.common.util.AssertUtil;
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.framework.domain.web.result.ApiPageResult;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.framework.rocketmq.Event;
|
||||
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
|
||||
import cn.axzo.tyr.client.common.enums.RoleTypeEnum;
|
||||
import cn.axzo.tyr.client.feign.TyrSaasRoleUserApi;
|
||||
@ -22,32 +23,14 @@ import cn.axzo.tyr.client.model.roleuser.req.GantOrUnGantaWorkerLeaderRoleReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.GetUserAutoOwnRoleReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.GetUserFeatureResourceIdsReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.ListRoleUserRelationParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.PageRoleUserRelationParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.PageRoleUserRelationReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.SuperAdminParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.WorkerManagerRoleUserReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.AutoOwnRoleUserReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.CreateSuperAdminRoleParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.GantOrUnGantaWorkerLeaderRoleReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.GetUserAutoOwnRoleReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.GetUserFeatureResourceIdsReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.ListRoleUserRelationParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.PageRoleUserRelationParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.SuperAdminParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.WorkerManagerRoleUserReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.AutoOwnRoleUserReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.CreateSuperAdminRoleParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.GantOrUnGantaWorkerLeaderRoleReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.GetUserAutoOwnRoleReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.GetUserFeatureResourceIdsReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.ListRoleUserRelationParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.RoleUserReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.SuperAdminParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.WorkerManagerRoleUserReq;
|
||||
import cn.axzo.tyr.server.config.MqProducer;
|
||||
import cn.axzo.tyr.server.event.payload.SaasRoleUserRelationRemovePayload;
|
||||
import cn.axzo.tyr.server.model.PermissionCacheKey;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasRoleUserRelationDao;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleUserRelation;
|
||||
@ -55,11 +38,10 @@ import cn.axzo.tyr.server.repository.mapper.SaasRoleUserRelationMapper;
|
||||
import cn.axzo.tyr.server.service.PermissionCacheService;
|
||||
import cn.axzo.tyr.server.service.SaasRoleUserRelationService;
|
||||
import cn.axzo.tyr.server.service.SaasRoleUserService;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.google.common.collect.Lists;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -72,12 +54,12 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.validation.Valid;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.axzo.tyr.server.event.inner.EventTypeEnum.SAAS_ROLE_USER_RELATION_REMOVED;
|
||||
|
||||
/**
|
||||
* @author tanjie@axzo.cn
|
||||
* @date 2023/9/13 15:47
|
||||
@ -91,6 +73,8 @@ public class RoleUserController implements TyrSaasRoleUserApi {
|
||||
private final SaasRoleUserRelationDao saasRoleUserRelationDao;
|
||||
private final PermissionCacheService permissionCacheService;
|
||||
private final SaasRoleUserRelationMapper saasRoleUserRelationMapper;
|
||||
private final MqProducer mqProducer;
|
||||
private static final String TARGET_TYPE = "saasRoleUserRelationId";
|
||||
|
||||
@Override
|
||||
public ApiResult<Void> saveOrUpdate(@Valid RoleUserReq req) {
|
||||
@ -245,6 +229,15 @@ public class RoleUserController implements TyrSaasRoleUserApi {
|
||||
.identityType(IdentityType.getIdentityType(relation.getIdentityType()))
|
||||
.build());
|
||||
}
|
||||
|
||||
Event event = Event.builder()
|
||||
.targetType(TARGET_TYPE)
|
||||
.eventCode(SAAS_ROLE_USER_RELATION_REMOVED.getEventCode())
|
||||
.data(SaasRoleUserRelationRemovePayload.builder()
|
||||
.values(relations)
|
||||
.build())
|
||||
.build();
|
||||
mqProducer.send(event);
|
||||
return ApiResult.ok();
|
||||
}
|
||||
|
||||
|
||||
@ -12,6 +12,7 @@ public enum EventTypeEnum {
|
||||
SAAS_FEATURE_RESOURCE_UPSERT("saas-feature-resource", "saas-feature-resource-upsert", "新菜单树更新"),
|
||||
PAGE_ELEMENT_FEATURE_RESOURCE_UPSERT("page-element-feature-resource", "page-element-feature-resource-upsert", "菜单-页面元素绑定关系更新"),
|
||||
SAAS_ROLE_USER_RELATION_REMOVED("saas-role-user-relation", "saas-role-user-relation-removed", "删除用户角色信息"),
|
||||
SAAS_ROLE_USER_RELATION_UPSERT("saas-role-user-relation", "saas-role-user-relation-upsert", "更新用户角色信息"),
|
||||
;
|
||||
|
||||
EventTypeEnum(String model, String name, String desc) {
|
||||
|
||||
@ -0,0 +1,30 @@
|
||||
package cn.axzo.tyr.server.event.payload;
|
||||
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserV2DTO;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleUserRelation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SaasRoleUserRelationUpsertPayload implements Serializable {
|
||||
|
||||
private List<SaasRoleUserRelation> oldValues;
|
||||
|
||||
private List<SaasRoleUserRelation> newValues;
|
||||
|
||||
public static SaasRoleUserRelation from(SaasRoleUserV2DTO saasRoleUserV2DTO) {
|
||||
SaasRoleUserRelation result = new SaasRoleUserRelation();
|
||||
BeanUtils.copyProperties(saasRoleUserV2DTO, result);
|
||||
result.setNaturalPersonId(saasRoleUserV2DTO.getSaasRoleUser().getPersonId());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -7,6 +7,7 @@ import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
|
||||
import cn.axzo.basics.common.exception.ServiceException;
|
||||
import cn.axzo.basics.common.util.AssertUtil;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.framework.rocketmq.Event;
|
||||
import cn.axzo.maokai.api.client.OrgJobApi;
|
||||
import cn.axzo.maokai.api.client.OrganizationalNodeUserQueryApi;
|
||||
import cn.axzo.maokai.api.vo.request.OrgJobListReq;
|
||||
@ -18,7 +19,6 @@ import cn.axzo.pokonyan.util.KeysUtil;
|
||||
import cn.axzo.tyr.client.common.enums.RoleResourceTypeEnum;
|
||||
import cn.axzo.tyr.client.common.enums.RoleTypeEnum;
|
||||
import cn.axzo.tyr.client.model.BaseWorkspaceModel;
|
||||
import cn.axzo.tyr.client.model.enums.DictWorkSpaceTypeEnum;
|
||||
import cn.axzo.tyr.client.model.enums.IdentityType;
|
||||
import cn.axzo.tyr.client.model.enums.WorkerLeaderRoleEnum;
|
||||
import cn.axzo.tyr.client.model.req.ListRoleReq;
|
||||
@ -39,6 +39,8 @@ import cn.axzo.tyr.client.model.roleuser.req.RoleUserReq;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.SuperAdminParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.WorkerManagerRoleUserReq;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||
import cn.axzo.tyr.server.config.MqProducer;
|
||||
import cn.axzo.tyr.server.event.payload.SaasRoleUserRelationUpsertPayload;
|
||||
import cn.axzo.tyr.server.model.RoleUserInfo;
|
||||
import cn.axzo.tyr.server.repository.dao.RemoveRoleUserByResource;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasPgroupPermissionRelationDao;
|
||||
@ -82,6 +84,9 @@ import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.axzo.tyr.server.event.inner.EventTypeEnum.SAAS_ROLE_USER_RELATION_UPSERT;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
*
|
||||
@ -106,6 +111,8 @@ public class RoleUserService implements SaasRoleUserService {
|
||||
private final WorkspaceConfigApi workspaceConfigApi;
|
||||
private final OrganizationalNodeUserQueryApi organizationalNodeUserQueryApi;
|
||||
private final RoleService roleService;
|
||||
private final MqProducer mqProducer;
|
||||
private static final String TARGET_TYPE = "saasRoleUserRelationId";
|
||||
|
||||
// 单位类型默认角色关系,后面可以座位管理员的逻辑进行迭代
|
||||
@Value("#{${participateUnitDefaultRoleId:{}}}")
|
||||
@ -263,23 +270,41 @@ public class RoleUserService implements SaasRoleUserService {
|
||||
updateRoleIds.addAll(notAdminAndAutoOwnRole);
|
||||
}
|
||||
// 清空所有角色
|
||||
if (CollectionUtil.isEmpty(updateRoleIds)) {
|
||||
return;
|
||||
if (!CollectionUtil.isEmpty(updateRoleIds)) {
|
||||
roleUserRelationDao.saveBatch(updateRoleIds.stream().map(e -> {
|
||||
SaasRoleUserRelation saasRoleUserRelation = new SaasRoleUserRelation();
|
||||
saasRoleUserRelation.setIdentityId(req.getIdentityId());
|
||||
saasRoleUserRelation.setIdentityType(req.getIdentityType().getCode());
|
||||
saasRoleUserRelation.setRoleId(e);
|
||||
saasRoleUserRelation.setNaturalPersonId(req.getPersonId());
|
||||
saasRoleUserRelation.setOuId(req.getOuId());
|
||||
saasRoleUserRelation.setWorkspaceId(req.getWorkspaceId());
|
||||
saasRoleUserRelation.setCreateBy(req.getOperator());
|
||||
saasRoleUserRelation.setUpdateBy(req.getOperator());
|
||||
return saasRoleUserRelation;
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
roleUserRelationDao.saveBatch(updateRoleIds.stream().map(e -> {
|
||||
SaasRoleUserRelation saasRoleUserRelation = new SaasRoleUserRelation();
|
||||
saasRoleUserRelation.setIdentityId(req.getIdentityId());
|
||||
saasRoleUserRelation.setIdentityType(req.getIdentityType().getCode());
|
||||
saasRoleUserRelation.setRoleId(e);
|
||||
saasRoleUserRelation.setNaturalPersonId(req.getPersonId());
|
||||
saasRoleUserRelation.setOuId(req.getOuId());
|
||||
saasRoleUserRelation.setWorkspaceId(req.getWorkspaceId());
|
||||
saasRoleUserRelation.setCreateBy(req.getOperator());
|
||||
saasRoleUserRelation.setUpdateBy(req.getOperator());
|
||||
return saasRoleUserRelation;
|
||||
}).collect(Collectors.toList()));
|
||||
|
||||
List<SaasRoleUserV2DTO> newSaasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.identityId(req.getIdentityId())
|
||||
.identityType(req.getIdentityType())
|
||||
.workspaceId(req.getWorkspaceId())
|
||||
.ouId(req.getOuId())
|
||||
.build());
|
||||
Event event = Event.builder()
|
||||
.targetType(TARGET_TYPE)
|
||||
.eventCode(SAAS_ROLE_USER_RELATION_UPSERT.getEventCode())
|
||||
.data(SaasRoleUserRelationUpsertPayload.builder()
|
||||
.oldValues(saasRoleUsers.stream()
|
||||
.map(SaasRoleUserRelationUpsertPayload::from)
|
||||
.collect(Collectors.toList()))
|
||||
.newValues(newSaasRoleUsers.stream()
|
||||
.map(SaasRoleUserRelationUpsertPayload::from)
|
||||
.collect(Collectors.toList()))
|
||||
.build())
|
||||
.build();
|
||||
mqProducer.send(event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -298,6 +323,13 @@ public class RoleUserService implements SaasRoleUserService {
|
||||
|
||||
AssertUtil.notNull(superAdmin, "超管角色不存在,请联系业务初始化超管角色");
|
||||
|
||||
List<SaasRoleUserRelation> oldValues = roleUserRelationDao.lambdaQuery()
|
||||
.eq(SaasRoleUserRelation::getIdentityId, param.getIdentityId())
|
||||
.eq(SaasRoleUserRelation::getIdentityType, param.getIdentityType().getCode())
|
||||
.eq(SaasRoleUserRelation::getNaturalPersonId, param.getNaturalPersonId())
|
||||
.eq(SaasRoleUserRelation::getOuId, param.getOuId())
|
||||
.eq(SaasRoleUserRelation::getWorkspaceId, param.getWorkspaceId())
|
||||
.list();
|
||||
//删除当前超管角色
|
||||
removeOldSuperAdmin(superAdmin.getId(), param.getWorkspaceId(), param.getOuId());
|
||||
|
||||
@ -310,6 +342,22 @@ public class RoleUserService implements SaasRoleUserService {
|
||||
saasRoleUserRelation.setOuId(param.getOuId());
|
||||
saasRoleUserRelation.setWorkspaceId(param.getWorkspaceId());
|
||||
roleUserRelationDao.save(saasRoleUserRelation);
|
||||
|
||||
Event event = Event.builder()
|
||||
.targetType(TARGET_TYPE)
|
||||
.eventCode(SAAS_ROLE_USER_RELATION_UPSERT.getEventCode())
|
||||
.data(SaasRoleUserRelationUpsertPayload.builder()
|
||||
.oldValues(oldValues)
|
||||
.newValues(roleUserRelationDao.lambdaQuery()
|
||||
.eq(SaasRoleUserRelation::getIdentityId, param.getIdentityId())
|
||||
.eq(SaasRoleUserRelation::getIdentityType, param.getIdentityType().getCode())
|
||||
.eq(SaasRoleUserRelation::getNaturalPersonId, param.getNaturalPersonId())
|
||||
.eq(SaasRoleUserRelation::getOuId, param.getOuId())
|
||||
.eq(SaasRoleUserRelation::getWorkspaceId, param.getWorkspaceId())
|
||||
.list())
|
||||
.build())
|
||||
.build();
|
||||
mqProducer.send(event);
|
||||
}
|
||||
|
||||
private void removeOldSuperAdmin(Long id, Long workspaceId, Long ouId) {
|
||||
|
||||
@ -129,7 +129,8 @@ public class SaasRoleUserRelationServiceImpl extends ServiceImpl<SaasRoleUserRel
|
||||
}
|
||||
|
||||
Set<Long> roleIds = resolveRoleIds(param);
|
||||
if (!CollectionUtils.isEmpty(param.getRoleCodes()) && CollectionUtils.isEmpty(roleIds)) {
|
||||
if ((!CollectionUtils.isEmpty(param.getRoleCodes()) || !CollectionUtils.isEmpty(param.getRoleTypes()))
|
||||
&& CollectionUtils.isEmpty(roleIds)) {
|
||||
return param.toEmpty();
|
||||
}
|
||||
wrapper.in(!CollectionUtils.isEmpty(roleIds), "role_id", roleIds);
|
||||
@ -202,13 +203,16 @@ public class SaasRoleUserRelationServiceImpl extends ServiceImpl<SaasRoleUserRel
|
||||
}
|
||||
|
||||
private Set<Long> resolveRoleIds(PageRoleUserRelationParam param) {
|
||||
if (CollectionUtils.isEmpty(param.getRoleCodes())) {
|
||||
if (CollectionUtils.isEmpty(param.getRoleCodes()) && CollectionUtils.isEmpty(param.getRoleTypes())) {
|
||||
return Optional.ofNullable(param.getRoleIds())
|
||||
.map(Sets::newHashSet)
|
||||
.orElseGet(Sets::newHashSet);
|
||||
}
|
||||
ListRoleReq listSaasRoleParam = ListRoleReq.builder()
|
||||
.roleCodes(param.getRoleCodes())
|
||||
.roleTypes(Optional.ofNullable(param.getRoleTypes())
|
||||
.map(e -> e.stream().map(RoleTypeEnum::getValue).collect(Collectors.toList()))
|
||||
.orElse(null))
|
||||
.build();
|
||||
Set<Long> roleIds = roleService.list(listSaasRoleParam).stream()
|
||||
.map(SaasRoleRes::getId)
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
package cn.axzo.tyr.server.service.impl;
|
||||
|
||||
import cn.axzo.foundation.exception.BusinessException;
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.tyr.base.BaseTest;
|
||||
import cn.axzo.tyr.base.MysqlDataLoader;
|
||||
import cn.axzo.tyr.client.common.enums.RoleTypeEnum;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserV2DTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.ListRoleUserRelationParam;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.PageRoleUserRelationParam;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleUserRelation;
|
||||
import cn.axzo.tyr.server.service.SaasRoleUserRelationService;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -56,4 +59,63 @@ class SaasRoleUserRelationServiceImplTest extends BaseTest {
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder().build()).size(), 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
void list() {
|
||||
|
||||
ListRoleUserRelationParam list = ListRoleUserRelationParam.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:mafb_business_vice_officer"))
|
||||
.build();
|
||||
List<SaasRoleUserV2DTO> result = saasRoleUserRelationService.listV2(list);
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
|
||||
|
||||
list = ListRoleUserRelationParam.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:mafb_business_vice_officer1"))
|
||||
.build();
|
||||
result = saasRoleUserRelationService.listV2(list);
|
||||
Assertions.assertEquals(result.size(), 0);
|
||||
|
||||
list = ListRoleUserRelationParam.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:mafb_business_vice_officer", "cms:mafb_productivity_vice_officer"))
|
||||
.build();
|
||||
result = saasRoleUserRelationService.listV2(list);
|
||||
Assertions.assertEquals(result.size(), 2);
|
||||
|
||||
list = ListRoleUserRelationParam.builder()
|
||||
.roleTypes(Sets.newHashSet(RoleTypeEnum.ADMIN))
|
||||
.build();
|
||||
result = saasRoleUserRelationService.listV2(list);
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
|
||||
list = ListRoleUserRelationParam.builder()
|
||||
.roleTypes(Sets.newHashSet(RoleTypeEnum.SUPER_ADMIN))
|
||||
.build();
|
||||
result = saasRoleUserRelationService.listV2(list);
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
|
||||
list = ListRoleUserRelationParam.builder()
|
||||
.roleTypes(Sets.newHashSet(RoleTypeEnum.ADMIN, RoleTypeEnum.SUPER_ADMIN))
|
||||
.build();
|
||||
result = saasRoleUserRelationService.listV2(list);
|
||||
Assertions.assertEquals(result.size(), 2);
|
||||
|
||||
list = ListRoleUserRelationParam.builder()
|
||||
.roleTypes(Sets.newHashSet(RoleTypeEnum.ADMIN, RoleTypeEnum.SUPER_ADMIN))
|
||||
.roleCodes(Sets.newHashSet("sdfdsf"))
|
||||
.build();
|
||||
result = saasRoleUserRelationService.listV2(list);
|
||||
Assertions.assertEquals(result.size(), 0);
|
||||
|
||||
list = ListRoleUserRelationParam.builder()
|
||||
.roleTypes(Sets.newHashSet(RoleTypeEnum.ADMIN, RoleTypeEnum.SUPER_ADMIN))
|
||||
.roleCodes(Sets.newHashSet("oms:project_manager"))
|
||||
.workspaceOuPairs(Lists.newArrayList(ListRoleUserRelationParam.WorkspaceOuPair.builder()
|
||||
.workspaceId(8L)
|
||||
.ouId(1L)
|
||||
.build()))
|
||||
.build();
|
||||
result = saasRoleUserRelationService.listV2(list);
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
}
|
||||
}
|
||||
@ -5,4 +5,14 @@ INSERT INTO saas_role_user_relation (id, identity_id, role_id, identity_type, na
|
||||
INSERT INTO saas_role_user_relation (id, identity_id, role_id, identity_type, natural_person_id, workspace_id, ou_id, resource_type, resource_id, is_delete, create_at, update_at, create_by, update_by, job_type) VALUES (16401, 98, 3417, 3, 2020, 6, 1, 0, 0, 0, '2021-09-16 22:09:29', '2021-09-16 22:09:29', 0, 0, 2);
|
||||
INSERT INTO saas_role_user_relation (id, identity_id, role_id, identity_type, natural_person_id, workspace_id, ou_id, resource_type, resource_id, is_delete, create_at, update_at, create_by, update_by, job_type) VALUES (16402, 106, 3418, 3, 3577, 12, 1, 0, 0, 0, '2021-09-16 22:09:29', '2021-09-16 22:09:29', 0, 0, 2);
|
||||
|
||||
|
||||
INSERT INTO saas_role (id, NAME, description, role_type, role_code, workspace_id, owner_ou_id, product_unit_type, workspace_type, is_delete, create_at, update_at, create_by, update_by, fit_ou_type_bit, fit_ou_node_type_bit, position_template_id, project_team_manage_role_resource_id, from_pre_role_id, job_code, is_display, sort, enabled)
|
||||
VALUES (3415, '项目经理', '', 'super_admin', 'oms:project_manager', -1, -1, 6, 6, 0, '2023-09-19 15:22:55', '2024-08-13 10:25:25', 2003043, 2003028, 1, 65535, 0, null, 0, '', 1, 2, 1);
|
||||
INSERT INTO saas_role (id, NAME, description, role_type, role_code, workspace_id, owner_ou_id, product_unit_type, workspace_type, is_delete, create_at, update_at, create_by, update_by, fit_ou_type_bit, fit_ou_node_type_bit, position_template_id, project_team_manage_role_resource_id, from_pre_role_id, job_code, is_display, sort, enabled)
|
||||
VALUES (3416, '项目负责人', '', 'admin', 'cms:mafb_project_commissioner', -1, -1, 5, 2, 0, '2023-10-23 17:49:59', '2024-08-13 10:25:40', -1, 9000399985, 1, 65535, 0, null, 0, '', 1, 1, 1);
|
||||
INSERT INTO saas_role (id, NAME, description, role_type, role_code, workspace_id, owner_ou_id, product_unit_type, workspace_type, is_delete, create_at, update_at, create_by, update_by, fit_ou_type_bit, fit_ou_node_type_bit, position_template_id, project_team_manage_role_resource_id, from_pre_role_id, job_code, is_display, sort, enabled)
|
||||
VALUES (3417, '商务副经理', '', 'init', 'cms:mafb_business_vice_officer', -1, -1, 5, 2, 0, '2023-10-23 17:50:00', '2024-08-13 10:25:41', -1, 2006333, 1, 65535, 0, null, 0, '', 1, 2, 1);
|
||||
INSERT INTO saas_role (id, NAME, description, role_type, role_code, workspace_id, owner_ou_id, product_unit_type, workspace_type, is_delete, create_at, update_at, create_by, update_by, fit_ou_type_bit, fit_ou_node_type_bit, position_template_id, project_team_manage_role_resource_id, from_pre_role_id, job_code, is_display, sort, enabled)
|
||||
VALUES (3418, '生产副经理', '', 'init', 'cms:mafb_productivity_vice_officer', -1, -1, 5, 2, 0, '2023-10-23 17:50:00', '2024-08-13 10:25:41', -1, 2006333, 1, 65535, 0, null, 0, '', 1, 3, 1);
|
||||
|
||||
#-->SaasRoleUserRelationServiceImplTest.sql
|
||||
Loading…
Reference in New Issue
Block a user