feat:(REQ-3282) 增加角色用户的page接口
This commit is contained in:
parent
0a6670666a
commit
cdcf121570
@ -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
|
||||
|
||||
@ -3,6 +3,7 @@ package cn.axzo.tyr.client.model.roleuser.req;
|
||||
import cn.axzo.foundation.dao.support.wrapper.CriteriaField;
|
||||
import cn.axzo.foundation.page.IPageReq;
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserV2DTO;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@ -10,6 +11,7 @@ import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@SuperBuilder
|
||||
@Data
|
||||
@ -29,10 +31,12 @@ public class PageRoleUserRelationParam extends ListRoleUserRelationParam impleme
|
||||
@CriteriaField(ignore = true)
|
||||
List<String> sort;
|
||||
|
||||
public PageResp toEmpty() {
|
||||
return PageResp.builder()
|
||||
.current(this.getPage())
|
||||
.size(this.getPageSize())
|
||||
public PageResp<SaasRoleUserV2DTO> toEmpty() {
|
||||
return PageResp.<SaasRoleUserV2DTO>builder()
|
||||
.current(Optional.ofNullable(this.getPage())
|
||||
.orElse(DEFAULT_PAGE_NUMBER))
|
||||
.size(Optional.ofNullable(this.getPageSize())
|
||||
.orElse(DEFAULT_PAGE_SIZE))
|
||||
.total(0)
|
||||
.data(Collections.emptyList())
|
||||
.build();
|
||||
|
||||
@ -0,0 +1,22 @@
|
||||
package cn.axzo.tyr.feign.api;
|
||||
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.foundation.result.ApiResult;
|
||||
import cn.axzo.tyr.feign.req.PageRoleUserReq;
|
||||
import cn.axzo.tyr.feign.resp.RoleUserResp;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@FeignClient(name = "tyr", url = "${axzo.service.tyr:http://tyr:8080}")
|
||||
public interface RoleUserApi {
|
||||
|
||||
/**
|
||||
* 角色用户page接口
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/roleUser/page")
|
||||
ApiResult<PageResp<RoleUserResp>> page(@RequestBody @Validated PageRoleUserReq req);
|
||||
}
|
||||
@ -0,0 +1,83 @@
|
||||
package cn.axzo.tyr.feign.req;
|
||||
|
||||
import cn.axzo.tyr.feign.enums.RoleTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PageRoleUserReq {
|
||||
|
||||
private Integer page;
|
||||
|
||||
/**
|
||||
* 最大值1000
|
||||
*/
|
||||
@Max(value = 1000, message = "pageSize最大值为1000")
|
||||
private Integer pageSize;
|
||||
|
||||
/**
|
||||
* 排序:使用示例,createTime__DESC
|
||||
*/
|
||||
private List<String> sort;
|
||||
|
||||
/**
|
||||
* 企业id
|
||||
*/
|
||||
private Long ouId;
|
||||
|
||||
/**
|
||||
* 项目id
|
||||
*/
|
||||
private Long workspaceId;
|
||||
|
||||
/**
|
||||
* 角色code
|
||||
*/
|
||||
private Set<String> roleCodes;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private Set<Long> roleIds;
|
||||
|
||||
/**
|
||||
* 角色类型:RoleTypeEnum
|
||||
* super_admin:超级管理员
|
||||
* admin:管理员
|
||||
* init:初始化内置角色-标准角色
|
||||
* auto_own:虚拟角色(自定义权限使用)
|
||||
* common:自定义角色
|
||||
*/
|
||||
private Set<RoleTypeEnum> roleTypes;
|
||||
|
||||
/**
|
||||
* workspaceId和ouId配对查询
|
||||
* 例如:((workspaceId = ## and ouId = ##) or (workspaceId = ## and ouId = ##))
|
||||
*/
|
||||
private List<WorkspaceOuPair> workspaceOuPairs;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class WorkspaceOuPair {
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
private Long workspaceId;
|
||||
|
||||
/**
|
||||
* 单位id
|
||||
*/
|
||||
private Long ouId;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,81 @@
|
||||
package cn.axzo.tyr.server.controller.v2;
|
||||
|
||||
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.foundation.result.ApiResult;
|
||||
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.feign.api.RoleUserApi;
|
||||
import cn.axzo.tyr.feign.req.PageRoleUserReq;
|
||||
import cn.axzo.tyr.feign.resp.RoleUserResp;
|
||||
import cn.axzo.tyr.server.service.SaasRoleUserRelationService;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class RoleUserV2Controller implements RoleUserApi {
|
||||
|
||||
@Autowired
|
||||
private SaasRoleUserRelationService saasRoleUserRelationService;
|
||||
|
||||
@Override
|
||||
public ApiResult<PageResp<RoleUserResp>> page(PageRoleUserReq req) {
|
||||
|
||||
PageResp<SaasRoleUserV2DTO> page = saasRoleUserRelationService.page(from(req));
|
||||
|
||||
return ApiResult.success(PageResp.<RoleUserResp>builder()
|
||||
.total(page.getTotal())
|
||||
.size(page.getSize())
|
||||
.current(page.getCurrent())
|
||||
.data(page.getData().stream()
|
||||
.map(this::from)
|
||||
.collect(Collectors.toList()))
|
||||
.build());
|
||||
}
|
||||
|
||||
private PageRoleUserRelationParam from(PageRoleUserReq req) {
|
||||
PageRoleUserRelationParam result = PageRoleUserRelationParam.builder().build();
|
||||
|
||||
BeanUtils.copyProperties(req, result);
|
||||
|
||||
result.setNeedUsers(true);
|
||||
|
||||
result.setRoleTypes(Optional.ofNullable(req.getRoleTypes())
|
||||
.map(e -> e.stream()
|
||||
.map(roleType -> RoleTypeEnum.valueOf(roleType.name()))
|
||||
.collect(Collectors.toSet()))
|
||||
.orElse(null));
|
||||
|
||||
result.setRoleIds(Optional.ofNullable(req.getRoleIds())
|
||||
.map(Lists::newArrayList)
|
||||
.orElse(null));
|
||||
|
||||
result.setWorkspaceOuPairs(Optional.ofNullable(req.getWorkspaceOuPairs())
|
||||
.map(e -> e.stream()
|
||||
.map(f -> ListRoleUserRelationParam.WorkspaceOuPair.builder()
|
||||
.workspaceId(f.getWorkspaceId())
|
||||
.ouId(f.getOuId())
|
||||
.build())
|
||||
.collect(Collectors.toList()))
|
||||
.orElse(null));
|
||||
return result;
|
||||
}
|
||||
|
||||
private RoleUserResp from(SaasRoleUserV2DTO saasRoleUserV2DTO) {
|
||||
RoleUserResp result = RoleUserResp.builder().build();
|
||||
|
||||
BeanUtils.copyProperties(saasRoleUserV2DTO, result);
|
||||
|
||||
result.setPersonId(saasRoleUserV2DTO.getSaasRoleUser().getPersonId());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -51,7 +51,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@ -128,11 +127,19 @@ public class SaasRoleUserRelationServiceImpl extends ServiceImpl<SaasRoleUserRel
|
||||
});
|
||||
}
|
||||
|
||||
Set<Long> roleIds = resolveRoleIds(param);
|
||||
if (!CollectionUtils.isEmpty(param.getRoleCodes()) && CollectionUtils.isEmpty(roleIds)) {
|
||||
Set<Long> roleIdsByRoleCodes = resolveRoleIdsByRoleCodes(param);
|
||||
if (!CollectionUtils.isEmpty(param.getRoleCodes()) && CollectionUtils.isEmpty(roleIdsByRoleCodes)) {
|
||||
return param.toEmpty();
|
||||
}
|
||||
wrapper.in(!CollectionUtils.isEmpty(roleIds), "role_id", roleIds);
|
||||
|
||||
Set<Long> roleIdsByRoleTypes = resolveRoleIdsByRoleTypes(param);
|
||||
if (!CollectionUtils.isEmpty(param.getRoleTypes()) && CollectionUtils.isEmpty(roleIdsByRoleTypes)) {
|
||||
return param.toEmpty();
|
||||
}
|
||||
|
||||
wrapper.in(!CollectionUtils.isEmpty(roleIdsByRoleCodes), "role_id", roleIdsByRoleCodes);
|
||||
|
||||
wrapper.in(!CollectionUtils.isEmpty(roleIdsByRoleTypes), "role_id", roleIdsByRoleTypes);
|
||||
|
||||
assembleBatchPersonWrapper(param, wrapper);
|
||||
|
||||
@ -201,26 +208,16 @@ public class SaasRoleUserRelationServiceImpl extends ServiceImpl<SaasRoleUserRel
|
||||
mqProducer.send(event);
|
||||
}
|
||||
|
||||
private Set<Long> resolveRoleIds(PageRoleUserRelationParam param) {
|
||||
private Set<Long> resolveRoleIdsByRoleCodes(PageRoleUserRelationParam param) {
|
||||
if (CollectionUtils.isEmpty(param.getRoleCodes())) {
|
||||
return Optional.ofNullable(param.getRoleIds())
|
||||
.map(Sets::newHashSet)
|
||||
.orElseGet(Sets::newHashSet);
|
||||
return Collections.emptySet();
|
||||
}
|
||||
ListRoleReq listSaasRoleParam = ListRoleReq.builder()
|
||||
.roleCodes(param.getRoleCodes())
|
||||
.build();
|
||||
Set<Long> roleIds = roleService.list(listSaasRoleParam).stream()
|
||||
return roleService.list(listSaasRoleParam).stream()
|
||||
.map(SaasRoleRes::getId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
if (CollectionUtils.isEmpty(param.getRoleIds())) {
|
||||
return roleIds;
|
||||
}
|
||||
|
||||
return param.getRoleIds().stream()
|
||||
.filter(roleIds::contains)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private Map<Long, SaasRoleUserV2DTO.SaasRoleUser> listSaasRoleUser(PageRoleUserRelationParam param,
|
||||
@ -607,4 +604,19 @@ public class SaasRoleUserRelationServiceImpl extends ServiceImpl<SaasRoleUserRel
|
||||
doUpdateWorkspaceUserRoles(g.getIdentityId(), g.getIdentityType(), g.getUpdateRoleIds(), g.getWorkspaceId(), g.getOuId(), g.getJobType());
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
private Set<Long> resolveRoleIdsByRoleTypes(PageRoleUserRelationParam param) {
|
||||
if (CollectionUtils.isEmpty(param.getRoleTypes())) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
ListRoleReq listSaasRoleParam = ListRoleReq.builder()
|
||||
.roleTypes(param.getRoleTypes().stream()
|
||||
.map(RoleTypeEnum::getValue)
|
||||
.collect(Collectors.toList()))
|
||||
.build();
|
||||
return roleService.list(listSaasRoleParam).stream()
|
||||
.map(SaasRoleRes::getId)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,191 @@
|
||||
package cn.axzo.tyr.server.controller.v2;
|
||||
|
||||
import cn.axzo.apollo.core.web.Result;
|
||||
import cn.axzo.apollo.workspace.api.workspace.WorkspaceApi;
|
||||
import cn.axzo.apollo.workspace.api.workspace.res.SimpleWorkspaceRes;
|
||||
import cn.axzo.basics.profiles.api.UserProfileServiceApi;
|
||||
import cn.axzo.basics.profiles.dto.basic.PersonProfileDto;
|
||||
import cn.axzo.tyr.base.BaseTest;
|
||||
import cn.axzo.tyr.base.MysqlDataLoader;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SuperAminInfoResp;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.SuperAdminParam;
|
||||
import cn.axzo.tyr.feign.enums.RoleTypeEnum;
|
||||
import cn.axzo.tyr.feign.req.PageRoleUserReq;
|
||||
import cn.axzo.tyr.feign.resp.RoleUserResp;
|
||||
import cn.axzo.tyr.server.service.SaasRoleUserService;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
class RoleUserV2ControllerTest extends BaseTest {
|
||||
@Autowired
|
||||
private MysqlDataLoader mysqlDataLoader;
|
||||
@Autowired
|
||||
private RoleUserV2Controller roleUserV2Controller;
|
||||
@Autowired
|
||||
private SaasRoleUserService saasRoleUserService;
|
||||
@Autowired
|
||||
private WorkspaceApi workspaceApi;
|
||||
@Autowired
|
||||
private UserProfileServiceApi userProfileServiceApi;
|
||||
|
||||
@BeforeEach
|
||||
@Override
|
||||
public void setup() {
|
||||
super.setup();
|
||||
mysqlDataLoader.loadFromClassName(getClass().getSimpleName());
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
void page() {
|
||||
List<SimpleWorkspaceRes> simpleWorkspaceRes = Lists.newArrayList(SimpleWorkspaceRes.builder()
|
||||
.type(2)
|
||||
.build());
|
||||
Mockito.when(workspaceApi.getListV2(Mockito.any()))
|
||||
.thenReturn(new Result(200, "sucess", simpleWorkspaceRes));
|
||||
|
||||
List<PersonProfileDto> personProfileDtos = org.assertj.core.util.Lists.newArrayList();
|
||||
PersonProfileDto personProfileDto = new PersonProfileDto();
|
||||
personProfileDto.setId(24510L);
|
||||
personProfileDto.setRealName("测试名字");
|
||||
personProfileDtos.add(personProfileDto);
|
||||
Mockito.when(userProfileServiceApi.postPersonProfiles(Mockito.any()))
|
||||
.thenReturn(CommonResponse.success(personProfileDtos));
|
||||
|
||||
// old
|
||||
List<SuperAminInfoResp> superAminInfoResps = saasRoleUserService.superAdminList(SuperAdminParam.builder()
|
||||
.workspaceId(3L)
|
||||
.ouId(4L)
|
||||
.build());
|
||||
Assertions.assertEquals(superAminInfoResps.size(), 1);
|
||||
Assertions.assertEquals(superAminInfoResps.get(0).getIdentityId(), 40L);
|
||||
Assertions.assertEquals(superAminInfoResps.get(0).getIdentityType(), 3);
|
||||
Assertions.assertEquals(superAminInfoResps.get(0).getWorkspaceId(), 3L);
|
||||
Assertions.assertEquals(superAminInfoResps.get(0).getOuId(), 4L);
|
||||
Assertions.assertEquals(superAminInfoResps.get(0).getPersonId(), 2232L);
|
||||
// old
|
||||
|
||||
List<RoleUserResp> data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.workspaceId(3L)
|
||||
.ouId(4L)
|
||||
.roleTypes(Sets.newHashSet(RoleTypeEnum.SUPER_ADMIN))
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 1);
|
||||
Assertions.assertEquals(data.get(0).getIdentityId(), 40L);
|
||||
Assertions.assertEquals(data.get(0).getIdentityType(), 3);
|
||||
Assertions.assertEquals(data.get(0).getWorkspaceId(), 3L);
|
||||
Assertions.assertEquals(data.get(0).getOuId(), 4L);
|
||||
Assertions.assertEquals(data.get(0).getPersonId(), 2232L);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleIds(Sets.newHashSet(101100L))
|
||||
.workspaceId(3L)
|
||||
.ouId(4L)
|
||||
.roleTypes(Sets.newHashSet(RoleTypeEnum.SUPER_ADMIN))
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 0);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleIds(Sets.newHashSet(101101L))
|
||||
.workspaceId(3L)
|
||||
.ouId(4L)
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 1);
|
||||
Assertions.assertEquals(data.get(0).getIdentityId(), 40L);
|
||||
Assertions.assertEquals(data.get(0).getIdentityType(), 3);
|
||||
Assertions.assertEquals(data.get(0).getWorkspaceId(), 3L);
|
||||
Assertions.assertEquals(data.get(0).getOuId(), 4L);
|
||||
Assertions.assertEquals(data.get(0).getPersonId(), 2232L);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleIds(Sets.newHashSet(101100L))
|
||||
.roleCodes(Sets.newHashSet("sdf"))
|
||||
.workspaceId(3L)
|
||||
.ouId(4L)
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 0);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleIds(Sets.newHashSet(101101L))
|
||||
.roleCodes(Sets.newHashSet("sdf"))
|
||||
.workspaceId(3L)
|
||||
.ouId(4L)
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 0);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleIds(Sets.newHashSet(101101L))
|
||||
.roleCodes(Sets.newHashSet("pro_superadmin"))
|
||||
.workspaceId(3L)
|
||||
.ouId(4L)
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 1);
|
||||
Assertions.assertEquals(data.get(0).getIdentityId(), 40L);
|
||||
Assertions.assertEquals(data.get(0).getIdentityType(), 3);
|
||||
Assertions.assertEquals(data.get(0).getWorkspaceId(), 3L);
|
||||
Assertions.assertEquals(data.get(0).getOuId(), 4L);
|
||||
Assertions.assertEquals(data.get(0).getPersonId(), 2232L);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleTypes(Sets.newHashSet(RoleTypeEnum.SUPER_ADMIN))
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 2);
|
||||
Assertions.assertEquals(data.get(0).getIdentityId(), 40L);
|
||||
Assertions.assertEquals(data.get(0).getIdentityType(), 3);
|
||||
Assertions.assertEquals(data.get(0).getWorkspaceId(), 8L);
|
||||
Assertions.assertEquals(data.get(0).getOuId(), 1L);
|
||||
Assertions.assertEquals(data.get(0).getPersonId(), 2232L);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleTypes(Sets.newHashSet(RoleTypeEnum.SUPER_ADMIN))
|
||||
.workspaceOuPairs(Lists.newArrayList(PageRoleUserReq.WorkspaceOuPair.builder().workspaceId(3L).ouId(4L).build(),
|
||||
PageRoleUserReq.WorkspaceOuPair.builder().workspaceId(8L).ouId(1L).build()))
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 2);
|
||||
Assertions.assertEquals(data.get(0).getIdentityId(), 40L);
|
||||
Assertions.assertEquals(data.get(0).getIdentityType(), 3);
|
||||
Assertions.assertEquals(data.get(0).getWorkspaceId(), 8L);
|
||||
Assertions.assertEquals(data.get(0).getOuId(), 1L);
|
||||
Assertions.assertEquals(data.get(0).getPersonId(), 2232L);
|
||||
|
||||
Assertions.assertEquals(data.get(1).getIdentityId(), 40L);
|
||||
Assertions.assertEquals(data.get(1).getIdentityType(), 3);
|
||||
Assertions.assertEquals(data.get(1).getWorkspaceId(), 3L);
|
||||
Assertions.assertEquals(data.get(1).getOuId(), 4L);
|
||||
Assertions.assertEquals(data.get(1).getPersonId(), 2232L);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleTypes(Sets.newHashSet(RoleTypeEnum.INIT))
|
||||
.workspaceOuPairs(Lists.newArrayList(PageRoleUserReq.WorkspaceOuPair.builder().workspaceId(3L).ouId(4L).build(),
|
||||
PageRoleUserReq.WorkspaceOuPair.builder().workspaceId(8L).ouId(1L).build()))
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 10);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,54 @@
|
||||
#-->DEFAULT
|
||||
|
||||
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 (101100, '超级管理员', '超级管理员', 'super_admin', 'ou_superadmin', 0, 0, 7, 1, 0, '2024-09-25 21:47:42', '2024-09-29 17:17:27', 2051297, 2051297, 1, 65535, 0, null, 0, '', 1, 0, 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 (101101, '超级管理员', '超级管理员', 'super_admin', 'pro_superadmin', 0, 0, 1, 2, 0, '2024-09-25 21:47:42', '2024-09-29 17:17:27', 2051297, 2051297, 1, 65535, 0, null, 0, '', 1, 0, 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 (101102, '超级管理员', '超级管理员', 'super_admin', 'oms_superadmin', 0, 0, 6, 6, 0, '2024-09-25 21:47:42', '2024-09-29 17:17:27', 2051297, 2051297, 1, 65535, 0, null, 0, '', 1, 0, 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 (101103, '超级管理员', '超级管理员', 'super_admin', 'zw_superadmin', 0, 0, 3, 3, 0, '2024-09-25 21:47:42', '2024-09-29 17:17:27', 2051297, 2051297, 1, 65535, 0, null, 0, '', 1, 0, 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 (100920, '工人管理', '', 'init', 'cms:zb_worker——management', -1, -1, 1, 2, 0, '2024-09-25 11:51:57', '2024-09-26 10:43:06', 154587, 154587, 1, 65535, 0, null, 0, '', 1, 4, 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 (100921, '查看组织架构', '', 'init', 'cms:zb_org_view', -1, -1, 1, 2, 0, '2024-09-25 11:51:57', '2024-09-26 10:43:06', 154587, 154587, 1, 65535, 0, null, 0, '', 1, 5, 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 (100923, '查看合约', '', 'init', 'cms:zb_contact_view', -1, -1, 1, 2, 0, '2024-09-25 11:51:58', '2024-09-26 10:43:06', 154587, 154587, 1, 65535, 0, null, 0, '', 1, 2, 1);
|
||||
|
||||
|
||||
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 (197519, 28801, 3414, 3, 24510, 3, 4, 0, 0, 0, '2024-01-18 16:36:16', '2024-09-29 17:16:39', 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 (183677, 40, 3415, 3, 2232, 8, 1, 0, 0, 0, '2023-10-06 15:13:35', '2024-09-29 17:16:39', 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 (1157571, 40, 101101, 3, 2232, 8, 1, 0, 0, 0, '2024-09-27 09:39:49', '2024-09-27 09:39:48', 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 (197520, 28802, 24425, 3, 24511, 3, 4, 0, 0, 0, '2024-01-18 16:36:16', '2024-09-29 17:16:39', 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 (1157572, 40, 101101, 3, 2232, 3, 4, 0, 0, 0, '2024-09-27 09:39:49', '2024-09-27 09:39:48', 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 (545048, 6, 100921, 3, 1827, 3, 4, 0, 0, 0, '2024-09-26 11:31:34', '2024-09-26 11:31:33', 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 (545301, 8, 100921, 3, 2107, 3, 4, 0, 0, 0, '2024-09-26 11:31:35', '2024-09-26 11:31:34', 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 (544214, 14, 100921, 3, 0, 3, 4, 0, 0, 0, '2024-09-26 11:31:32', '2024-09-26 11:31:32', 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 (545447, 17, 100921, 3, 3135, 3, 4, 0, 0, 0, '2024-09-26 11:31:35', '2024-09-26 11:31:34', 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 (545448, 17, 100920, 3, 3135, 3, 4, 0, 0, 0, '2024-09-26 11:31:35', '2024-09-26 11:31:34', 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 (544216, 18, 100921, 3, 0, 3, 4, 0, 0, 0, '2024-09-26 11:31:32', '2024-09-26 11:31:32', 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 (544451, 36, 100921, 3, 3470, 3, 4, 0, 0, 0, '2024-09-26 11:31:33', '2024-09-26 11:31:32', 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 (544452, 36, 100920, 3, 3470, 3, 4, 0, 0, 0, '2024-09-26 11:31:33', '2024-09-26 11:31:32', 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 (544453, 36, 100923, 3, 3470, 3, 4, 0, 0, 0, '2024-09-26 11:31:33', '2024-09-26 11:31:32', 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 (544687, 429, 100921, 3, 5267, 3, 4, 0, 0, 0, '2024-09-26 11:31:33', '2024-09-26 11:31:33', 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 (544688, 429, 100921, 3, 5267, 5, 6, 0, 0, 0, '2024-09-26 11:31:33', '2024-09-26 11:31:33', 0, 0, 2);
|
||||
|
||||
#-->SaasRoleUserRelationServiceImplTest.sql
|
||||
Loading…
Reference in New Issue
Block a user