feat:(feature/REQ-3282) 删除多余代码,扩展用户角色接口支持roleUserListV2相关功能
This commit is contained in:
parent
4181bcfa8e
commit
21be080fb3
@ -157,6 +157,25 @@ public class SaasRoleUserV2DTO {
|
||||
|
||||
private String roleCode;
|
||||
|
||||
private Date createAt;
|
||||
|
||||
private Date updateAt;
|
||||
|
||||
/**
|
||||
* 创建者
|
||||
*/
|
||||
private Long createBy;
|
||||
|
||||
/**
|
||||
* 更新者
|
||||
*/
|
||||
private Long updateBy;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 角色权限
|
||||
*/
|
||||
|
||||
@ -41,12 +41,18 @@ public class ListRoleUserRelationParam {
|
||||
@CriteriaField(field = "resourceType", operator = Operator.EQ)
|
||||
private Integer resourceType;
|
||||
|
||||
@CriteriaField(field = "resourceType", operator = Operator.IN)
|
||||
private Set<Integer> resourceTypes;
|
||||
|
||||
/**
|
||||
* 资源Id
|
||||
*/
|
||||
@CriteriaField(field = "resourceId", operator = Operator.EQ)
|
||||
private Long resourceId;
|
||||
|
||||
@CriteriaField(field = "resourceId", operator = Operator.IN)
|
||||
private Set<Long> resourceIds;
|
||||
|
||||
/**
|
||||
* 是否显示
|
||||
*/
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.tyr.feign.req;
|
||||
|
||||
import cn.axzo.tyr.feign.enums.FeatureResourceTypeEnum;
|
||||
import cn.axzo.tyr.feign.enums.IdentityTypeEnum;
|
||||
import cn.axzo.tyr.feign.enums.RoleTypeEnum;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -42,11 +43,13 @@ public class PageRoleUserReq {
|
||||
|
||||
/**
|
||||
* 角色code
|
||||
* 查询指定角色code对应的用户
|
||||
*/
|
||||
private Set<String> roleCodes;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
* 查询指定角色id对应的用户
|
||||
*/
|
||||
private Set<Long> roleIds;
|
||||
|
||||
@ -57,6 +60,8 @@ public class PageRoleUserReq {
|
||||
* init:初始化内置角色-标准角色
|
||||
* auto_own:虚拟角色(自定义权限使用)
|
||||
* common:自定义角色
|
||||
*
|
||||
* 查询指定角色类型的用户
|
||||
*/
|
||||
private Set<RoleTypeEnum> roleTypes;
|
||||
|
||||
@ -86,6 +91,69 @@ public class PageRoleUserReq {
|
||||
*/
|
||||
private IdentityTypeEnum identityType;
|
||||
|
||||
/**
|
||||
* 历史字段,资源类型
|
||||
*/
|
||||
private Set<Integer> resourceTypes;
|
||||
|
||||
/**
|
||||
* 历史字段,资源id
|
||||
*/
|
||||
private Set<Long> resourceIds;
|
||||
|
||||
/**
|
||||
* 是否显示
|
||||
* needRole = true时才有效,指定isDisplay值去查询对应的角色
|
||||
*/
|
||||
private Boolean isDisplay;
|
||||
|
||||
/**
|
||||
* 是否启用
|
||||
* needRole = true时才有效,指定enabled值去查询对应的角色
|
||||
*/
|
||||
private Boolean enabled;
|
||||
|
||||
/**
|
||||
* 是否需要用户信息:当前系统没有冗余名字,需要实时查询用户信息,比如名字
|
||||
*/
|
||||
private Boolean needUsers;
|
||||
|
||||
/**
|
||||
* 菜单组件id
|
||||
* needRole = true时才有效,根据指定featureResourceIds去查询角色关联的菜单组件等信息
|
||||
*/
|
||||
private Set<Long> featureResourceIds;
|
||||
|
||||
/**
|
||||
* 是否需要角色跟菜单组件的关联关系,不查询具体的菜单组件信息
|
||||
* needRole = true时才有效
|
||||
*/
|
||||
private Boolean needFeatureResourceRelation;
|
||||
|
||||
/**
|
||||
* 是否需要角色关联的菜单组件信息,saas_feature_recource的记录
|
||||
* needRole = true时才有效
|
||||
*/
|
||||
private Boolean needFeatureResources;
|
||||
|
||||
/**
|
||||
* needFeatureResourceRelation 或者 needFeatureResources = true时,根据指定的featureResourceTypes去过滤数据
|
||||
* 需要 needRole = true 且 needFeatureResourceRelation 或者 needFeatureResources = true时,才有效才会生效
|
||||
*/
|
||||
private Set<FeatureResourceTypeEnum> featureResourceTypes;
|
||||
|
||||
/**
|
||||
* needFeatureResourceRelation 或者 needFeatureResources = true时,根据指定的featureResourceTypes去过滤数据
|
||||
* 目前只有CMS端的新版本才冗余了端
|
||||
* 需要 needRole = true 且 needFeatureResourceRelation 或者 needFeatureResources = true时,才有效才会生效
|
||||
*/
|
||||
private String terminal;
|
||||
|
||||
/**
|
||||
* 批量配对的查询用户
|
||||
*/
|
||||
private Set<BatchPerson> batchPersons;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@ -101,4 +169,23 @@ public class PageRoleUserReq {
|
||||
*/
|
||||
private Long ouId;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public static class BatchPerson {
|
||||
private Long identityId;
|
||||
|
||||
/**
|
||||
* 身份类型 1:工人 2:班组长 3:从业人员 4:监管人员 5:运营人员
|
||||
*/
|
||||
private Integer identityType;
|
||||
|
||||
private Long workspaceId;
|
||||
|
||||
private Long ouId;
|
||||
|
||||
private Long personId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,10 +2,7 @@ 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.FeatureResourceType;
|
||||
import cn.axzo.tyr.client.model.enums.RolePermissionTagEnum;
|
||||
import cn.axzo.tyr.client.model.res.SaasRoleRes;
|
||||
import cn.axzo.tyr.client.model.roleuser.req.ListRoleUserRelationParam;
|
||||
import cn.axzo.tyr.feign.api.RoleApi;
|
||||
import cn.axzo.tyr.feign.enums.RoleTypeEnum;
|
||||
import cn.axzo.tyr.feign.req.PageRoleReq;
|
||||
@ -15,7 +12,8 @@ import cn.axzo.tyr.feign.resp.RoleGroupResp;
|
||||
import cn.axzo.tyr.feign.resp.RoleResp;
|
||||
import cn.axzo.tyr.feign.resp.RoleUserResp;
|
||||
import cn.axzo.tyr.server.service.RoleService;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -23,6 +21,7 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -48,19 +47,9 @@ public class RoleController implements RoleApi {
|
||||
}
|
||||
|
||||
private cn.axzo.tyr.client.model.req.PageRoleReq from(PageRoleReq req) {
|
||||
cn.axzo.tyr.client.model.req.PageRoleReq result = cn.axzo.tyr.client.model.req.PageRoleReq.builder().build();
|
||||
BeanUtils.copyProperties(req, result);
|
||||
result.setRoleIds(Optional.ofNullable(req.getRoleIds())
|
||||
.map(Lists::newArrayList)
|
||||
.orElse(null));
|
||||
|
||||
result.setWorkspaceIds(Optional.ofNullable(req.getWorkspaceIds())
|
||||
.map(Lists::newArrayList)
|
||||
.orElse(null));
|
||||
|
||||
result.setOuIds(Optional.ofNullable(req.getOuIds())
|
||||
.map(Lists::newArrayList)
|
||||
.orElse(null));
|
||||
cn.axzo.tyr.client.model.req.PageRoleReq result = JSON.parseObject(JSON.toJSONString(req),
|
||||
cn.axzo.tyr.client.model.req.PageRoleReq.class);
|
||||
|
||||
result.setRoleTypes(Optional.ofNullable(req.getRoleTypes())
|
||||
.map(e -> e.stream()
|
||||
@ -68,28 +57,11 @@ public class RoleController implements RoleApi {
|
||||
.collect(Collectors.toList()))
|
||||
.orElse(null));
|
||||
|
||||
result.setWorkspaceOuPairs(Optional.ofNullable(req.getWorkspaceOuPairs())
|
||||
.map(e -> e.stream()
|
||||
.map(pair -> {
|
||||
ListRoleUserRelationParam.WorkspaceOuPair workspaceOuPair = ListRoleUserRelationParam.WorkspaceOuPair.builder()
|
||||
.build();
|
||||
BeanUtils.copyProperties(pair, workspaceOuPair);
|
||||
return workspaceOuPair;
|
||||
})
|
||||
.collect(Collectors.toList()))
|
||||
.orElse(null));
|
||||
|
||||
result.setProductUnitTypes(req.getCooperateShipTypes());
|
||||
|
||||
result.setNeedPermission(req.getNeedFeatureResources());
|
||||
|
||||
result.setNeedPermissionRelation(req.getNeedFeatureResourceRelation());
|
||||
|
||||
result.setFeatureResourceTypes(Optional.ofNullable(req.getFeatureResourceTypes())
|
||||
.map(e -> e.stream()
|
||||
.map(f -> FeatureResourceType.valueOf(f.name()))
|
||||
.collect(Collectors.toList()))
|
||||
.orElse(null));
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -98,19 +70,9 @@ public class RoleController implements RoleApi {
|
||||
return;
|
||||
}
|
||||
|
||||
roleResp.setRoleFeatureResources(saasRoleRes.getSaasPermissions().stream()
|
||||
.map(permission -> {
|
||||
RoleFeatureResourceResp roleFeatureResourceResp = RoleFeatureResourceResp.builder().build();
|
||||
BeanUtils.copyProperties(permission, roleFeatureResourceResp);
|
||||
roleFeatureResourceResp.setTags(Optional.ofNullable(permission.getTags())
|
||||
.map(tags -> tags.stream()
|
||||
.map(RolePermissionTagEnum::getDesc)
|
||||
.collect(Collectors.toSet())
|
||||
)
|
||||
.orElse(null));
|
||||
return roleFeatureResourceResp;
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
List<RoleFeatureResourceResp> roleFeatureResources = JSONArray.parseArray(JSON.toJSONString(saasRoleRes.getSaasPermissions()),
|
||||
RoleFeatureResourceResp.class);
|
||||
roleResp.setRoleFeatureResources(roleFeatureResources);
|
||||
}
|
||||
|
||||
private void assembleRoleGroup(SaasRoleRes saasRoleRes, RoleResp roleResp) {
|
||||
@ -161,19 +123,9 @@ public class RoleController implements RoleApi {
|
||||
return;
|
||||
}
|
||||
|
||||
roleResp.setFeatureResourceRelations(saasRoleRes.getPermissionRelations().stream()
|
||||
.map(saasPermissionRelationRes -> {
|
||||
FeatureResourceRelationResp featureResourceRelationResp = FeatureResourceRelationResp.builder().build();
|
||||
BeanUtils.copyProperties(saasPermissionRelationRes, featureResourceRelationResp);
|
||||
featureResourceRelationResp.setTags(Optional.ofNullable(saasPermissionRelationRes.getTags())
|
||||
.map(tags -> tags.stream()
|
||||
.map(RolePermissionTagEnum::getDesc)
|
||||
.collect(Collectors.toSet())
|
||||
)
|
||||
.orElse(null));
|
||||
return featureResourceRelationResp;
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
List<FeatureResourceRelationResp> resourceRelationResps = JSONArray.parseArray(JSON.toJSONString(saasRoleRes.getPermissionRelations()),
|
||||
FeatureResourceRelationResp.class);
|
||||
roleResp.setFeatureResourceRelations(resourceRelationResps);
|
||||
}
|
||||
|
||||
private RoleResp from(SaasRoleRes saasRoleRes) {
|
||||
|
||||
@ -2,7 +2,6 @@ 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.req.PageSaasRoleGroupParam;
|
||||
import cn.axzo.tyr.client.model.res.SaasRoleGroupDTO;
|
||||
import cn.axzo.tyr.feign.api.RoleGroupApi;
|
||||
@ -10,13 +9,13 @@ import cn.axzo.tyr.feign.req.PageRoleGroupReq;
|
||||
import cn.axzo.tyr.feign.resp.RoleGroupResp;
|
||||
import cn.axzo.tyr.feign.resp.RoleResp;
|
||||
import cn.axzo.tyr.server.service.SaasRoleGroupService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
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
|
||||
@ -42,14 +41,7 @@ public class RoleGroupController implements RoleGroupApi {
|
||||
}
|
||||
|
||||
private PageSaasRoleGroupParam from(PageRoleGroupReq req) {
|
||||
PageSaasRoleGroupParam result = PageSaasRoleGroupParam.builder().build();
|
||||
BeanUtils.copyProperties(req, result);
|
||||
result.setRoleTypes(Optional.ofNullable(req.getRoleTypes())
|
||||
.map(e -> e.stream()
|
||||
.map(roleType -> RoleTypeEnum.valueOf(roleType.name()))
|
||||
.collect(Collectors.toSet()))
|
||||
.orElse(null));
|
||||
return result;
|
||||
return JSON.parseObject(JSON.toJSONString(req), PageSaasRoleGroupParam.class);
|
||||
}
|
||||
|
||||
private RoleGroupResp from(SaasRoleGroupDTO saasRoleGroupDTO) {
|
||||
|
||||
@ -3,17 +3,21 @@ 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.FeatureResourceRelationResp;
|
||||
import cn.axzo.tyr.feign.resp.RoleFeatureResourceResp;
|
||||
import cn.axzo.tyr.feign.resp.RoleResp;
|
||||
import cn.axzo.tyr.feign.resp.RoleUserResp;
|
||||
import cn.axzo.tyr.server.service.SaasRoleUserRelationService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@ -21,6 +25,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelation.NEW_FEATURE;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class RoleUserV2Controller implements RoleUserApi {
|
||||
@ -44,33 +50,22 @@ public class RoleUserV2Controller implements RoleUserApi {
|
||||
}
|
||||
|
||||
private PageRoleUserRelationParam from(PageRoleUserReq req) {
|
||||
PageRoleUserRelationParam result = PageRoleUserRelationParam.builder().build();
|
||||
PageRoleUserRelationParam result = JSON.parseObject(JSON.toJSONString(req),
|
||||
PageRoleUserRelationParam.class);
|
||||
|
||||
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())
|
||||
result.setFeatureIds(Optional.ofNullable(req.getFeatureResourceIds())
|
||||
.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));
|
||||
result.setPersonIds(Optional.ofNullable(req.getPersonIds())
|
||||
.map(Lists::newArrayList)
|
||||
.orElse(null));
|
||||
result.setNeedPermission(req.getNeedFeatureResources());
|
||||
|
||||
result.setNeedPermissionRelation(req.getNeedFeatureResourceRelation());
|
||||
|
||||
// 因为关联关系存在关联featureResource和feature两个表,且有冲突,用type区分的,只有type = NEW_FEATURE的数据补了端
|
||||
// 这个type对外不可知,也是临时的,后续只能关联featureResource,所以这里如果有terminal,则自动补上type = NEW_FEATURE
|
||||
if (StringUtils.isNotBlank(req.getTerminal())) {
|
||||
result.setType(NEW_FEATURE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -80,6 +75,7 @@ public class RoleUserV2Controller implements RoleUserApi {
|
||||
BeanUtils.copyProperties(saasRoleUserV2DTO, result);
|
||||
|
||||
result.setPersonId(saasRoleUserV2DTO.getSaasRoleUser().getPersonId());
|
||||
result.setRealName(saasRoleUserV2DTO.getSaasRoleUser().getRealName());
|
||||
|
||||
result.setRole(Optional.ofNullable(saasRoleUserV2DTO.getSaasRole())
|
||||
.map(e -> {
|
||||
@ -88,9 +84,31 @@ public class RoleUserV2Controller implements RoleUserApi {
|
||||
role.setRoleId(e.getId());
|
||||
role.setCooperateShipType(e.getProductUnitType());
|
||||
role.setOuId(e.getOwnerOuId());
|
||||
|
||||
assembleRoleFeatureResource(e, role);
|
||||
|
||||
assembleFeatureResourceRelation(e, role);
|
||||
return role;
|
||||
})
|
||||
.orElse(null));
|
||||
return result;
|
||||
}
|
||||
|
||||
private void assembleRoleFeatureResource(SaasRoleUserV2DTO.SaasRole fromSaasRole, RoleResp roleResp) {
|
||||
if (CollectionUtils.isEmpty(fromSaasRole.getSaasPermissions())) {
|
||||
return;
|
||||
}
|
||||
roleResp.setRoleFeatureResources(JSONArray.parseArray(JSON.toJSONString(fromSaasRole.getSaasPermissions()),
|
||||
RoleFeatureResourceResp.class));
|
||||
}
|
||||
|
||||
private void assembleFeatureResourceRelation(SaasRoleUserV2DTO.SaasRole saasRoleRes, RoleResp roleResp) {
|
||||
|
||||
if (CollectionUtils.isEmpty(saasRoleRes.getPermissionRelations())) {
|
||||
return;
|
||||
}
|
||||
|
||||
roleResp.setFeatureResourceRelations(JSONArray.parseArray(JSON.toJSONString(saasRoleRes.getPermissionRelations()),
|
||||
FeatureResourceRelationResp.class));
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,7 +18,6 @@ public interface SaasFeatureDao extends IService<SaasFeature> {
|
||||
|
||||
void updateChildrenPath(Long updater, String pathPrefix, String newPathPrefix);
|
||||
|
||||
List<SaasFeature> listByParentId(Long parentId);
|
||||
|
||||
void updateSort(Long permissionId, int switchIndex);
|
||||
|
||||
@ -31,7 +30,5 @@ public interface SaasFeatureDao extends IService<SaasFeature> {
|
||||
|
||||
List<SaasFeature> getChildByParentId(Long parentId);
|
||||
|
||||
List<SaasFeature> listAllFeature();
|
||||
|
||||
List<SaasFeature> listAllFeatureByTerminal(String terminal);
|
||||
}
|
||||
@ -58,13 +58,4 @@ public class SaasPageElementFeatureResourceRelationDao extends ServiceImpl<SaasP
|
||||
.set(Objects.nonNull(operatorId), SaasPageElementFeatureResourceRelation::getUpdateBy, operatorId)
|
||||
.update();
|
||||
}
|
||||
|
||||
public void updateGroupCode(String oldGroupCode, String newGroupCode, String terminal) {
|
||||
lambdaUpdate()
|
||||
.eq(SaasPageElementFeatureResourceRelation::getIsDelete, DeleteEnum.NORMAL.getValue())
|
||||
.eq(SaasPageElementFeatureResourceRelation::getTerminal, terminal)
|
||||
.eq(SaasPageElementFeatureResourceRelation::getPageElementCode, oldGroupCode)
|
||||
.set(SaasPageElementFeatureResourceRelation::getPageElementCode, newGroupCode)
|
||||
.update();
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,23 +42,6 @@ public class SaasRoleUserRelationDao extends ServiceImpl<SaasRoleUserRelationMap
|
||||
.list();
|
||||
}
|
||||
|
||||
public List<SaasRoleUserRelation> queryByPersonId(Long personId, Long workspaceId, Long ouId) {
|
||||
return this.lambdaQuery()
|
||||
.eq(SaasRoleUserRelation::getNaturalPersonId, personId)
|
||||
.eq(null != workspaceId, SaasRoleUserRelation::getWorkspaceId, workspaceId)
|
||||
.eq(null != ouId, SaasRoleUserRelation::getOuId, ouId)
|
||||
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
||||
.list();
|
||||
}
|
||||
|
||||
|
||||
public void deleteByRoleId(List<Long> roleId) {
|
||||
lambdaUpdate()
|
||||
.in(SaasRoleUserRelation::getRoleId,roleId)
|
||||
.set(BaseEntity::getIsDelete,TableIsDeleteEnum.DELETE.value)
|
||||
.update();
|
||||
}
|
||||
|
||||
public void deleteById(List<Long> ids) {
|
||||
if (CollUtil.isEmpty(ids)) {
|
||||
return;
|
||||
|
||||
@ -28,11 +28,6 @@ public class SaasFeatureDaoImpl extends ServiceImpl<SaasFeatureMapper, SaasFeatu
|
||||
this.baseMapper.updateChildrenPath(updater, pathPrefix, newPathPrefix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SaasFeature> listByParentId(Long parentId) {
|
||||
return this.baseMapper.selectList(new LambdaQueryWrapper<SaasFeature>().eq(SaasFeature::getParentId, parentId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSort(Long permissionId, int sort) {
|
||||
this.update(new LambdaUpdateWrapper<SaasFeature>().set(SaasFeature::getSort, sort).eq(SaasFeature::getId, permissionId));
|
||||
@ -61,11 +56,6 @@ public class SaasFeatureDaoImpl extends ServiceImpl<SaasFeatureMapper, SaasFeatu
|
||||
.eq(BaseEntity::getIsDelete,TableIsDeleteEnum.NORMAL).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SaasFeature> listAllFeature() {
|
||||
return lambdaQuery().eq(BaseEntity::getIsDelete, 0).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SaasFeature> listAllFeatureByTerminal(String terminal) {
|
||||
return lambdaQuery()
|
||||
|
||||
@ -2,8 +2,6 @@ package cn.axzo.tyr.server.repository.mapper;
|
||||
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeatureResource;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -15,8 +13,4 @@ import org.apache.ibatis.annotations.Update;
|
||||
*/
|
||||
public interface SaasFeatureResourceMapper extends BaseMapper<SaasFeatureResource> {
|
||||
|
||||
@Update("UPDATE saas_feature_resource" +
|
||||
" SET path = REPLACE(path, #{oldPath}, #{newPath})" +
|
||||
" WHERE is_delete = 0 AND path LIKE CONCAT(#{oldPath}, '%')")
|
||||
void replacePath(@Param("oldPath") String oldPath, @Param("newPath") String newPath);
|
||||
}
|
||||
|
||||
@ -25,8 +25,6 @@ public interface SaasRoleMapper extends BaseMapper<SaasRole> {
|
||||
Page<SaasRole> pageQueryForOUWorkspace(IPage<SaasRole> page, Long ouId, Long workspaceId, Integer workspaceJoinType,
|
||||
Integer superAdminWorkspaceType);
|
||||
|
||||
List<SaasRole> listForOUWorkspace(Long ouId, Long workspaceId, Integer workspaceJoinType);
|
||||
|
||||
List<RoleFeatureRelation> listFeatureByIds(@Param("roleIds") Set<Long> roleIds, @Param("featureIds") Set<Long> featureIds);
|
||||
}
|
||||
|
||||
|
||||
@ -51,14 +51,6 @@ public interface PermissionPointService {
|
||||
|
||||
List<PermissionPointTreeNode> queryList(PermissionPointListQueryRequest request);
|
||||
|
||||
/**
|
||||
* 指定条件查询出子级的所以父级
|
||||
* 并将父级平铺返回
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
List<PermissionPointTreeNode> listTreeNodesFlatChild(PermissionPointTreeQueryReq request);
|
||||
|
||||
/** 根据code查询权限点, terminal可为空 **/
|
||||
List<SaasFeature> listNodeWithChildrenByCode(String featureCode, String terminal);
|
||||
|
||||
|
||||
@ -42,8 +42,6 @@ public interface SaasRoleUserService {
|
||||
*/
|
||||
List<SuperAminInfoResp> batchSuperAdminList(List<SuperAdminParam> param);
|
||||
|
||||
List<SaasRoleUserRelation> listByRoleIds(List<Long> roleIds, Long ouId, Long workspaceId);
|
||||
|
||||
/**
|
||||
* 删除单位参与的工作台的所有的人员与角色。 目前主要是用于移除参与单位的地方
|
||||
*/
|
||||
|
||||
@ -14,9 +14,6 @@ import java.util.Set;
|
||||
|
||||
public interface WorkspaceProductService {
|
||||
|
||||
|
||||
List<WorkspaceProduct> listWorkspaceProduct(WorkspaceProductParam param);
|
||||
|
||||
/**
|
||||
* 从缓存中查询项目的产品
|
||||
* @param param
|
||||
|
||||
@ -659,18 +659,6 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<PermissionPointTreeNode> listTreeNodesFlatChild(PermissionPointTreeQueryReq request) {
|
||||
List<PermissionPointTreeNode> permissionPointTreeNodes = listTreeNodes(request);
|
||||
//将树型结构打平
|
||||
return permissionPointTreeNodes.stream().map(e -> {
|
||||
e.flatChildren();
|
||||
return e.getChildren();
|
||||
}).flatMap(List::stream).collect(Collectors.toList());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SaasFeature> listNodeWithChildrenByCode(String featureCode, String terminal) {
|
||||
return listNodeWithChildrenByCodes(Collections.singletonList(featureCode), terminal);
|
||||
|
||||
@ -1558,6 +1558,7 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
|
||||
.featureIds(param.getFeatureIds())
|
||||
.terminal(param.getTerminal())
|
||||
.type(NEW_FEATURE)
|
||||
.featureResourceTypes(param.getFeatureResourceTypes())
|
||||
.build())
|
||||
.stream()
|
||||
.filter(e -> CollectionUtils.isNotEmpty(e.getPgroupPermissionRelations()))
|
||||
|
||||
@ -367,29 +367,6 @@ public class RoleUserService implements SaasRoleUserService {
|
||||
.eq(SaasRoleUserRelation::getOuId, ouId));
|
||||
}
|
||||
|
||||
private SaasRole findSuperAdmin(Long workspaceId, Long ouId, Integer workspaceType) {
|
||||
//优先取租户超管 没有再取标准角色超管
|
||||
//租户超管
|
||||
return saasRoleDao
|
||||
.findRoleByTypeAndWorkspaceIdAndOuId(RoleTypeEnum.SUPER_ADMIN.getValue(),
|
||||
workspaceId, ouId);
|
||||
// if (superAdmin != null) {
|
||||
// return superAdmin;
|
||||
// }
|
||||
//标准角超管
|
||||
// String superAdminCode = superAdminCodes.get(workspaceType);
|
||||
// if (StrUtil.isBlank(superAdminCode)) {
|
||||
// throw new ServiceException("租户类型[" + workspaceType + "]未配置超管编码");
|
||||
// }
|
||||
// return saasRoleDao.lambdaQuery().eq(SaasRole::getRoleCode, superAdminCode).one();
|
||||
}
|
||||
|
||||
private void checkRoleName(String name, Long workspaceId, Long ouId) {
|
||||
List<SaasRole> saasRoles = saasRoleDao.listCommonRoleByNameAndWorkspaceIdAndOuId(name,
|
||||
workspaceId, ouId);
|
||||
AssertUtil.isEmpty(saasRoles, "已存在相同的角色名称,请更换角色名称");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SuperAminInfoResp> batchSuperAdminList(List<SuperAdminParam> param) {
|
||||
// 兼容上线历史数据还没清洗的间隙,查询超管角色需要根据workspaceId和预设的超管一起
|
||||
@ -467,17 +444,6 @@ public class RoleUserService implements SaasRoleUserService {
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SaasRoleUserRelation> listByRoleIds(List<Long> roleIds, Long ouId, Long workspaceId) {
|
||||
if (CollectionUtil.isEmpty(roleIds)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return roleUserRelationDao.list(new LambdaQueryWrapper<SaasRoleUserRelation>()
|
||||
.eq(Objects.nonNull(ouId), SaasRoleUserRelation::getOuId, ouId)
|
||||
.eq(Objects.nonNull(workspaceId), SaasRoleUserRelation::getWorkspaceId, workspaceId)
|
||||
.in(SaasRoleUserRelation::getRoleId, roleIds));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void removeWorkspaceOuAllUserRole(Long workspaceId, Long ouId) {
|
||||
|
||||
@ -66,75 +66,6 @@ public class WorkspaceProductServiceImpl implements WorkspaceProductService {
|
||||
|
||||
private static final String WORKSPACE_PRODUCT_KEY = "workspace:product";
|
||||
|
||||
@Override
|
||||
public List<WorkspaceProduct> listWorkspaceProduct(WorkspaceProductParam param) {
|
||||
|
||||
if (CollectionUtils.isEmpty(param.getWorkspaceIds())) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<ServicePkgDetailRes> servicePkgDetailRes = RpcInternalUtil.rpcListProcessor(() -> servicePkgClient.getServicePkgDetailBySpaceId(param.getWorkspaceIds()),
|
||||
"查询项目的产品", param.getWorkspaceIds()).getData();
|
||||
if (CollectionUtil.isEmpty(servicePkgDetailRes)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
Set<Long> productIds = servicePkgDetailRes.stream()
|
||||
.map(ServicePkgDetailRes::getProducts)
|
||||
.filter(CollectionUtil::isNotEmpty)
|
||||
.flatMap(List::stream)
|
||||
.map(ServicePkgProduct::getProductId)
|
||||
.collect(Collectors.toSet());
|
||||
if (CollectionUtil.isEmpty(productIds)) {
|
||||
log.warn("no product found for workspace :{}", param.getWorkspaceIds());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// 已被删除产品过滤一层
|
||||
productIds = productModuleDao.listByIds(productIds)
|
||||
.stream()
|
||||
.filter(productModule -> Objects.equals(productModule.getIsDelete(),0L))
|
||||
.map(BaseEntity::getId)
|
||||
.collect(Collectors.toSet());
|
||||
if (CollectionUtil.isEmpty(productIds)) {
|
||||
log.warn("all product is deleted for workspace :{}", param.getWorkspaceIds());
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
ProductFeatureQuery productFeatureQuery = ProductFeatureQuery.builder()
|
||||
.productIds(productIds)
|
||||
.featureResourceTypes(param.getFeatureResourceTypes())
|
||||
.terminal(param.getTerminal())
|
||||
.type(param.getType())
|
||||
.featureIdPairs(param.getFeatureIdPairs())
|
||||
.build();
|
||||
Map<Long, List<SaasProductModuleFeatureRelation>> saasProductModuleFeatureRelations = productFeatureRelationService.queryOnCondition(productFeatureQuery).stream()
|
||||
.collect(Collectors.groupingBy(SaasProductModuleFeatureRelation::getProductModuleId));
|
||||
|
||||
return servicePkgDetailRes.stream()
|
||||
.filter(e -> CollectionUtils.isNotEmpty(e.getProducts()))
|
||||
.map(e -> {
|
||||
List<SaasProductModuleFeatureRelation> features = e.getProducts().stream()
|
||||
.map(product -> saasProductModuleFeatureRelations.get(product.getProductId()))
|
||||
.filter(Objects::nonNull)
|
||||
.flatMap(Collection::stream)
|
||||
.collect(Collectors.toList());
|
||||
return Pair.of(e.getSpaceId(), features);
|
||||
})
|
||||
// 考虑一个项目有多个服务包的情况
|
||||
.collect(Collectors.toMap(Pair::getKey, Pair::getValue, (f, s) -> {
|
||||
f.addAll(s);
|
||||
return f;
|
||||
}))
|
||||
.entrySet()
|
||||
.stream()
|
||||
.map(e -> WorkspaceProduct.builder()
|
||||
.workspaceId(e.getKey())
|
||||
.saasProductModuleFeatureRelations(e.getValue())
|
||||
.build())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WorkspaceProduct> listWorkspaceProductCached(WorkspaceProductParam param) {
|
||||
if (CollectionUtils.isEmpty(param.getWorkspaceIds())) {
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
package cn.axzo.tyr.server.util;
|
||||
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class IdPathUtil {
|
||||
|
||||
private static final String PATH_SPLIT = "/";
|
||||
|
||||
public static Set<Long> featurePathsToIds(Set<String> paths) {
|
||||
if (CollectionUtils.isEmpty(paths)) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
return paths.stream().map(e -> {
|
||||
String[] split = e.split(PATH_SPLIT);
|
||||
return Arrays.stream(split).filter(StringUtils::hasText).map(Long::parseLong)
|
||||
.collect(Collectors.toSet());
|
||||
}).reduce(new HashSet<>(), (a, b) -> {
|
||||
a.addAll(b);
|
||||
return a;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,7 +5,6 @@ import cn.axzo.tyr.client.model.data.object.AttributePermissionBO;
|
||||
import cn.axzo.tyr.client.model.data.object.DataObjectRuleBO;
|
||||
import cn.axzo.tyr.client.model.data.object.DefaultDataObjectRuleBO;
|
||||
import cn.axzo.tyr.client.model.req.CreateDataObjectReq;
|
||||
import cn.axzo.tyr.client.model.req.EditDataObjectReq;
|
||||
import cn.axzo.tyr.client.model.res.DataObjectRes;
|
||||
import cn.axzo.tyr.server.repository.entity.DataObject;
|
||||
import cn.axzo.tyr.server.repository.entity.DataObjectAttr;
|
||||
@ -20,7 +19,6 @@ import org.mapstruct.Named;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Mapper
|
||||
@ -30,8 +28,6 @@ public interface DataObjectMapper {
|
||||
DataObject createReq2DataObject(CreateDataObjectReq req);
|
||||
|
||||
|
||||
DataObject editReq2DataObject(EditDataObjectReq req);
|
||||
|
||||
DataObjectRes dataObject2DataObjectRes(DataObject req);
|
||||
|
||||
DataObjectAttr attributeBO2DataObjectAttr(AttributeBO bo);
|
||||
@ -67,12 +63,8 @@ public interface DataObjectMapper {
|
||||
|
||||
List<DataObjectRule> defaultRuleBOs2Rules(List<DefaultDataObjectRuleBO> bo);
|
||||
|
||||
List<DefaultDataObjectRuleBO> rules2defaultRuleBOs(List<DataObjectRule> bo);
|
||||
|
||||
List<DataObjectRule> ruleBOs2Rules(List<DataObjectRuleBO> bo);
|
||||
|
||||
List<DataObjectRuleBO> rules2RuleBOs(List<DataObjectRule> bo);
|
||||
|
||||
List<AttributePermissionBO> ruleAttrs2AttrPermissionBOs(List<DataObjectRuleAttr> bo);
|
||||
|
||||
@Named("mapRelationId2RuleScope")
|
||||
|
||||
@ -159,31 +159,31 @@ class RoleControllerTest extends BaseTest {
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(0).getId(), 153L);
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(0).getUniCode(), "oms:menu_page");
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(0).getTags().size(), 1);
|
||||
Assertions.assertTrue(roleResps.get(0).getRoleFeatureResources().get(0).getTags().contains(RolePermissionTagEnum.JOINED.getDesc()));
|
||||
Assertions.assertTrue(roleResps.get(0).getRoleFeatureResources().get(0).getTags().contains(RolePermissionTagEnum.JOINED.name()));
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(0).getTerminal(), "NT_OMS_WEB");
|
||||
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(1).getId(), 466L);
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(1).getUniCode(), "oms:imConfig_page");
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(1).getTags().size(), 1);
|
||||
Assertions.assertTrue(roleResps.get(0).getRoleFeatureResources().get(1).getTags().contains(RolePermissionTagEnum.JOINED.getDesc()));
|
||||
Assertions.assertTrue(roleResps.get(0).getRoleFeatureResources().get(1).getTags().contains(RolePermissionTagEnum.JOINED.name()));
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(1).getTerminal(), "NT_OMS_WEB");
|
||||
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(2).getId(), 467L);
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(2).getUniCode(), "oms:im_robot_page");
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(2).getTags().size(), 1);
|
||||
Assertions.assertTrue(roleResps.get(0).getRoleFeatureResources().get(2).getTags().contains(RolePermissionTagEnum.JOINED.getDesc()));
|
||||
Assertions.assertTrue(roleResps.get(0).getRoleFeatureResources().get(2).getTags().contains(RolePermissionTagEnum.JOINED.name()));
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(2).getTerminal(), "NT_OMS_WEB");
|
||||
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(3).getId(), 469L);
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(3).getUniCode(), "oms:msgPush_page");
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(3).getTags().size(), 1);
|
||||
Assertions.assertTrue(roleResps.get(0).getRoleFeatureResources().get(3).getTags().contains(RolePermissionTagEnum.JOINED.getDesc()));
|
||||
Assertions.assertTrue(roleResps.get(0).getRoleFeatureResources().get(3).getTags().contains(RolePermissionTagEnum.JOINED.name()));
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(3).getTerminal(), "NT_OMS_WEB");
|
||||
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(4).getId(), 693L);
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(4).getUniCode(), "oms:detail_backPay_btn");
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(4).getTags().size(), 1);
|
||||
Assertions.assertTrue(roleResps.get(0).getRoleFeatureResources().get(4).getTags().contains(RolePermissionTagEnum.JOINED.getDesc()));
|
||||
Assertions.assertTrue(roleResps.get(0).getRoleFeatureResources().get(4).getTags().contains(RolePermissionTagEnum.JOINED.name()));
|
||||
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().get(4).getTerminal(), "NT_OMS_WEB");
|
||||
|
||||
|
||||
@ -270,7 +270,7 @@ class RoleControllerTest extends BaseTest {
|
||||
Assertions.assertEquals(roleResps.get(0).getFeatureResourceRelations().get(0).getType(), 1);
|
||||
Assertions.assertEquals(roleResps.get(0).getFeatureResourceRelations().get(0).getFeatureType(), 2);
|
||||
Assertions.assertEquals(roleResps.get(0).getFeatureResourceRelations().get(0).getTags().size(), 1);
|
||||
Assertions.assertTrue(roleResps.get(0).getFeatureResourceRelations().get(0).getTags().contains(RolePermissionTagEnum.JOINED.getDesc()));
|
||||
Assertions.assertTrue(roleResps.get(0).getFeatureResourceRelations().get(0).getTags().contains(RolePermissionTagEnum.JOINED.name()));
|
||||
|
||||
|
||||
roleResps = roleController.page(PageRoleReq.builder()
|
||||
|
||||
@ -5,19 +5,24 @@ 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.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.base.BaseTest;
|
||||
import cn.axzo.tyr.base.MysqlDataLoader;
|
||||
import cn.axzo.tyr.client.common.enums.FeatureResourceType;
|
||||
import cn.axzo.tyr.client.model.enums.IdentityType;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserDTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SaasRoleUserV2DTO;
|
||||
import cn.axzo.tyr.client.model.roleuser.dto.SuperAminInfoResp;
|
||||
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.SuperAdminParam;
|
||||
import cn.axzo.tyr.feign.enums.FeatureResourceTypeEnum;
|
||||
import cn.axzo.tyr.feign.enums.IdentityTypeEnum;
|
||||
import cn.axzo.tyr.feign.enums.RolePermissionTagEnum;
|
||||
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.controller.roleuser.RoleUserController;
|
||||
import cn.axzo.tyr.server.service.SaasRoleUserRelationService;
|
||||
import cn.axzo.tyr.server.service.SaasRoleUserService;
|
||||
import cn.azxo.framework.common.model.CommonResponse;
|
||||
import com.google.common.collect.Lists;
|
||||
@ -33,6 +38,8 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelation.NEW_FEATURE;
|
||||
|
||||
class RoleUserV2ControllerTest extends BaseTest {
|
||||
@Autowired
|
||||
private MysqlDataLoader mysqlDataLoader;
|
||||
@ -46,6 +53,8 @@ class RoleUserV2ControllerTest extends BaseTest {
|
||||
private UserProfileServiceApi userProfileServiceApi;
|
||||
@Autowired
|
||||
private RoleUserController roleUserController;
|
||||
@Autowired
|
||||
private SaasRoleUserRelationService saasRoleUserRelationService;
|
||||
|
||||
@BeforeEach
|
||||
@Override
|
||||
@ -65,7 +74,7 @@ class RoleUserV2ControllerTest extends BaseTest {
|
||||
|
||||
List<PersonProfileDto> personProfileDtos = org.assertj.core.util.Lists.newArrayList();
|
||||
PersonProfileDto personProfileDto = new PersonProfileDto();
|
||||
personProfileDto.setId(24510L);
|
||||
personProfileDto.setId(2232L);
|
||||
personProfileDto.setRealName("测试名字");
|
||||
personProfileDtos.add(personProfileDto);
|
||||
Mockito.when(userProfileServiceApi.postPersonProfiles(Mockito.any()))
|
||||
@ -97,6 +106,23 @@ class RoleUserV2ControllerTest extends BaseTest {
|
||||
Assertions.assertEquals(data.get(0).getWorkspaceId(), 3L);
|
||||
Assertions.assertEquals(data.get(0).getOuId(), 4L);
|
||||
Assertions.assertEquals(data.get(0).getPersonId(), 2232L);
|
||||
Assertions.assertNull(data.get(0).getRealName());
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.workspaceIds(Sets.newHashSet(3L))
|
||||
.ouIds(Sets.newHashSet(4L))
|
||||
.roleTypes(Sets.newHashSet(RoleTypeEnum.SUPER_ADMIN))
|
||||
.needUsers(true)
|
||||
.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);
|
||||
Assertions.assertEquals(data.get(0).getRealName(), "测试名字");
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleIds(Sets.newHashSet(101100L))
|
||||
@ -453,7 +479,7 @@ class RoleUserV2ControllerTest extends BaseTest {
|
||||
Assertions.assertEquals(data.get(0).getResourceType(), 0);
|
||||
Assertions.assertTrue(data.get(0).getRole().getIsDisplay());
|
||||
Assertions.assertTrue(data.get(0).getRole().getEnabled());
|
||||
Assertions.assertEquals(LocalDateTime.ofInstant(listApiResult.get(0).getUpdateAt().toInstant(), ZoneId.systemDefault()),
|
||||
Assertions.assertEquals(LocalDateTime.ofInstant(data.get(0).getUpdateAt().toInstant(), ZoneId.systemDefault()),
|
||||
LocalDateTime.of(2024, 9, 26, 11, 31, 32));
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
@ -613,5 +639,452 @@ class RoleUserV2ControllerTest extends BaseTest {
|
||||
Assertions.assertTrue(data.get(0).getRole().getEnabled());
|
||||
Assertions.assertEquals(LocalDateTime.ofInstant(data.get(0).getUpdateAt().toInstant(), ZoneId.systemDefault()),
|
||||
LocalDateTime.of(2024, 9, 26, 11, 31, 32));
|
||||
|
||||
// old
|
||||
|
||||
List<SaasRoleUserV2DTO> saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.resourceType(1)
|
||||
.build());
|
||||
Assertions.assertTrue(saasRoleUsers.isEmpty());
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.resourceType(0)
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 13);
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.resourceId(1L)
|
||||
.build());
|
||||
Assertions.assertTrue(saasRoleUsers.isEmpty());
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.resourceId(0L)
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 13);
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.isDisplay(true)
|
||||
.needRole(true)
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 13);
|
||||
Assertions.assertNotNull(saasRoleUsers.get(0).getSaasRole());
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.isDisplay(false)
|
||||
.needRole(true)
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 13);
|
||||
Assertions.assertNull(saasRoleUsers.get(0).getSaasRole());
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.enabled(true)
|
||||
.needRole(true)
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 13);
|
||||
Assertions.assertNotNull(saasRoleUsers.get(0).getSaasRole());
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.enabled(false)
|
||||
.needRole(true)
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 13);
|
||||
Assertions.assertNull(saasRoleUsers.get(0).getSaasRole());
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:zb_worker——management"))
|
||||
.identityId(17L)
|
||||
.needRole(true)
|
||||
.needPermissionRelation(true)
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 1);
|
||||
Assertions.assertNotNull(saasRoleUsers.get(0).getSaasRole());
|
||||
Assertions.assertEquals(saasRoleUsers.get(0).getSaasRole().getPermissionRelations().size(), 3);
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.featureIds(Lists.newArrayList(101744L))
|
||||
.roleCodes(Sets.newHashSet("cms:zb_worker——management"))
|
||||
.identityId(17L)
|
||||
.needRole(true)
|
||||
.needPermissionRelation(true)
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 1);
|
||||
Assertions.assertNotNull(saasRoleUsers.get(0).getSaasRole());
|
||||
Assertions.assertEquals(saasRoleUsers.get(0).getSaasRole().getPermissionRelations().size(), 1);
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:zb_worker——management"))
|
||||
.identityId(17L)
|
||||
.needRole(true)
|
||||
.needPermissionRelation(true)
|
||||
.featureResourceTypes(Lists.newArrayList(FeatureResourceType.PAGE))
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 1);
|
||||
Assertions.assertNotNull(saasRoleUsers.get(0).getSaasRole());
|
||||
Assertions.assertNull(saasRoleUsers.get(0).getSaasRole().getPermissionRelations());
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:zb_worker——management"))
|
||||
.identityId(17L)
|
||||
.needRole(true)
|
||||
.needPermissionRelation(true)
|
||||
.featureResourceTypes(Lists.newArrayList(FeatureResourceType.COMPONENT))
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 1);
|
||||
Assertions.assertNotNull(saasRoleUsers.get(0).getSaasRole());
|
||||
Assertions.assertEquals(saasRoleUsers.get(0).getSaasRole().getPermissionRelations().size(), 3);
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:zb_worker——management"))
|
||||
.identityId(17L)
|
||||
.needRole(true)
|
||||
.needPermissionRelation(true)
|
||||
.terminal("NT_CMS_WEB_GENERAL")
|
||||
.type(NEW_FEATURE)
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 1);
|
||||
Assertions.assertNotNull(saasRoleUsers.get(0).getSaasRole());
|
||||
Assertions.assertNull(saasRoleUsers.get(0).getSaasRole().getPermissionRelations());
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:zb_worker——management"))
|
||||
.identityId(17L)
|
||||
.needRole(true)
|
||||
.needPermissionRelation(true)
|
||||
.terminal("NT_CMP_APP_GENERAL")
|
||||
.type(NEW_FEATURE)
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 1);
|
||||
Assertions.assertNotNull(saasRoleUsers.get(0).getSaasRole());
|
||||
Assertions.assertEquals(saasRoleUsers.get(0).getSaasRole().getPermissionRelations().size(), 3);
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:zb_worker——management"))
|
||||
.identityId(17L)
|
||||
.needRole(true)
|
||||
.needPermission(true)
|
||||
.terminal("NT_CMP_APP_GENERAL")
|
||||
.type(NEW_FEATURE)
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 1);
|
||||
Assertions.assertNotNull(saasRoleUsers.get(0).getSaasRole());
|
||||
Assertions.assertNull(saasRoleUsers.get(0).getSaasRole().getPermissionRelations());
|
||||
Assertions.assertEquals(saasRoleUsers.get(0).getSaasRole().getSaasPermissions().size(), 3);
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.batchPersons(Lists.newArrayList(ListRoleUserRelationParam.BatchPerson.builder()
|
||||
.personId(1827L)
|
||||
.ouId(4L)
|
||||
.workspaceId(3L)
|
||||
.build()))
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 1);
|
||||
|
||||
saasRoleUsers = saasRoleUserRelationService.listV2(ListRoleUserRelationParam.builder()
|
||||
.batchPersons(Lists.newArrayList(ListRoleUserRelationParam.BatchPerson.builder()
|
||||
.personId(1827L)
|
||||
.ouId(4L)
|
||||
.workspaceId(3L)
|
||||
.build(),
|
||||
ListRoleUserRelationParam.BatchPerson.builder()
|
||||
.personId(2107L)
|
||||
.ouId(4L)
|
||||
.workspaceId(3L)
|
||||
.build()))
|
||||
.build());
|
||||
Assertions.assertEquals(saasRoleUsers.size(), 2);
|
||||
// old
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.resourceTypes(Sets.newHashSet(1))
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertTrue(data.isEmpty());
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.resourceTypes(Sets.newHashSet(0))
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 13);
|
||||
Assertions.assertEquals(data.get(0).getId(), 544214L);
|
||||
Assertions.assertEquals(data.get(0).getIdentityId(), 14L);
|
||||
Assertions.assertEquals(data.get(0).getIdentityType(), 3);
|
||||
Assertions.assertEquals(data.get(0).getRoleId(), 100921L);
|
||||
Assertions.assertEquals(data.get(0).getPersonId(), 0L);
|
||||
Assertions.assertEquals(data.get(0).getCreateBy(), 1L);
|
||||
Assertions.assertEquals(data.get(0).getUpdateBy(), 2L);
|
||||
Assertions.assertEquals(data.get(0).getOuId(), 4L);
|
||||
Assertions.assertEquals(data.get(0).getWorkspaceId(), 3L);
|
||||
Assertions.assertEquals(data.get(0).getResourceId(), 0L);
|
||||
Assertions.assertEquals(data.get(0).getResourceType(), 0);
|
||||
Assertions.assertEquals(LocalDateTime.ofInstant(listApiResult.get(0).getUpdateAt().toInstant(), ZoneId.systemDefault()),
|
||||
LocalDateTime.of(2024, 9, 26, 11, 31, 32));
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.resourceIds(Sets.newHashSet(1L))
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertTrue(data.isEmpty());
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.resourceIds(Sets.newHashSet(0L))
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 13);
|
||||
Assertions.assertEquals(data.get(0).getId(), 544214L);
|
||||
Assertions.assertEquals(data.get(0).getIdentityId(), 14L);
|
||||
Assertions.assertEquals(data.get(0).getIdentityType(), 3);
|
||||
Assertions.assertEquals(data.get(0).getRoleId(), 100921L);
|
||||
Assertions.assertEquals(data.get(0).getPersonId(), 0L);
|
||||
Assertions.assertEquals(data.get(0).getCreateBy(), 1L);
|
||||
Assertions.assertEquals(data.get(0).getUpdateBy(), 2L);
|
||||
Assertions.assertEquals(data.get(0).getOuId(), 4L);
|
||||
Assertions.assertEquals(data.get(0).getWorkspaceId(), 3L);
|
||||
Assertions.assertEquals(data.get(0).getResourceId(), 0L);
|
||||
Assertions.assertEquals(data.get(0).getResourceType(), 0);
|
||||
Assertions.assertEquals(LocalDateTime.ofInstant(listApiResult.get(0).getUpdateAt().toInstant(), ZoneId.systemDefault()),
|
||||
LocalDateTime.of(2024, 9, 26, 11, 31, 32));
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.isDisplay(true)
|
||||
.needRole(true)
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 13);
|
||||
Assertions.assertNotNull(data.get(0).getRole());
|
||||
Assertions.assertEquals(data.get(0).getId(), 544214L);
|
||||
Assertions.assertEquals(data.get(0).getIdentityId(), 14L);
|
||||
Assertions.assertEquals(data.get(0).getIdentityType(), 3);
|
||||
Assertions.assertEquals(data.get(0).getRoleId(), 100921L);
|
||||
Assertions.assertEquals(data.get(0).getPersonId(), 0L);
|
||||
Assertions.assertEquals(data.get(0).getRole().getRoleId(), 100921L);
|
||||
Assertions.assertEquals(data.get(0).getRole().getRoleCode(), "cms:zb_org_view");
|
||||
Assertions.assertEquals(data.get(0).getRole().getName(), "查看组织架构");
|
||||
Assertions.assertEquals(data.get(0).getRole().getRoleType(), cn.axzo.tyr.client.common.enums.RoleTypeEnum.INIT.getValue());
|
||||
Assertions.assertEquals(data.get(0).getRole().getDescription(), "ff");
|
||||
Assertions.assertEquals(data.get(0).getRole().getWorkspaceId(), -1L);
|
||||
Assertions.assertEquals(data.get(0).getRole().getOuId(), -1L);
|
||||
Assertions.assertEquals(data.get(0).getRole().getCooperateShipType(), 1);
|
||||
Assertions.assertEquals(data.get(0).getRole().getCreateBy(), 154587L);
|
||||
Assertions.assertEquals(data.get(0).getRole().getUpdateBy(), 154587L);
|
||||
Assertions.assertEquals(data.get(0).getRole().getSort(), 5);
|
||||
Assertions.assertTrue(data.get(0).getRole().getIsDisplay());
|
||||
Assertions.assertTrue(data.get(0).getRole().getEnabled());
|
||||
Assertions.assertEquals(LocalDateTime.ofInstant(data.get(0).getRole().getUpdateAt().toInstant(), ZoneId.systemDefault()),
|
||||
LocalDateTime.of(2024, 9, 26, 10, 43, 6));
|
||||
Assertions.assertEquals(LocalDateTime.ofInstant(data.get(0).getRole().getCreateAt().toInstant(), ZoneId.systemDefault()),
|
||||
LocalDateTime.of(2024, 9, 25, 11, 51, 57));
|
||||
Assertions.assertEquals(data.get(0).getCreateBy(), 1L);
|
||||
Assertions.assertEquals(data.get(0).getUpdateBy(), 2L);
|
||||
Assertions.assertEquals(data.get(0).getOuId(), 4L);
|
||||
Assertions.assertEquals(data.get(0).getWorkspaceId(), 3L);
|
||||
Assertions.assertEquals(data.get(0).getResourceId(), 0L);
|
||||
Assertions.assertEquals(data.get(0).getResourceType(), 0);
|
||||
Assertions.assertEquals(LocalDateTime.ofInstant(listApiResult.get(0).getUpdateAt().toInstant(), ZoneId.systemDefault()),
|
||||
LocalDateTime.of(2024, 9, 26, 11, 31, 32));
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.isDisplay(false)
|
||||
.needRole(true)
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 13);
|
||||
Assertions.assertNull(data.get(0).getRole());
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.enabled(true)
|
||||
.needRole(true)
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 13);
|
||||
Assertions.assertNotNull(data.get(0).getRole());
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.enabled(false)
|
||||
.needRole(true)
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 13);
|
||||
Assertions.assertNull(data.get(0).getRole());
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:zb_worker——management"))
|
||||
.identityIds(Sets.newHashSet(17L))
|
||||
.needRole(true)
|
||||
.needFeatureResourceRelation(true)
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 1);
|
||||
Assertions.assertNotNull(data.get(0).getRole());
|
||||
Assertions.assertEquals(data.get(0).getRole().getFeatureResourceRelations().size(), 3);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.featureResourceIds(Sets.newHashSet(101744L))
|
||||
.roleCodes(Sets.newHashSet("cms:zb_worker——management"))
|
||||
.identityIds(Sets.newHashSet(17L))
|
||||
.needRole(true)
|
||||
.needFeatureResourceRelation(true)
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 1);
|
||||
Assertions.assertNotNull(data.get(0).getRole());
|
||||
Assertions.assertEquals(data.get(0).getRole().getFeatureResourceRelations().size(), 1);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:zb_worker——management"))
|
||||
.identityIds(Sets.newHashSet(17L))
|
||||
.needRole(true)
|
||||
.needFeatureResourceRelation(true)
|
||||
.featureResourceTypes(Sets.newHashSet(FeatureResourceTypeEnum.PAGE))
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 1);
|
||||
Assertions.assertNotNull(data.get(0).getRole());
|
||||
Assertions.assertNull(data.get(0).getRole().getFeatureResourceRelations());
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:zb_worker——management"))
|
||||
.identityIds(Sets.newHashSet(17L))
|
||||
.needRole(true)
|
||||
.needFeatureResourceRelation(true)
|
||||
.featureResourceTypes(Sets.newHashSet(FeatureResourceTypeEnum.COMPONENT))
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 1);
|
||||
Assertions.assertNotNull(data.get(0).getRole());
|
||||
Assertions.assertEquals(data.get(0).getRole().getFeatureResourceRelations().size(), 3);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:zb_worker——management"))
|
||||
.identityIds(Sets.newHashSet(17L))
|
||||
.needRole(true)
|
||||
.needFeatureResourceRelation(true)
|
||||
.featureResourceTypes(Sets.newHashSet(FeatureResourceTypeEnum.COMPONENT))
|
||||
.terminal("NT_CMS_WEB_GENERAL")
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 1);
|
||||
Assertions.assertNotNull(data.get(0).getRole());
|
||||
Assertions.assertNull(data.get(0).getRole().getFeatureResourceRelations());
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:zb_worker——management"))
|
||||
.identityIds(Sets.newHashSet(17L))
|
||||
.needRole(true)
|
||||
.needFeatureResourceRelation(true)
|
||||
.featureResourceTypes(Sets.newHashSet(FeatureResourceTypeEnum.COMPONENT))
|
||||
.terminal("NT_CMP_APP_GENERAL")
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 1);
|
||||
Assertions.assertNotNull(data.get(0).getRole());
|
||||
Assertions.assertEquals(data.get(0).getRole().getFeatureResourceRelations().size(), 3);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.roleCodes(Sets.newHashSet("cms:zb_worker——management"))
|
||||
.identityIds(Sets.newHashSet(17L))
|
||||
.needRole(true)
|
||||
.needFeatureResources(true)
|
||||
.featureResourceTypes(Sets.newHashSet(FeatureResourceTypeEnum.COMPONENT))
|
||||
.terminal("NT_CMP_APP_GENERAL")
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 1);
|
||||
Assertions.assertNotNull(data.get(0).getRole());
|
||||
Assertions.assertNull(data.get(0).getRole().getFeatureResourceRelations());
|
||||
Assertions.assertEquals(data.get(0).getRole().getRoleFeatureResources().size(), 3);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.personIds(Sets.newHashSet(1827L))
|
||||
.ouIds(Sets.newHashSet(4L))
|
||||
.workspaceIds(Sets.newHashSet(3L))
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 1);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.batchPersons(Sets.newHashSet(PageRoleUserReq.BatchPerson.builder()
|
||||
.personId(1827L)
|
||||
.ouId(4L)
|
||||
.workspaceId(3L)
|
||||
.build(),
|
||||
PageRoleUserReq.BatchPerson.builder()
|
||||
.personId(2107L)
|
||||
.ouId(4L)
|
||||
.workspaceId(3L)
|
||||
.build()))
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 2);
|
||||
|
||||
data = roleUserV2Controller.page(PageRoleUserReq.builder()
|
||||
.isDisplay(true)
|
||||
.needRole(true)
|
||||
.needFeatureResources(true)
|
||||
.needFeatureResourceRelation(true)
|
||||
.build())
|
||||
.getData()
|
||||
.getData();
|
||||
Assertions.assertEquals(data.size(), 13);
|
||||
Assertions.assertNotNull(data.get(0).getRole());
|
||||
Assertions.assertEquals(data.get(0).getId(), 544214L);
|
||||
Assertions.assertEquals(data.get(0).getIdentityId(), 14L);
|
||||
Assertions.assertEquals(data.get(0).getIdentityType(), 3);
|
||||
Assertions.assertEquals(data.get(0).getRoleId(), 100921L);
|
||||
Assertions.assertEquals(data.get(0).getPersonId(), 0L);
|
||||
Assertions.assertEquals(data.get(0).getRole().getRoleId(), 100921L);
|
||||
Assertions.assertEquals(data.get(0).getRole().getRoleCode(), "cms:zb_org_view");
|
||||
Assertions.assertEquals(data.get(0).getRole().getName(), "查看组织架构");
|
||||
Assertions.assertEquals(data.get(0).getRole().getRoleType(), cn.axzo.tyr.client.common.enums.RoleTypeEnum.INIT.getValue());
|
||||
Assertions.assertEquals(data.get(0).getRole().getDescription(), "ff");
|
||||
Assertions.assertEquals(data.get(0).getRole().getWorkspaceId(), -1L);
|
||||
Assertions.assertEquals(data.get(0).getRole().getOuId(), -1L);
|
||||
Assertions.assertEquals(data.get(0).getRole().getCooperateShipType(), 1);
|
||||
Assertions.assertEquals(data.get(0).getRole().getCreateBy(), 154587L);
|
||||
Assertions.assertEquals(data.get(0).getRole().getUpdateBy(), 154587L);
|
||||
Assertions.assertEquals(data.get(0).getRole().getSort(), 5);
|
||||
Assertions.assertTrue(data.get(0).getRole().getIsDisplay());
|
||||
Assertions.assertTrue(data.get(0).getRole().getEnabled());
|
||||
Assertions.assertEquals(LocalDateTime.ofInstant(data.get(0).getRole().getUpdateAt().toInstant(), ZoneId.systemDefault()),
|
||||
LocalDateTime.of(2024, 9, 26, 10, 43, 6));
|
||||
Assertions.assertEquals(LocalDateTime.ofInstant(data.get(0).getRole().getCreateAt().toInstant(), ZoneId.systemDefault()),
|
||||
LocalDateTime.of(2024, 9, 25, 11, 51, 57));
|
||||
Assertions.assertEquals(data.get(0).getCreateBy(), 1L);
|
||||
Assertions.assertEquals(data.get(0).getUpdateBy(), 2L);
|
||||
Assertions.assertEquals(data.get(0).getOuId(), 4L);
|
||||
Assertions.assertEquals(data.get(0).getWorkspaceId(), 3L);
|
||||
Assertions.assertEquals(data.get(0).getResourceId(), 0L);
|
||||
Assertions.assertEquals(data.get(0).getResourceType(), 0);
|
||||
Assertions.assertEquals(LocalDateTime.ofInstant(listApiResult.get(0).getUpdateAt().toInstant(), ZoneId.systemDefault()),
|
||||
LocalDateTime.of(2024, 9, 26, 11, 31, 32));
|
||||
|
||||
Assertions.assertEquals(data.get(0).getRole().getFeatureResourceRelations().size(), 3);
|
||||
Assertions.assertEquals(data.get(0).getRole().getFeatureResourceRelations().get(0).getFeatureId(), 100835L);
|
||||
Assertions.assertEquals(data.get(0).getRole().getFeatureResourceRelations().get(0).getTags().size(), 1);
|
||||
Assertions.assertTrue(data.get(0).getRole().getFeatureResourceRelations().get(0).getTags().contains(RolePermissionTagEnum.JOINED.name()));
|
||||
Assertions.assertEquals(data.get(0).getRole().getFeatureResourceRelations().get(0).getType(), 1);
|
||||
Assertions.assertEquals(data.get(0).getRole().getFeatureResourceRelations().get(0).getFeatureType(), FeatureResourceTypeEnum.MENU.getCode());
|
||||
|
||||
Assertions.assertEquals(data.get(0).getRole().getRoleFeatureResources().size(), 3);
|
||||
Assertions.assertEquals(data.get(0).getRole().getRoleFeatureResources().get(0).getId(), 100835L);
|
||||
Assertions.assertEquals(data.get(0).getRole().getRoleFeatureResources().get(0).getUniCode(), "cms:project_9103");
|
||||
Assertions.assertTrue(data.get(0).getRole().getRoleFeatureResources().get(0).getTags().contains(RolePermissionTagEnum.JOINED.name()));
|
||||
Assertions.assertEquals(data.get(0).getRole().getRoleFeatureResources().get(0).getTerminal(), "NT_CMS_WEB_GENERAL");
|
||||
}
|
||||
}
|
||||
@ -45,4 +45,49 @@ VALUES (544687, 429, 100921, 3, 5267, 3, 4, 0, 0, 0, '2024-09-26 11:31:33', '202
|
||||
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);
|
||||
|
||||
INSERT INTO saas_pgroup_role_relation (id, role_id, group_id, is_delete, create_at, update_at, create_by, update_by)
|
||||
VALUES (2290971, 100920, 1211, 0, '2024-09-25 11:51:57', '2024-09-26 10:43:27', 154587, 154587);
|
||||
INSERT INTO saas_pgroup_role_relation (id, role_id, group_id, is_delete, create_at, update_at, create_by, update_by)
|
||||
VALUES (2290972, 100921, 1212, 0, '2024-09-25 11:51:57', '2024-09-26 10:43:27', 154587, 154587);
|
||||
INSERT INTO saas_pgroup_role_relation (id, role_id, group_id, is_delete, create_at, update_at, create_by, update_by)
|
||||
VALUES (2290974, 100923, 1214, 0, '2024-09-25 11:51:58', '2024-09-26 10:43:27', 154587, 154587);
|
||||
|
||||
INSERT INTO saas_pgroup_permission_relation (id, group_id, feature_id, is_delete, create_at, update_at, create_by, update_by, type, feature_type, terminal, tags)
|
||||
VALUES (5208030, 1211, 101744, 0, '2024-09-25 21:34:42', '2024-11-09 08:51:59', 2051297, 2051297, 1, 4, 'NT_CMP_APP_GENERAL', '["JOINED"]');
|
||||
INSERT INTO saas_pgroup_permission_relation (id, group_id, feature_id, is_delete, create_at, update_at, create_by, update_by, type, feature_type, terminal, tags)
|
||||
VALUES (5208040, 1211, 101745, 0, '2024-09-25 21:34:42', '2024-11-09 08:51:59', 2051297, 2051297, 1, 4, 'NT_CMP_APP_GENERAL', '["JOINED"]');
|
||||
INSERT INTO saas_pgroup_permission_relation (id, group_id, feature_id, is_delete, create_at, update_at, create_by, update_by, type, feature_type, terminal, tags)
|
||||
VALUES (5208043, 1211, 101746, 0, '2024-09-25 21:34:42', '2024-11-09 08:51:59', 2051297, 2051297, 1, 4, 'NT_CMP_APP_GENERAL', '["JOINED"]');
|
||||
|
||||
INSERT INTO saas_pgroup_permission_relation (id, group_id, feature_id, is_delete, create_at, update_at, create_by, update_by, type, feature_type, terminal, tags)
|
||||
VALUES (5208031, 1212, 101744, 0, '2024-09-25 21:34:42', '2024-11-09 08:51:59', 2051297, 2051297, 1, 4, 'NT_CMP_APP_GENERAL', '["JOINED"]');
|
||||
INSERT INTO saas_pgroup_permission_relation (id, group_id, feature_id, is_delete, create_at, update_at, create_by, update_by, type, feature_type, terminal, tags)
|
||||
VALUES (5208055, 1212, 101749, 0, '2024-09-25 21:34:42', '2024-11-09 08:51:59', 2051297, 2051297, 1, 4, 'NT_CMP_APP_GENERAL', '["JOINED"]');
|
||||
INSERT INTO saas_pgroup_permission_relation (id, group_id, feature_id, is_delete, create_at, update_at, create_by, update_by, type, feature_type, terminal, tags)
|
||||
VALUES (5205310, 1212, 100835, 0, '2024-09-25 21:34:42', '2024-11-09 08:51:59', 2051297, 9000404386, 1, 1, 'NT_CMS_WEB_GENERAL', '["JOINED"]');
|
||||
|
||||
INSERT INTO saas_pgroup_permission_relation (id, group_id, feature_id, is_delete, create_at, update_at, create_by, update_by, type, feature_type, terminal, tags)
|
||||
VALUES (5206538, 1214, 101048, 0, '2024-09-25 21:34:42', '2024-11-09 08:51:59', 2051297, 9000404204, 1, 2, 'NT_CMS_WEB_GENERAL', '["JOINED"]');
|
||||
INSERT INTO saas_pgroup_permission_relation (id, group_id, feature_id, is_delete, create_at, update_at, create_by, update_by, type, feature_type, terminal, tags)
|
||||
VALUES (5206556, 1214, 101053, 0, '2024-09-25 21:34:42', '2024-11-09 08:51:59', 2051297, 9000404204, 1, 4, 'NT_CMS_WEB_GENERAL', '["JOINED"]');
|
||||
INSERT INTO saas_pgroup_permission_relation (id, group_id, feature_id, is_delete, create_at, update_at, create_by, update_by, type, feature_type, terminal, tags)
|
||||
VALUES (5206562, 1214, 101054, 0, '2024-09-25 21:34:42', '2024-11-09 08:51:59', 2051297, 9000404204, 1, 4, 'NT_CMS_WEB_GENERAL', '["JOINED"]');
|
||||
|
||||
INSERT INTO saas_feature_resource (id, feature_code, feature_name, feature_type, terminal, component_type, parent_id, path, workspace_type, workspace_types, version, uni_code, display_order, status, icon, redirect_type, link_url, link_type, link_ext, app_item_id, sync_version, extra, auth_type, sub_auth_type, create_at, update_at, create_by, update_by, is_delete)
|
||||
VALUES (100835, 'cms:project_9103', '项目', 1, 'NT_CMS_WEB_GENERAL', 0, 100000, '100000,100835,', 0, '', 0, 'cms:project_9103', 1, 1, 'https://axzo-public.oss-cn-chengdu.aliyuncs.com/oms/oms/d4137963b9f54c7787afa7ef52d95540.svg', 1, '/', 0, '', 0, 0, '{"moreIcon": "https://axzo-public.oss-cn-chengdu.aliyuncs.com/oms/oms/cc474a2dc1884b6081f33d470a2e03e6.svg", "activeIcon": "https://axzo-public.oss-cn-chengdu.aliyuncs.com/oms/oms/3e69eb003de64682a2e88c4d9da5ed1d.svg"}', 0, 0, '2024-06-01 14:50:52', '2024-10-29 11:29:10', 59926, 9000404098, 0);
|
||||
INSERT INTO saas_feature_resource (id, feature_code, feature_name, feature_type, terminal, component_type, parent_id, path, workspace_type, workspace_types, version, uni_code, display_order, status, icon, redirect_type, link_url, link_type, link_ext, app_item_id, sync_version, extra, auth_type, sub_auth_type, create_at, update_at, create_by, update_by, is_delete)
|
||||
VALUES (101048, 'cms:pro_contract_management_7701', '合约管理', 2, 'NT_CMS_WEB_GENERAL', 0, 100883, '100000,100835,100883,101048,', 2, '2', 0, 'cms:pro_contract_management_7701', 0, 1, '', 1, '/netConstruction/construction/contract-manage', 0, '', 0, 0, null, 1, 0, '2024-06-18 16:35:35', '2024-10-21 11:24:41', 59926, 9000404204, 0);
|
||||
INSERT INTO saas_feature_resource (id, feature_code, feature_name, feature_type, terminal, component_type, parent_id, path, workspace_type, workspace_types, version, uni_code, display_order, status, icon, redirect_type, link_url, link_type, link_ext, app_item_id, sync_version, extra, auth_type, sub_auth_type, create_at, update_at, create_by, update_by, is_delete)
|
||||
VALUES (101053, 'cms:pro_contract_price_authority_7706', '查看合约价格信息', 4, 'NT_CMS_WEB_GENERAL', 5, 101054, '100000,100835,100883,101048,101054,101053,', 0, '', 0, 'cms:pro_contract_price_authority_7706', 4, 1, '', 1, '', 0, '', 0, 0, null, 1, 1, '2024-07-12 14:02:46', '2024-10-21 11:24:43', 59926, 9000404204, 0);
|
||||
INSERT INTO saas_feature_resource (id, feature_code, feature_name, feature_type, terminal, component_type, parent_id, path, workspace_type, workspace_types, version, uni_code, display_order, status, icon, redirect_type, link_url, link_type, link_ext, app_item_id, sync_version, extra, auth_type, sub_auth_type, create_at, update_at, create_by, update_by, is_delete)
|
||||
VALUES (101054, 'cms:pro_contract_detail_7707', '合约详情', 4, 'NT_CMS_WEB_GENERAL', 1, 101048, '100000,100835,100883,101048,101054,', 0, '', 0, 'cms:pro_contract_detail_7707', 3, 1, '', 1, '/', 0, '', 0, 0, null, 1, 1, '2024-07-04 16:27:16', '2024-10-21 11:24:42', 185732, 9000404204, 0);
|
||||
INSERT INTO saas_feature_resource (id, feature_code, feature_name, feature_type, terminal, component_type, parent_id, path, workspace_type, workspace_types, version, uni_code, display_order, status, icon, redirect_type, link_url, link_type, link_ext, app_item_id, sync_version, extra, auth_type, sub_auth_type, create_at, update_at, create_by, update_by, is_delete)
|
||||
VALUES (101744, 'cmp:pro_team_list_0443', '查看班组列表', 4, 'NT_CMP_APP_GENERAL', 5, 101741, '636,101437,101445,101573,101741,101744,', 0, '', 0, 'cmp:pro_team_list_0443', 2, 1, '', 1, '', 0, '', 0, 0, null, 1, 1, '2024-08-13 10:39:22', '2024-08-28 10:53:36', 86256, 25923, 0);
|
||||
INSERT INTO saas_feature_resource (id, feature_code, feature_name, feature_type, terminal, component_type, parent_id, path, workspace_type, workspace_types, version, uni_code, display_order, status, icon, redirect_type, link_url, link_type, link_ext, app_item_id, sync_version, extra, auth_type, sub_auth_type, create_at, update_at, create_by, update_by, is_delete)
|
||||
VALUES (101745, 'cmp:pro_worker_invite_recorder_0445', '查看工人入场申请', 4, 'NT_CMP_APP_GENERAL', 5, 101741, '636,101437,101445,101573,101741,101745,', 0, '', 0, 'cmp:pro_worker_invite_recorder_0445', 3, 1, '', 1, '', 0, '', 0, 0, null, 1, 1, '2024-08-13 10:40:29', '2024-08-28 10:53:36', 86256, 25923, 0);
|
||||
INSERT INTO saas_feature_resource (id, feature_code, feature_name, feature_type, terminal, component_type, parent_id, path, workspace_type, workspace_types, version, uni_code, display_order, status, icon, redirect_type, link_url, link_type, link_ext, app_item_id, sync_version, extra, auth_type, sub_auth_type, create_at, update_at, create_by, update_by, is_delete)
|
||||
VALUES (101746, 'cmp:pro_team_leader_invite_recorder_0446', '班组长入场申请记录', 4, 'NT_CMP_APP_GENERAL', 5, 101741, '636,101437,101445,101573,101741,101746,', 0, '', 0, 'cmp:pro_team_leader_invite_recorder_0446', 4, 1, '', 1, '', 0, '', 0, 0, null, 1, 1, '2024-08-13 10:40:50', '2024-08-28 10:53:36', 86256, 25923, 0);
|
||||
INSERT INTO saas_feature_resource (id, feature_code, feature_name, feature_type, terminal, component_type, parent_id, path, workspace_type, workspace_types, version, uni_code, display_order, status, icon, redirect_type, link_url, link_type, link_ext, app_item_id, sync_version, extra, auth_type, sub_auth_type, create_at, update_at, create_by, update_by, is_delete)
|
||||
VALUES (101749, 'cmp:pro_team_index_0449', '查看班组详情', 4, 'NT_CMP_APP_GENERAL', 5, 101741, '636,101437,101445,101573,101741,101749,', 0, '', 0, 'cmp:pro_team_index_0449', 7, 1, '', 1, '', 0, '', 0, 0, null, 1, 1, '2024-08-13 10:41:28', '2024-08-28 10:53:37', 86256, 25923, 0);
|
||||
|
||||
#-->SaasRoleUserRelationServiceImplTest.sql
|
||||
Loading…
Reference in New Issue
Block a user