feat:(REQ-3282) 收口角色page接口

This commit is contained in:
李龙 2024-12-07 17:08:21 +08:00
parent 23543a359d
commit 6e3e5b7342
23 changed files with 1075 additions and 235 deletions

View File

@ -63,4 +63,16 @@ public class PagePgroupPermissionRelationReq implements IPageReq {
@CriteriaField(ignore = true)
private Set<RolePermissionTagEnum> tags;
/**
* 是否需要菜单组件信息
*/
@CriteriaField(ignore = true)
private Boolean needFeatureResource;
/**
* 是否需要角色信息
*/
@CriteriaField(ignore = true)
private Boolean needRole;
}

View File

@ -21,6 +21,8 @@ public class SaasPermissionRes {
*/
private String featureCode;
private String uniCode;
/**
* 资源所属端
*/

View File

@ -1,17 +1,16 @@
package cn.axzo.tyr.feign.api;
import cn.axzo.foundation.page.PageResp;
import cn.axzo.foundation.result.ApiResult;
import cn.axzo.tyr.feign.req.ListRoleReq;
import cn.axzo.tyr.feign.req.PageRoleReq;
import cn.axzo.tyr.feign.resp.RoleResp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@FeignClient(name = "tyr", url = "${axzo.service.tyr:http://tyr:8080}")
public interface RoleApi {
@PostMapping("/api/role/list")
ApiResult<List<RoleResp>> list(@RequestBody ListRoleReq req);
@PostMapping("/api/role/page")
ApiResult<PageResp<RoleResp>> page(@RequestBody PageRoleReq req);
}

View File

@ -0,0 +1,15 @@
package cn.axzo.tyr.feign.config;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Configuration;
/**
* @Author: liyong.tian
* @Date: 2022/9/17
* @Description:
*/
@EnableFeignClients(basePackages = {"cn.axzo.tyr.feign"})
@Configuration
public class TyrFeignAutoConfiguration {
}

View File

@ -1,5 +1,6 @@
package cn.axzo.tyr.feign.req;
import cn.axzo.foundation.page.PageReq;
import cn.axzo.tyr.feign.enums.RolePermissionTagEnum;
import cn.axzo.tyr.feign.enums.RoleTypeEnum;
import cn.axzo.tyr.feign.enums.FeatureResourceTypeEnum;
@ -15,7 +16,7 @@ import java.util.Set;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ListRoleReq {
public class PageRoleReq extends PageReq {
/**
* 角色id
@ -63,13 +64,35 @@ public class ListRoleReq {
private Set<RoleTypeEnum> roleTypes;
/**
* 是否需要角色下的权限信息
* workspaceId和ouId配对查询
* 例如((workspaceId = ## and ouId = ##) or (workspaceId = ## and ouId = ##))
*/
private Boolean needPermission;
private List<WorkspaceOuPair> workspaceOuPairs;
/**
* 角色权限码
*/
private Set<String> roleCodes;
/**
* 角色分组code
*/
private Set<String> roleGroupCodes;
/**
* 协同关系类型
* 1:总包 2:建设单位 3:监理单位 4:劳务分包 5:专业分包 6:OMS通用 7:企业通用 8:企业内班组 9:项目内班组
*/
private Set<Integer> cooperateShipTypes;
/**
* 是否需要角色关联的菜单组件信息saas_feature_recource的记录
*/
private Boolean needFeatureResources;
/**
* 根据权限标签去过滤角色对应的权限
* 只有在needPermission = true时才生效
* 只有在needFeatureResources = true时才生效
*/
private Set<RolePermissionTagEnum> permissionTags;
@ -96,38 +119,11 @@ public class ListRoleReq {
*/
private List<FeatureResourceTypeEnum> featureResourceTypes;
/**
* 新旧权限点needPermissionRelation = true时最好带上因为新旧权限点会有冲突的情况发生
*/
private Integer type;
/**
* 查询权限点时会根据端过滤增加效率目前只有CMS端的新版本才冗余了端
*/
private String terminal;
/**
* workspaceId和ouId配对查询
* 例如((workspaceId = ## and ouId = ##) or (workspaceId = ## and ouId = ##))
*/
private List<WorkspaceOuPair> workspaceOuPairs;
/**
* 角色权限码
*/
private Set<String> roleCodes;
/**
* 角色分组code
*/
private Set<String> roleGroupCodes;
/**
* 协同关系类型
* 1:总包 2:建设单位 3:监理单位 4:劳务分包 5:专业分包 6:OMS通用 7:企业通用 8:企业内班组 9:项目内班组
*/
private Set<Integer> cooperateShipTypes;
@Data
@Builder
@NoArgsConstructor

View File

@ -0,0 +1,35 @@
package cn.axzo.tyr.feign.resp;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Set;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RoleFeatureResourceResp {
/**
* 菜单组件id
*/
private Long id;
/**
* 菜单组件编码(全局唯一)
*/
private String uniCode;
/**
* 菜单组件所属端
*/
private String terminal;
/**
* 菜单组件的权限标签
*/
private Set<String> tags;
}

View File

@ -1,15 +0,0 @@
package cn.axzo.tyr.feign.resp;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class RolePermissionResp {
private Long id;
}

View File

@ -96,9 +96,9 @@ public class RoleResp {
private RoleGroupResp roleGroup;
/**
* 角色权限
* 角色关联的菜单组件信息
*/
private List<RolePermissionResp> rolePermissions;
private List<RoleFeatureResourceResp> roleFeatureResources;
/**
* 角色对应的人员信息

View File

@ -1,2 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
cn.axzo.tyr.client.config.TyrClientAutoConfiguration
cn.axzo.tyr.feign.config.TyrFeignAutoConfiguration

View File

@ -30,7 +30,8 @@ public enum BizResultCode implements IResultCode {
FEATURE_NAME_EXIST("100020", "菜单组件名字已经存在:{}"),
TERMINAL_EXIST("100021", "新端已经存在:{}"),
TERMINAL_NOT_FOUND("100022", "原端不存在:{}"),
FEATURE_CODE_OVER_LENGTH("100023", "组件code不能超过100个字符:{}");
FEATURE_CODE_OVER_LENGTH("100023", "组件code不能超过100个字符:{}"),
MAX_PAGE_SIZE_ERROR("100024", "最大查询");
private String errorCode;

View File

@ -437,7 +437,7 @@ public class PrivateController {
.pageSize(DEFAULT_PAGE_SIZE)
.build();
PageResp<SaasPgroupPermissionRelation> page = saasPgroupPermissionRelationService.page(req);
PageResp<SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO> page = saasPgroupPermissionRelationService.page(req);
if (CollectionUtils.isNotEmpty(page.getData())) {
updateOldRoleFeature(page.getData());
@ -451,8 +451,8 @@ public class PrivateController {
return "ok";
}
private void updateNewRoleFeature(List<SaasPgroupPermissionRelation> saasPgroupPermissionRelations) {
List<SaasPgroupPermissionRelation> newFeatureRelations = saasPgroupPermissionRelations.stream()
private void updateNewRoleFeature(List<SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO> saasPgroupPermissionRelations) {
List<SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO> newFeatureRelations = saasPgroupPermissionRelations.stream()
.filter(e -> Objects.equals(e.getType(), NEW_FEATURE))
.collect(Collectors.toList());
@ -460,7 +460,7 @@ public class PrivateController {
return;
}
Map<Long, SaasFeatureResource> saasFeatureResourceMap = saasFeatureResourceDao.listByIds(Lists.transform(newFeatureRelations, SaasPgroupPermissionRelation::getFeatureId))
Map<Long, SaasFeatureResource> saasFeatureResourceMap = saasFeatureResourceDao.listByIds(Lists.transform(newFeatureRelations, SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO::getFeatureId))
.stream()
.collect(Collectors.toMap(SaasFeatureResource::getId, Function.identity()));
@ -485,8 +485,8 @@ public class PrivateController {
saasPgroupPermissionRelationService.updateBatchById(update);
}
private void updateOldRoleFeature(List<SaasPgroupPermissionRelation> saasPgroupPermissionRelations) {
List<SaasPgroupPermissionRelation> oldFeatureRelations = saasPgroupPermissionRelations.stream()
private void updateOldRoleFeature(List<SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO> saasPgroupPermissionRelations) {
List<SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO> oldFeatureRelations = saasPgroupPermissionRelations.stream()
.filter(e -> Objects.equals(e.getType(), OLD_FEATURE))
.collect(Collectors.toList());
@ -494,7 +494,7 @@ public class PrivateController {
return;
}
Map<Long, SaasFeature> saasFeatureMap = saasFeatureDao.listByIds(Lists.transform(oldFeatureRelations, SaasPgroupPermissionRelation::getFeatureId))
Map<Long, SaasFeature> saasFeatureMap = saasFeatureDao.listByIds(Lists.transform(oldFeatureRelations, SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO::getFeatureId))
.stream()
.collect(Collectors.toMap(SaasFeature::getId, Function.identity()));

View File

@ -1,17 +1,23 @@
package cn.axzo.tyr.server.controller.v2;
import cn.axzo.foundation.page.PageResp;
import cn.axzo.foundation.result.ApiResult;
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.req.ListRoleReq;
import cn.axzo.tyr.feign.enums.RoleTypeEnum;
import cn.axzo.tyr.feign.req.PageRoleReq;
import cn.axzo.tyr.feign.resp.RoleFeatureResourceResp;
import cn.axzo.tyr.feign.resp.RoleResp;
import cn.axzo.tyr.server.service.RoleService;
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.List;
import java.util.Optional;
import java.util.stream.Collectors;
@Slf4j
@ -22,14 +28,81 @@ public class RoleController implements RoleApi {
private RoleService roleService;
@Override
public ApiResult<List<RoleResp>> list(ListRoleReq req) {
List<SaasRoleRes> list = roleService.list(cn.axzo.tyr.client.model.req.ListRoleReq.builder().build());
return ApiResult.success(list.stream()
.map(e -> {
RoleResp result = RoleResp.builder().build();
BeanUtils.copyProperties(e, result);
return result;
public ApiResult<PageResp<RoleResp>> page(PageRoleReq req) {
check(req);
PageResp<SaasRoleRes> page = roleService.page(from(req));
return ApiResult.success(PageResp.<RoleResp>builder()
.total(page.getTotal())
.size(page.getSize())
.current(page.getCurrent())
.data(page.getData().stream()
.map(this::from)
.collect(Collectors.toList()))
.build());
}
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));
result.setRoleTypes(Optional.ofNullable(req.getRoleTypes())
.map(e -> e.stream()
.map(RoleTypeEnum::getValue)
.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());
return result;
}
private RoleResp from(SaasRoleRes saasRoleRes) {
RoleResp result = RoleResp.builder().build();
BeanUtils.copyProperties(saasRoleRes, result);
result.setRoleFeatureResources(saasRoleRes.getSaasPermissions().stream()
.map(permission -> {
RoleFeatureResourceResp roleFeatureResourceResp = RoleFeatureResourceResp.builder().build();
BeanUtils.copyProperties(permission, roleFeatureResourceResp);
// roleFeatureResourceResp.setUniCode();
roleFeatureResourceResp.setTags(Optional.ofNullable(permission.getTags())
.map(tags -> tags.stream()
.map(RolePermissionTagEnum::getDesc)
.collect(Collectors.toSet())
)
.orElse(null));
return roleFeatureResourceResp;
})
.collect(Collectors.toList()));
return result;
}
private void check(PageRoleReq req) {
}
}

View File

@ -1,7 +1,9 @@
package cn.axzo.tyr.server.service;
import cn.axzo.foundation.page.PageResp;
import cn.axzo.tyr.client.model.enums.RolePermissionTagEnum;
import cn.axzo.tyr.client.model.req.PagePgroupPermissionRelationReq;
import cn.axzo.tyr.client.model.res.SaasFeatureResourceResp;
import cn.axzo.tyr.client.model.vo.SaveOrUpdateRoleVO;
import cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelation;
import com.baomidou.mybatisplus.extension.service.IService;
@ -10,14 +12,16 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
import java.util.Set;
public interface SaasPgroupPermissionRelationService extends IService<SaasPgroupPermissionRelation> {
void saveOrUpdate(UpsertPermissionRelationParam param);
PageResp<SaasPgroupPermissionRelation> page(PagePgroupPermissionRelationReq param);
PageResp<SaasPgroupPermissionRelationDTO> page(PagePgroupPermissionRelationReq param);
List<SaasPgroupPermissionRelation> list(PagePgroupPermissionRelationReq param);
List<SaasPgroupPermissionRelationDTO> list(PagePgroupPermissionRelationReq param);
void delete(DeleteParam param);
@ -61,4 +65,64 @@ public interface SaasPgroupPermissionRelationService extends IService<SaasPgroup
class DeleteParam {
private List<Long> ids;
}
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
class SaasPgroupPermissionRelationDTO {
private Long id;
private Date createAt;
private Date updateAt;
/**
* 权限集id
*/
private Long groupId;
/**
* 功能id
*/
private Long featureId;
/**
* 创建者
*/
private Long createBy;
/**
* 更新者
*/
private Long updateBy;
/**
* 关联类型0saas_feature,1:saas_feature_resource
* 暂时的因为cms端会有灰度数据从saas_feature和saas_feature_resource出
*/
private Integer type;
/**
* 菜单资源类型1-菜单 2-页面 3-应用入口 4-组件
* 冗余菜单资源类型是在cms端查询菜单和页面时方便快速查询
* type = 0时featureType是saas_feature表的featureType
* type = 1时featureType是saas_feature_resource表的featureType
* 后面会全部切换到saas_feature_resource
* FeatureResourceType
*/
private Integer featureType;
/**
* featureId所在端
*/
private String terminal;
/**
* 标签
*/
private Set<RolePermissionTagEnum> tags;
private SaasFeatureResourceResp saasFeatureResource;
}
}

View File

@ -0,0 +1,141 @@
package cn.axzo.tyr.server.service;
import cn.axzo.foundation.dao.support.wrapper.CriteriaField;
import cn.axzo.foundation.dao.support.wrapper.Operator;
import cn.axzo.foundation.page.IPageReq;
import cn.axzo.foundation.page.PageResp;
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.server.repository.entity.SaasPgroupRoleRelation;
import com.baomidou.mybatisplus.extension.service.IService;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.Date;
import java.util.List;
import java.util.Set;
public interface SaasPgroupRoleRelationService extends IService<SaasPgroupRoleRelation> {
List<SaasPgroupRoleRelationDTO> list(ListSaasPgroupRoleRelationParam param);
PageResp<SaasPgroupRoleRelationDTO> page(PageSaasPgroupRoleRelationParam param);
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
class ListSaasPgroupRoleRelationParam {
@CriteriaField(field = "roleId", operator = Operator.IN)
private Set<Long> roleIds;
@CriteriaField(field = "groupId", operator = Operator.IN)
private Set<Long> groupIds;
@CriteriaField(ignore = true)
private Boolean needRole;
/**
* 查询featureResource需要
* 组装在pgroupPermissionRelations.SaasFeatureResourceResp
*/
@CriteriaField(ignore = true)
private Boolean needFeatureResource;
/**
* 只查询featureId跟pgroupId的关联关系记录
* 组装在pgroupPermissionRelations
*/
@CriteriaField(ignore = true)
private Boolean needFeatureResourceRelation;
/**
* 根据权限标签去过滤角色对应的权限
* 只有在needPermission = true时才生效
*/
@CriteriaField(ignore = true)
private Set<RolePermissionTagEnum> permissionTags;
/**
* 查询权限点时会根据端过滤增加效率目前只有CMS端的新版本才冗余了端
*/
@CriteriaField(ignore = true)
private String terminal;
@CriteriaField(ignore = true)
private List<Long> featureIds;
/**
* 查询菜单树节点类型
*/
@CriteriaField(ignore = true)
private List<FeatureResourceType> featureResourceTypes;
/**
* 新旧feature
*/
@CriteriaField(ignore = true)
private Integer type;
}
@SuperBuilder
@Data
@NoArgsConstructor
@AllArgsConstructor
class PageSaasPgroupRoleRelationParam extends ListSaasPgroupRoleRelationParam implements IPageReq {
@CriteriaField(ignore = true)
Integer page;
@CriteriaField(ignore = true)
Integer pageSize;
/**
* 排序使用示例createTime__DESC
*/
@CriteriaField(ignore = true)
List<String> sort;
}
@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
class SaasPgroupRoleRelationDTO {
private Long id;
private Date createAt;
private Date updateAt;
/**
* 角色id
*/
private Long roleId;
/**
* 权限集id
*/
private Long groupId;
/**
* 创建者
*/
private Long createBy;
/**
* 更新者
*/
private Long updateBy;
private SaasRoleRes saasRoleRes;
private List<SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO> pgroupPermissionRelations;
}
}

View File

@ -87,12 +87,14 @@ import cn.axzo.tyr.server.service.RoleService;
import cn.axzo.tyr.server.service.SaasFeatureResourceService;
import cn.axzo.tyr.server.service.SaasPgroupPermissionRelationOperateLogService;
import cn.axzo.tyr.server.service.SaasPgroupPermissionRelationService;
import cn.axzo.tyr.server.service.SaasPgroupRoleRelationService;
import cn.axzo.tyr.server.service.SaasRoleGroupRelationService;
import cn.axzo.tyr.server.service.SaasRoleGroupService;
import cn.axzo.tyr.server.service.SaasRoleUserRelationService;
import cn.axzo.tyr.server.util.RpcInternalUtil;
import cn.axzo.tyr.server.utils.RpcExternalUtil;
import cn.azxo.framework.common.constatns.Constants;
import cn.azxo.framework.common.utils.LogUtil;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
@ -100,6 +102,7 @@ import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.lang.Pair;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -212,6 +215,8 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
private MqProducer mqProducer;
@Autowired
private WorkspaceApi workspaceApi;
@Autowired
private SaasPgroupRoleRelationService saasPgroupRoleRelationService;
private static final String TARGET_TYPE = "saasFeatureResourceId";
@ -1391,13 +1396,18 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
@Override
public List<SaasRoleRes> list(ListRoleReq param) {
return PageConverter.drainAll(pageNumber -> {
PageRoleReq pageParam = PageRoleReq.builder().build();
BeanUtils.copyProperties(param, pageParam);
pageParam.setPage(pageNumber);
pageParam.setPageSize(10000);
return page(pageParam);
});
PageRoleReq pageParam = PageRoleReq.builder().build();
BeanUtils.copyProperties(param, pageParam);
pageParam.setPage(1);
pageParam.setPageSize(5000);
List<SaasRoleRes> data = page(pageParam).getData();
// XXXlist接口返回数据太大为了不影响业务先返回同时输出error日志以便告警研发排查请求来源和业务是否正确
if (data.size() > 5000) {
LogUtil.error(LogUtil.ErrorLevel.P1, LogUtil.ErrorType.ERROR_BUSINESS,
"单次请求role的条数过多只返回5000条信息请确认场景 param = {}", JSON.toJSONString(param));
}
return data;
}
@Override
@ -1445,7 +1455,7 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
Map<Long, List<SaasRoleUserV2DTO.SaasRoleUser>> saasRoleUsers = listSaasRoleUser(param, page.getRecords());
Map<Long, List<SaasPermissionRelationRes>> permissionRelations = listRolePermissionRelations(param, page.getRecords());
ºº
return PageConverter.toResp(page, (record) -> from(record,
saasRoleGroups,
BooleanUtils.isTrue(param.getNeedPermissionOld()) ? saasPermissionsOld : saasPermissions,
@ -1539,58 +1549,29 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
return Collections.emptyMap();
}
List<SaasPgroupRoleRelation> saasPgroupRoleRelations = saasPgroupRoleRelationDao.findByRoleIds(Lists.transform(saasRoles, SaasRole::getId));
if (CollectionUtils.isEmpty(saasPgroupRoleRelations)) {
return Collections.emptyMap();
}
List<SaasPgroupPermissionRelation> saasPgroupPermissionRelations = saasPgroupPermissionRelationService.list(PagePgroupPermissionRelationReq.builder()
.groupIds(Lists.transform(saasPgroupRoleRelations, SaasPgroupRoleRelation::getGroupId))
.featureIds(param.getFeatureIds())
.type(NEW_FEATURE)
.tags(param.getPermissionTags())
.terminal(param.getTerminal())
.build());
if (CollectionUtils.isEmpty(saasPgroupPermissionRelations)) {
return Collections.emptyMap();
}
Map<Long, ResourcePermission> resourcePermissions = saasFeatureResourceService.permissionQuery(ResourcePermissionQueryDTO.builder()
.ids(Lists.transform(saasPgroupPermissionRelations, SaasPgroupPermissionRelation::getFeatureId))
.build())
return saasPgroupRoleRelationService.list(SaasPgroupRoleRelationService.ListSaasPgroupRoleRelationParam.builder()
.roleIds(saasRoles.stream()
.map(SaasRole::getId)
.collect(Collectors.toSet()))
.needFeatureResource(true)
.permissionTags(param.getPermissionTags())
.featureIds(param.getFeatureIds())
.terminal(param.getTerminal())
.type(NEW_FEATURE)
.build())
.stream()
.collect(Collectors.toMap(ResourcePermission::getId, Function.identity()));
Map<Long, List<SaasPgroupPermissionRelation>> pgroupPermissions = saasPgroupPermissionRelations.stream()
.collect(Collectors.groupingBy(SaasPgroupPermissionRelation::getGroupId));
return saasPgroupRoleRelations.stream()
.map(e -> {
List<SaasPgroupPermissionRelation> permissions = pgroupPermissions.get(e.getGroupId());
if (CollectionUtils.isEmpty(permissions)) {
return null;
}
return permissions.stream()
.map(permission -> {
ResourcePermission saasPermissionRes = resourcePermissions.get(permission.getFeatureId());
return SaasPermissionWrapper.from(e, saasPermissionRes, permission);
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
})
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.collect(Collectors.groupingBy(SaasPermissionWrapper::getRoleId,
Collectors.mapping(e -> SaasPermissionRes.builder()
.id(e.getId())
.featureCode(e.getFeatureCode())
.tags(e.getTags())
.terminal(e.getTerminal())
.build(),
Collectors.toList())));
.filter(e -> CollectionUtils.isNotEmpty(e.getPgroupPermissionRelations()))
.collect(Collectors.toMap(SaasPgroupRoleRelationService.SaasPgroupRoleRelationDTO::getRoleId,
e -> e.getPgroupPermissionRelations().stream()
.filter(relation -> Objects.nonNull(relation.getSaasFeatureResource()))
.map(relation -> SaasPermissionRes.builder()
.id(relation.getSaasFeatureResource().getId())
.featureCode(relation.getSaasFeatureResource().getUniCode())
.uniCode(relation.getSaasFeatureResource().getUniCode())
.tags(relation.getTags())
.terminal(relation.getSaasFeatureResource().getTerminal())
.build())
.collect(Collectors.toList())));
}
@Data
@ -1606,6 +1587,8 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
*/
private String featureCode;
private String uniCode;
private Long roleId;
private Set<RolePermissionTagEnum> tags;
@ -1617,7 +1600,7 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
public static SaasPermissionWrapper from(SaasPgroupRoleRelation saasPgroupRoleRelation,
ResourcePermission saasPermissionRes,
SaasPgroupPermissionRelation saasPgroupPermissionRelation) {
SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO saasPgroupPermissionRelation) {
if (saasPermissionRes == null) {
return null;
}
@ -1627,6 +1610,7 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
.roleId(saasPgroupRoleRelation.getRoleId())
.tags(saasPgroupPermissionRelation.getTags())
.terminal(saasPermissionRes.getTerminal())
.uniCode(saasPermissionRes.getFeatureCode())
.build();
}
}
@ -1688,9 +1672,10 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
.collect(Collectors.toList());
PagePgroupPermissionRelationReq pagePgroupPermissionRelationReq = PagePgroupPermissionRelationReq.builder()
.featureIds(featureIds)
.needRole(true)
.build();
List<Long> groupIds = saasPgroupPermissionRelationService.list(pagePgroupPermissionRelationReq).stream()
.map(SaasPgroupPermissionRelation::getGroupId)
.map(SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO::getGroupId)
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(groupIds)) {
@ -1927,7 +1912,7 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
return Collections.emptyMap();
}
List<SaasPgroupPermissionRelation> saasPgroupPermissionRelations = saasPgroupPermissionRelationService.list(PagePgroupPermissionRelationReq.builder()
List<SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO> saasPgroupPermissionRelations = saasPgroupPermissionRelationService.list(PagePgroupPermissionRelationReq.builder()
.groupIds(Lists.transform(saasPgroupRoleRelations, SaasPgroupRoleRelation::getGroupId))
.featureIds(param.getFeatureIds())
.type(OLD_FEATURE)
@ -1937,17 +1922,17 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
return Collections.emptyMap();
}
List<Long> featureIds = Lists.transform(saasPgroupPermissionRelations, SaasPgroupPermissionRelation::getFeatureId);
List<Long> featureIds = Lists.transform(saasPgroupPermissionRelations, SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO::getFeatureId);
Map<Long, SaasFeature> resourcePermissions = saasFeatureDao.listByIds(featureIds).stream()
.collect(Collectors.toMap(SaasFeature::getId, Function.identity()));
Map<Long, List<SaasPgroupPermissionRelation>> pgroupPermissions = saasPgroupPermissionRelations.stream()
.collect(Collectors.groupingBy(SaasPgroupPermissionRelation::getGroupId));
Map<Long, List<SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO>> pgroupPermissions = saasPgroupPermissionRelations.stream()
.collect(Collectors.groupingBy(SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO::getGroupId));
return saasPgroupRoleRelations.stream()
.map(e -> {
List<SaasPgroupPermissionRelation> permissions = pgroupPermissions.get(e.getGroupId());
List<SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO> permissions = pgroupPermissions.get(e.getGroupId());
if (CollectionUtils.isEmpty(permissions)) {
return null;
}
@ -1983,46 +1968,27 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
return Collections.emptyMap();
}
List<SaasPgroupRoleRelation> saasPgroupRoleRelations = saasPgroupRoleRelationDao.findByRoleIds(Lists.transform(saasRoles, SaasRole::getId));
if (CollectionUtils.isEmpty(saasPgroupRoleRelations)) {
return Collections.emptyMap();
}
PagePgroupPermissionRelationReq pagePgroupPermissionRelationReq = PagePgroupPermissionRelationReq.builder()
.groupIds(Lists.transform(saasPgroupRoleRelations, SaasPgroupRoleRelation::getGroupId))
.featureIds(param.getFeatureIds())
.featureResourceTypes(param.getFeatureResourceTypes())
.type(param.getType())
.terminal(param.getTerminal())
.build();
List<SaasPgroupPermissionRelation> saasPgroupPermissionRelations = saasPgroupPermissionRelationService.list(pagePgroupPermissionRelationReq);
Map<Long, List<SaasPgroupPermissionRelation>> pgroupPermissions = saasPgroupPermissionRelations.stream()
.collect(Collectors.groupingBy(SaasPgroupPermissionRelation::getGroupId));
return saasPgroupRoleRelations.stream()
.map(e -> {
List<SaasPgroupPermissionRelation> permissionRelations = pgroupPermissions.get(e.getGroupId());
if (CollectionUtils.isEmpty(permissionRelations)) {
return null;
}
return permissionRelations.stream()
.map(permissionRelation -> SaasPermissionRelationWrapper.from(e, permissionRelation))
.filter(Objects::nonNull)
.collect(Collectors.toList());
})
.filter(Objects::nonNull)
.flatMap(Collection::stream)
.collect(Collectors.groupingBy(SaasPermissionRelationWrapper::getRoleId,
Collectors.mapping(e -> SaasPermissionRelationRes.builder()
.featureId(e.getFeatureId())
.type(e.getType())
.featureType(e.getFeatureType())
.tags(e.getTags())
.build(),
Collectors.toList())));
return saasPgroupRoleRelationService.list(SaasPgroupRoleRelationService.ListSaasPgroupRoleRelationParam.builder()
.roleIds(saasRoles.stream()
.map(SaasRole::getId)
.collect(Collectors.toSet()))
.needFeatureResourceRelation(true)
.featureIds(param.getFeatureIds())
.featureResourceTypes(param.getFeatureResourceTypes())
.type(param.getType())
.terminal(param.getTerminal())
.build())
.stream()
.filter(e -> CollectionUtils.isNotEmpty(e.getPgroupPermissionRelations()))
.collect(Collectors.toMap(SaasPgroupRoleRelationService.SaasPgroupRoleRelationDTO::getRoleId,
e -> e.getPgroupPermissionRelations().stream()
.map(relation -> SaasPermissionRelationRes.builder()
.featureId(relation.getFeatureId())
.type(relation.getType())
.featureType(relation.getFeatureType())
.tags(relation.getTags())
.build())
.collect(Collectors.toList())));
}
private void saveOperateLog(Long featureId, Long operatorId, List<FeatureRoleRelationReq.RelationRoleSettings> req) {
@ -2110,52 +2076,4 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
saasPgroupPermissionRelationOperateLogService.batchSave(Lists.newArrayList(operateLog));
}
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
static class SaasPermissionRelationWrapper {
/**
* 角色id
*/
private Long roleId;
/**
* 菜单资源树节点id
*/
private Long featureId;
/**
* 新旧菜单资源数标识
*/
private Integer type;
/**
* 菜单资源树节点类型
*/
private Integer featureType;
/**
* 权限点标签
* 在职:JOINED
* 离场:LEAVE
*/
private Set<RolePermissionTagEnum> tags;
public static SaasPermissionRelationWrapper from(SaasPgroupRoleRelation saasPgroupRoleRelation,
SaasPgroupPermissionRelation permissionRelation) {
if (permissionRelation == null) {
return null;
}
return SaasPermissionRelationWrapper.builder()
.roleId(saasPgroupRoleRelation.getRoleId())
.featureId(permissionRelation.getFeatureId())
.type(permissionRelation.getType())
.featureType(permissionRelation.getFeatureType())
.tags(permissionRelation.getTags())
.build();
}
}
}

View File

@ -304,7 +304,7 @@ public class SaasFeatureResourceServiceImpl extends ServiceImpl<SaasFeatureResou
return Collections.emptyMap();
}
List<SaasPgroupPermissionRelation> relations = saasPgroupPermissionRelationService.list(PagePgroupPermissionRelationReq.builder()
List<SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO> relations = saasPgroupPermissionRelationService.list(PagePgroupPermissionRelationReq.builder()
.featureIds(Lists.transform(descendants, SaasFeatureResource::getId))
.tags(detailFeatureResourceReq.getTags())
.build());
@ -312,7 +312,7 @@ public class SaasFeatureResourceServiceImpl extends ServiceImpl<SaasFeatureResou
return Collections.emptyMap();
}
List<Long> groupIds = Lists.transform(relations, SaasPgroupPermissionRelation::getGroupId);
List<Long> groupIds = Lists.transform(relations, SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO::getGroupId);
List<SaasPgroupRoleRelation> saasPgroupRoleRelations = saasPgroupRoleRelationDao.listByGroupIds(groupIds);
if (CollectionUtils.isEmpty(saasPgroupRoleRelations)) {
@ -1000,13 +1000,13 @@ public class SaasFeatureResourceServiceImpl extends ServiceImpl<SaasFeatureResou
.featureIds(Lists.transform(deleteFeatureResource, SaasFeatureResourceResp::getId))
.type(NEW_FEATURE)
.build();
List<SaasPgroupPermissionRelation> permissionRelations = saasPgroupPermissionRelationService.list(pagePgroupPermissionRelationReq);
List<SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO> permissionRelations = saasPgroupPermissionRelationService.list(pagePgroupPermissionRelationReq);
if (CollectionUtils.isEmpty(permissionRelations)) {
return;
}
SaasPgroupPermissionRelationService.DeleteParam deleteParam = SaasPgroupPermissionRelationService.DeleteParam.builder()
.ids(Lists.transform(permissionRelations, SaasPgroupPermissionRelation::getId))
.ids(Lists.transform(permissionRelations, SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO::getId))
.build();
saasPgroupPermissionRelationService.delete(deleteParam);
}

View File

@ -7,9 +7,12 @@ import cn.axzo.foundation.page.PageResp;
import cn.axzo.tyr.client.common.enums.FeatureResourceType;
import cn.axzo.tyr.client.model.enums.RolePermissionTagEnum;
import cn.axzo.tyr.client.model.req.PagePgroupPermissionRelationReq;
import cn.axzo.tyr.client.model.req.PageSaasFeatureResourceReq;
import cn.axzo.tyr.client.model.res.SaasFeatureResourceResp;
import cn.axzo.tyr.server.repository.dao.SaasPgroupPermissionRelationDao;
import cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelation;
import cn.axzo.tyr.server.repository.mapper.SaasPgroupPermissionRelationMapper;
import cn.axzo.tyr.server.service.SaasFeatureResourceService;
import cn.axzo.tyr.server.service.SaasPgroupPermissionRelationService;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@ -19,16 +22,18 @@ import com.google.common.collect.Lists;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
@ -42,6 +47,8 @@ public class SaasPgroupPermissionRelationServiceImpl
implements SaasPgroupPermissionRelationService {
private final SaasPgroupPermissionRelationDao saasPgroupPermissionRelationDao;
private final SaasFeatureResourceService saasFeatureResourceService;
@Override
@Transactional(rollbackFor = Exception.class)
public void saveOrUpdate(UpsertPermissionRelationParam param) {
@ -94,7 +101,7 @@ public class SaasPgroupPermissionRelationServiceImpl
}
@Override
public PageResp<SaasPgroupPermissionRelation> page(PagePgroupPermissionRelationReq param) {
public PageResp<SaasPgroupPermissionRelationDTO> page(PagePgroupPermissionRelationReq param) {
QueryWrapper<SaasPgroupPermissionRelation> wrapper = QueryWrapperHelper.fromBean(param, SaasPgroupPermissionRelation.class);
wrapper.eq("is_delete", 0);
@ -117,11 +124,13 @@ public class SaasPgroupPermissionRelationServiceImpl
IPage<SaasPgroupPermissionRelation> page = this.page(PageConverter.toMybatis(param, SaasPgroupPermissionRelation.class), wrapper);
return PageConverter.toResp(page, Function.identity());
Map<Long, SaasFeatureResourceResp> saasFeatureResources = listSaasFeatureResource(page.getRecords(), param);
return PageConverter.toResp(page, (record) -> from(record, saasFeatureResources));
}
@Override
public List<SaasPgroupPermissionRelation> list(PagePgroupPermissionRelationReq param) {
public List<SaasPgroupPermissionRelationDTO> list(PagePgroupPermissionRelationReq param) {
return PageConverter.drainAll(pageNumber -> {
param.setPage(pageNumber);
// 减少io后续优化
@ -138,4 +147,29 @@ public class SaasPgroupPermissionRelationServiceImpl
}
this.removeByIds(param.getIds());
}
private SaasPgroupPermissionRelationDTO from(SaasPgroupPermissionRelation saasPgroupPermissionRelation,
Map<Long, SaasFeatureResourceResp> saasFeatureResources) {
SaasPgroupPermissionRelationDTO result = SaasPgroupPermissionRelationDTO.builder().build();
BeanUtils.copyProperties(saasPgroupPermissionRelation, result);
result.setSaasFeatureResource(saasFeatureResources.get(result.getFeatureId()));
return result;
}
private Map<Long, SaasFeatureResourceResp> listSaasFeatureResource(List<SaasPgroupPermissionRelation> saasPgroupPermissionRelations,
PagePgroupPermissionRelationReq param) {
if (CollectionUtils.isEmpty(saasPgroupPermissionRelations) || BooleanUtils.isNotTrue(param.getNeedFeatureResource())) {
return Collections.emptyMap();
}
return saasFeatureResourceService.list(PageSaasFeatureResourceReq.builder()
.ids(saasPgroupPermissionRelations.stream()
.map(SaasPgroupPermissionRelation::getFeatureId)
.distinct()
.collect(Collectors.toList()))
.build())
.stream()
.collect(Collectors.toMap(SaasFeatureResourceResp::getId, Function.identity()));
}
}

View File

@ -0,0 +1,116 @@
package cn.axzo.tyr.server.service.impl;
import cn.axzo.foundation.dao.support.converter.PageConverter;
import cn.axzo.foundation.dao.support.mysql.QueryWrapperHelper;
import cn.axzo.foundation.page.PageResp;
import cn.axzo.tyr.client.model.req.ListRoleReq;
import cn.axzo.tyr.client.model.req.PagePgroupPermissionRelationReq;
import cn.axzo.tyr.client.model.res.SaasRoleRes;
import cn.axzo.tyr.server.repository.entity.SaasPgroupRoleRelation;
import cn.axzo.tyr.server.repository.mapper.SaasPgroupRoleRelationMapper;
import cn.axzo.tyr.server.service.RoleService;
import cn.axzo.tyr.server.service.SaasPgroupPermissionRelationService;
import cn.axzo.tyr.server.service.SaasPgroupRoleRelationService;
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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.BooleanUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import static cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelation.NEW_FEATURE;
@Slf4j
@Service
public class SaasPgroupRoleRelationServiceImpl extends ServiceImpl<SaasPgroupRoleRelationMapper, SaasPgroupRoleRelation>
implements SaasPgroupRoleRelationService {
@Autowired
private RoleService roleService;
@Autowired
private SaasPgroupPermissionRelationService saasPgroupPermissionRelationService;
@Override
public List<SaasPgroupRoleRelationDTO> list(ListSaasPgroupRoleRelationParam param) {
PageSaasPgroupRoleRelationParam pageParam = PageSaasPgroupRoleRelationParam.builder().build();
BeanUtils.copyProperties(param, pageParam);
return PageConverter.drainAll(pageNumber -> {
pageParam.setPage(pageNumber);
pageParam.setPageSize(1000);
return page(pageParam);
});
}
@Override
public PageResp<SaasPgroupRoleRelationDTO> page(PageSaasPgroupRoleRelationParam param) {
QueryWrapper<SaasPgroupRoleRelation> wrapper = QueryWrapperHelper.fromBean(param, SaasPgroupRoleRelation.class);
wrapper.eq("is_delete", 0);
IPage<SaasPgroupRoleRelation> page = this.page(PageConverter.toMybatis(param, SaasPgroupRoleRelation.class), wrapper);
Map<Long, SaasRoleRes> saasRoleRes = listRole(page.getRecords(), param);
Map<Long, List<SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO>> pgrouupPermissionRelations = listFeatureResource(page.getRecords(), param);
return PageConverter.toResp(page, (record) -> from(record, saasRoleRes, pgrouupPermissionRelations));
}
private SaasPgroupRoleRelationDTO from(SaasPgroupRoleRelation saasPgroupRoleRelation,
Map<Long, SaasRoleRes> saasRoleRes,
Map<Long, List<SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO>> pgrouupPermissionRelations) {
SaasPgroupRoleRelationDTO result = SaasPgroupRoleRelationDTO.builder().build();
BeanUtils.copyProperties(saasPgroupRoleRelation, result);
result.setSaasRoleRes(saasRoleRes.get(result.getRoleId()));
result.setPgroupPermissionRelations(pgrouupPermissionRelations.get(result.getGroupId()));
return result;
}
private Map<Long, SaasRoleRes> listRole(List<SaasPgroupRoleRelation> saasPgroupRoleRelations,
PageSaasPgroupRoleRelationParam param) {
if (CollectionUtils.isEmpty(saasPgroupRoleRelations) || BooleanUtils.isNotTrue(param.getNeedRole())) {
return Collections.emptyMap();
}
return roleService.list(ListRoleReq.builder()
.roleIds(Lists.transform(saasPgroupRoleRelations, SaasPgroupRoleRelation::getRoleId))
.build())
.stream()
.collect(Collectors.toMap(SaasRoleRes::getId, Function.identity()));
}
private Map<Long, List<SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO>> listFeatureResource(List<SaasPgroupRoleRelation> saasPgroupRoleRelations,
PageSaasPgroupRoleRelationParam param) {
if (CollectionUtils.isEmpty(saasPgroupRoleRelations) ||
(BooleanUtils.isNotTrue(param.getNeedFeatureResource()) && BooleanUtils.isNotTrue(param.getNeedFeatureResourceRelation()))) {
return Collections.emptyMap();
}
return saasPgroupPermissionRelationService.list(PagePgroupPermissionRelationReq.builder()
.groupIds(saasPgroupRoleRelations.stream()
.map(SaasPgroupRoleRelation::getGroupId)
.distinct()
.collect(Collectors.toList()))
.needFeatureResource(param.getNeedFeatureResource())
.featureIds(param.getFeatureIds())
.tags(param.getPermissionTags())
.type(param.getType())
.terminal(param.getTerminal())
.featureResourceTypes(param.getFeatureResourceTypes())
.build())
.stream()
.collect(Collectors.groupingBy(SaasPgroupPermissionRelationService.SaasPgroupPermissionRelationDTO::getGroupId));
}
}

View File

@ -0,0 +1,116 @@
package cn.axzo.tyr.server.controller.v2;
import cn.axzo.tyr.base.BaseTest;
import cn.axzo.tyr.base.MysqlDataLoader;
import cn.axzo.tyr.feign.enums.RoleTypeEnum;
import cn.axzo.tyr.feign.req.PageRoleReq;
import cn.axzo.tyr.feign.resp.RoleResp;
import com.google.common.collect.Sets;
import org.assertj.core.util.Lists;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.MockitoAnnotations;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
class RoleControllerTest extends BaseTest {
@Autowired
private MysqlDataLoader mysqlDataLoader;
@Autowired
private RoleController roleController;
@BeforeEach
@Override
public void setup() {
super.setup();
mysqlDataLoader.loadFromClassName(getClass().getSimpleName());
MockitoAnnotations.initMocks(this);
}
@Test
void list() {
List<RoleResp> roleResps = roleController.list(PageRoleReq.builder()
.roleIds(Sets.newHashSet(24425L))
.build())
.getData();
Assertions.assertEquals(roleResps.size(), 1);
roleResps = roleController.list(PageRoleReq.builder()
.workspaceType(6)
.build())
.getData();
Assertions.assertEquals(roleResps.size(), 2);
roleResps = roleController.list(PageRoleReq.builder()
.isDisplay(true)
.build())
.getData();
Assertions.assertEquals(roleResps.size(), 9);
roleResps = roleController.list(PageRoleReq.builder()
.roleCode("oms:project_manager")
.build())
.getData();
Assertions.assertEquals(roleResps.size(), 1);
roleResps = roleController.list(PageRoleReq.builder()
.workspaceIds(Sets.newHashSet(3L, 0L))
.build())
.getData();
Assertions.assertEquals(roleResps.size(), 5);
roleResps = roleController.list(PageRoleReq.builder()
.ouIds(Sets.newHashSet(4L, 0L))
.build())
.getData();
Assertions.assertEquals(roleResps.size(), 5);
roleResps = roleController.list(PageRoleReq.builder()
.enabled(true)
.build())
.getData();
Assertions.assertEquals(roleResps.size(), 9);
roleResps = roleController.list(PageRoleReq.builder()
.roleTypes(Sets.newHashSet(RoleTypeEnum.SUPER_ADMIN))
.build())
.getData();
Assertions.assertEquals(roleResps.size(), 4);
roleResps = roleController.list(PageRoleReq.builder()
.workspaceOuPairs(Lists.newArrayList(PageRoleReq.WorkspaceOuPair.builder()
.workspaceId(3L)
.ouId(4L)
.build()))
.build())
.getData();
Assertions.assertEquals(roleResps.size(), 1);
roleResps = roleController.list(PageRoleReq.builder()
.roleCodes(Sets.newHashSet("ou_superadmin"))
.build())
.getData();
Assertions.assertEquals(roleResps.size(), 1);
roleResps = roleController.list(PageRoleReq.builder()
.roleGroupCodes(Sets.newHashSet("omsSuperAdminGroup"))
.build())
.getData();
Assertions.assertEquals(roleResps.size(), 1);
roleResps = roleController.list(PageRoleReq.builder()
.cooperateShipTypes(Sets.newHashSet(1))
.build())
.getData();
Assertions.assertEquals(roleResps.size(), 2);
roleResps = roleController.list(PageRoleReq.builder()
.roleIds(Sets.newHashSet(24425L))
.needFeatureResources(true)
.build())
.getData();
Assertions.assertEquals(roleResps.size(), 1);
Assertions.assertEquals(roleResps.get(0).getRoleFeatureResources().size(), 10);
}
}

View File

@ -7,7 +7,9 @@ import cn.axzo.apollo.workspace.api.workspace.res.SimpleWorkspaceRes;
import cn.axzo.basics.profiles.api.UserProfileServiceApi;
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.common.enums.RoleTypeEnum;
import cn.axzo.tyr.client.model.enums.RolePermissionTagEnum;
import cn.axzo.tyr.client.model.req.ListRoleReq;
import cn.axzo.tyr.client.model.req.QueryByIdentityIdTypeReq;
import cn.axzo.tyr.client.model.req.QuerySaasRoleReq;
@ -30,6 +32,9 @@ import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import static cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelation.NEW_FEATURE;
import static cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelation.OLD_FEATURE;
class RoleServiceTest extends BaseTest {
@Autowired
@ -88,6 +93,201 @@ class RoleServiceTest extends BaseTest {
.roleIds(Lists.newArrayList(24425L, 25324L))
.build());
Assertions.assertEquals(roles.size(), 2);
roles = roleService.list(ListRoleReq.builder()
.roleIds(Lists.newArrayList(24425L))
.needPermission(true)
.build());
Assertions.assertEquals(roles.size(), 1);
Assertions.assertEquals(roles.get(0).getSaasPermissions().size(), 5);
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getId(), 153L);
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getFeatureCode(), "oms:menu_page");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getUniCode(), "oms:menu_page");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getSaasPermissions().get(0).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getTerminal(), "NT_OMS_WEB");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(1).getId(), 466L);
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(1).getFeatureCode(), "oms:imConfig_page");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(1).getUniCode(), "oms:imConfig_page");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(1).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getSaasPermissions().get(1).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(1).getTerminal(), "NT_OMS_WEB");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(2).getId(), 467L);
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(2).getFeatureCode(), "oms:im_robot_page");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(2).getUniCode(), "oms:im_robot_page");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(2).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getSaasPermissions().get(2).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(2).getTerminal(), "NT_OMS_WEB");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(3).getId(), 469L);
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(3).getFeatureCode(), "oms:msgPush_page");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(3).getUniCode(), "oms:msgPush_page");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(3).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getSaasPermissions().get(3).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(3).getTerminal(), "NT_OMS_WEB");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(4).getId(), 693L);
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(4).getFeatureCode(), "oms:detail_backPay_btn");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(4).getUniCode(), "oms:detail_backPay_btn");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(4).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getSaasPermissions().get(4).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(4).getTerminal(), "NT_OMS_WEB");
roles = roleService.list(ListRoleReq.builder()
.roleIds(Lists.newArrayList(24425L))
.featureIds(Lists.newArrayList(153L))
.needPermission(true)
.build());
Assertions.assertEquals(roles.size(), 1);
Assertions.assertEquals(roles.get(0).getSaasPermissions().size(), 1);
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getId(), 153L);
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getFeatureCode(), "oms:menu_page");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getUniCode(), "oms:menu_page");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getSaasPermissions().get(0).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getTerminal(), "NT_OMS_WEB");
roles = roleService.list(ListRoleReq.builder()
.roleIds(Lists.newArrayList(24425L))
.terminal("NT_OMS_WEB")
.needPermission(true)
.build());
Assertions.assertEquals(roles.size(), 1);
Assertions.assertEquals(roles.get(0).getSaasPermissions().size(), 1);
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getId(), 153L);
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getFeatureCode(), "oms:menu_page");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getUniCode(), "oms:menu_page");
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getSaasPermissions().get(0).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getSaasPermissions().get(0).getTerminal(), "NT_OMS_WEB");
roles = roleService.list(ListRoleReq.builder()
.roleIds(Lists.newArrayList(24425L))
.needPermissionRelation(true)
.build());
Assertions.assertEquals(roles.size(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().size(), 10);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getFeatureId(), 153L);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getFeatureType(), 2);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getType(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getPermissionRelations().get(0).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(1).getFeatureId(), 466L);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(1).getFeatureType(), 2);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(1).getType(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(1).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getPermissionRelations().get(1).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(2).getFeatureId(), 467L);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(2).getFeatureType(), 2);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(2).getType(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(2).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getPermissionRelations().get(2).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(3).getFeatureId(), 469L);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(3).getFeatureType(), 2);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(3).getType(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(3).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getPermissionRelations().get(3).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(4).getFeatureId(), 693L);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(4).getFeatureType(), 4);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(4).getType(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(4).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getPermissionRelations().get(4).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(5).getFeatureId(), 694L);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(5).getFeatureType(), 0);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(5).getType(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(5).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getPermissionRelations().get(5).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(6).getFeatureId(), 695L);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(6).getFeatureType(), 0);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(6).getType(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(6).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getPermissionRelations().get(6).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(7).getFeatureId(), 101996L);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(7).getFeatureType(), 2);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(7).getType(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(7).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getPermissionRelations().get(7).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(8).getFeatureId(), 102055L);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(8).getFeatureType(), 2);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(8).getType(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(8).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getPermissionRelations().get(8).getTags().contains(RolePermissionTagEnum.JOINED));
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(9).getFeatureId(), 102056L);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(9).getFeatureType(), 2);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(9).getType(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(9).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getPermissionRelations().get(9).getTags().contains(RolePermissionTagEnum.JOINED));
roles = roleService.list(ListRoleReq.builder()
.roleIds(Lists.newArrayList(24425L))
.needPermissionRelation(true)
.featureIds(Lists.newArrayList(153L))
.build());
Assertions.assertEquals(roles.size(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().size(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getFeatureId(), 153L);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getFeatureType(), 2);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getType(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getPermissionRelations().get(0).getTags().contains(RolePermissionTagEnum.JOINED));
roles = roleService.list(ListRoleReq.builder()
.roleIds(Lists.newArrayList(24425L))
.needPermissionRelation(true)
.type(OLD_FEATURE)
.build());
Assertions.assertEquals(roles.size(), 1);
Assertions.assertNull(roles.get(0).getPermissionRelations());
roles = roleService.list(ListRoleReq.builder()
.roleIds(Lists.newArrayList(24425L))
.needPermissionRelation(true)
.type(NEW_FEATURE)
.build());
Assertions.assertEquals(roles.size(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().size(), 10);
roles = roleService.list(ListRoleReq.builder()
.roleIds(Lists.newArrayList(24425L))
.needPermissionRelation(true)
.type(NEW_FEATURE)
.featureResourceTypes(Lists.newArrayList(FeatureResourceType.COMPONENT))
.build());
Assertions.assertEquals(roles.size(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().size(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getFeatureId(), 693L);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getFeatureType(), 4);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getType(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getPermissionRelations().get(0).getTags().contains(RolePermissionTagEnum.JOINED));
roles = roleService.list(ListRoleReq.builder()
.roleIds(Lists.newArrayList(24425L))
.needPermissionRelation(true)
.type(NEW_FEATURE)
.terminal("NT_OMS_WEB")
.build());
Assertions.assertEquals(roles.size(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().size(), 4);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getFeatureId(), 153L);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getFeatureType(), 2);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getType(), 1);
Assertions.assertEquals(roles.get(0).getPermissionRelations().get(0).getTags().size(), 1);
Assertions.assertTrue(roles.get(0).getPermissionRelations().get(0).getTags().contains(RolePermissionTagEnum.JOINED));
}
@Test

View File

@ -0,0 +1,93 @@
#-->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 (24425, '项目经理', '', 'init', 'oms:project_manager', -1, -1, 6, 6, 0, '2023-09-19 15:22:55', '2024-08-13 10:25:25', 2003043, 2003028, 1, 65535, 0, null, 0, '', 1, 2, 1);
INSERT INTO saas_role (id, NAME, description, role_type, role_code, workspace_id, owner_ou_id, product_unit_type, workspace_type, is_delete, create_at, update_at, create_by, update_by, fit_ou_type_bit, fit_ou_node_type_bit, position_template_id, project_team_manage_role_resource_id, from_pre_role_id, job_code, is_display, sort, enabled) VALUES (25324, '项目负责人', '', 'init', 'cms:mafb_project_commissioner', -1, -1, 5, 2, 0, '2023-10-23 17:49:59', '2024-08-13 10:25:40', -1, 9000399985, 1, 65535, 0, null, 0, '', 1, 1, 1);
INSERT INTO saas_role (id, NAME, description, role_type, role_code, workspace_id, owner_ou_id, product_unit_type, workspace_type, is_delete, create_at, update_at, create_by, update_by, fit_ou_type_bit, fit_ou_node_type_bit, position_template_id, project_team_manage_role_resource_id, from_pre_role_id, job_code, is_display, sort, enabled) VALUES (25326, '商务副经理', '', 'init', 'cms:mafb_business_vice_officer', -1, -1, 5, 2, 0, '2023-10-23 17:50:00', '2024-08-13 10:25:41', -1, 2006333, 1, 65535, 0, null, 0, '', 1, 2, 1);
INSERT INTO saas_role (id, NAME, description, role_type, role_code, workspace_id, owner_ou_id, product_unit_type, workspace_type, is_delete, create_at, update_at, create_by, update_by, fit_ou_type_bit, fit_ou_node_type_bit, position_template_id, project_team_manage_role_resource_id, from_pre_role_id, job_code, is_display, sort, enabled) VALUES (25327, '生产副经理', '', 'init', 'cms:mafb_productivity_vice_officer', -1, -1, 5, 2, 0, '2023-10-23 17:50:00', '2024-08-13 10:25:41', -1, 2006333, 1, 65535, 0, null, 0, '', 1, 3, 1);
INSERT INTO saas_role_group_relation (id, role_id, saas_role_group_id, is_delete, create_at, update_at) VALUES (12, 24425, 6, 0, '2023-09-19 15:22:55', '2023-09-19 15:22:55');
INSERT INTO saas_role_group_relation (id, role_id, saas_role_group_id, is_delete, create_at, update_at) VALUES (23, 25324, 13, 0, '2023-10-23 17:49:59', '2023-10-23 17:49:58');
INSERT INTO saas_role_group_relation (id, role_id, saas_role_group_id, is_delete, create_at, update_at) VALUES (25, 25326, 13, 0, '2023-10-23 17:50:00', '2023-10-23 17:49:59');
INSERT INTO saas_role_group_relation (id, role_id, saas_role_group_id, is_delete, create_at, update_at) VALUES (26, 25327, 13, 0, '2023-10-23 17:50:00', '2023-10-23 17:49:59');
INSERT INTO saas_role_group (id, workspace_type_code, ou_type_code, name, workspace_id, ou_id, parent_id, sort, code, category_code, is_delete, create_at, update_at)
VALUES (6, '6', '6', '研发中心', -1, -1, 0, 3, 'A1', '', 0, '2023-09-19 14:31:19', '2024-05-29 09:33:24');
INSERT INTO saas_role_group (id, workspace_type_code, ou_type_code, name, workspace_id, ou_id, parent_id, sort, code, category_code, is_delete, create_at, update_at)
VALUES (13, '2', '5', '专业分包', -1, -1, 0, 1, 'A2', '', 0, '2023-10-23 17:49:59', '2024-08-15 18:39:13');
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 (3416, '自定义', '', 'common', '', 3, 4, 1, 2, 0, '2022-10-19 15:52:33', '2024-09-29 17:16:27', 0, 0, 65535, 65535, 0, 0, 0, '', 1, 0, 1);
INSERT INTO saas_role_group_relation (id, role_id, saas_role_group_id, is_delete, create_at, update_at)
VALUES (549, 101100, 18, 0, '2024-09-25 21:47:42', '2024-09-25 21:47:42');
INSERT INTO saas_role_group_relation (id, role_id, saas_role_group_id, is_delete, create_at, update_at)
VALUES (550, 101101, 14, 0, '2024-09-25 21:47:42', '2024-09-25 21:47:42');
INSERT INTO saas_role_group_relation (id, role_id, saas_role_group_id, is_delete, create_at, update_at)
VALUES (551, 101102, 57, 0, '2024-09-25 21:47:42', '2024-09-25 21:47:42');
INSERT INTO saas_role_group (id, workspace_type_code, ou_type_code, name, workspace_id, ou_id, parent_id, sort, code, category_code, is_delete, create_at, update_at, path)
VALUES (14, '2', '1', '总包单位', -1, -1, 0, 1, '', '', 0, '2023-10-23 17:50:04', '2024-09-10 10:18:44', '14,');
INSERT INTO saas_role_group (id, workspace_type_code, ou_type_code, name, workspace_id, ou_id, parent_id, sort, code, category_code, is_delete, create_at, update_at, path)
VALUES (18, '1', '7', '企业通用', -1, -1, 0, 4, '', '', 0, '2023-10-23 17:50:15', '2024-09-10 10:18:44', '18,');
INSERT INTO saas_role_group (id, workspace_type_code, ou_type_code, name, workspace_id, ou_id, parent_id, sort, code, category_code, is_delete, create_at, update_at, path)
VALUES (57, '6', '6', 'OMS超管组', -1, -1, 0, 9, 'omsSuperAdminGroup', '', 0, '2024-04-17 11:38:28', '2024-09-10 10:18:45', '57,');
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 (1158315, 28801, 101100, 3, 24510, 3, 4, 0, 0, 0, '2024-09-29 16:33:31', '2024-09-29 16:33:31', 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_pgroup_role_relation (id, role_id, group_id, is_delete, create_at, update_at, create_by, update_by)
VALUES (2193533, 24425, 862, 0, '2023-09-19 15:22:55', '2024-04-16 18:48:04', 2003043, 2003043);
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 (60976, 862, 466, 0, '2024-05-08 11:00:16', '2024-11-09 08:51:59', 9000243, 0, 1, 2, '', '["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 (60987, 862, 467, 0, '2024-05-08 11:01:06', '2024-11-09 08:51:59', 9000243, 0, 1, 2, '', '["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 (61155, 862, 469, 0, '2024-05-09 10:45:38', '2024-11-09 08:51:59', 9000243, 0, 1, 2, '', '["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 (67190, 862, 693, 0, '2024-06-07 14:34:38', '2024-11-09 08:51:59', 25923, 0, 1, 4, '', '["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 (67198, 862, 694, 0, '2024-06-07 14:34:42', '2024-11-09 08:51:59', 25923, 0, 1, 0, '', '["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 (67206, 862, 695, 0, '2024-06-07 14:34:47', '2024-11-09 08:51:59', 25923, 0, 1, 0, '', '["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 (5202137, 862, 153, 0, '2024-09-15 00:08:51', '2024-12-03 11:43:43', 9000404098, 9000400021, 1, 2, 'NT_OMS_WEB', '["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 (5212591, 862, 101996, 0, '2024-09-29 14:58:57', '2024-11-09 08:51:59', 89601, 0, 1, 2, 'NT_OMS_WEB', '["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 (5213026, 862, 102055, 0, '2024-09-30 16:32:35', '2024-11-09 08:51:59', 25923, 0, 1, 2, 'NT_OMS_WEB', '["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 (5213035, 862, 102056, 0, '2024-09-30 16:32:35', '2024-11-09 08:51:59', 25923, 0, 1, 2, 'NT_OMS_WEB', '["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 (153, 'oms:menu_page', '菜单管理', 2, 'NT_OMS_WEB', 0, 72, '528,72,153,', 0, '0', 0, 'oms:menu_page', 0, 1, '', 1, '/home/menuManage', 1, '', 1, 0, '{"moreIcon": "", "activeIcon": "", "terminalType": "", "terminalBizType": ""}', 1, 0, '2024-04-24 17:09:38', '2024-12-05 17:45:21', 59926, 9000400021, 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 (466, 'oms:imConfig_page', 'IM配置新版', 2, 'NT_OMS_WEB', 0, 80, '528,80,466,', 0, '0', 0, 'oms:imConfig_page', 6, 0, '', 1, '/msgCenter/IMConfig', 1, ' ', 1, 0, '{"moreIcon": "", "activeIcon": ""}', 1, 0, '2024-05-08 11:00:11', '2024-12-05 17:45:22', 9000243, 9000399676, 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 (467, 'oms:im_robot_page', 'IM机器人(新版)', 2, 'NT_OMS_WEB', 0, 80, '528,80,467,', 0, '0', 0, 'oms:im_robot_page', 7, 0, '', 1, '/msgCenter/IMRobot', 1, ' ', 1, 0, '{"moreIcon": "", "activeIcon": ""}', 1, 0, '2024-05-08 11:01:03', '2024-12-05 17:45:22', 9000243, 9000399676, 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 (469, 'oms:msgPush_page', '消息推送(新版)', 2, 'NT_OMS_WEB', 0, 76, '528,76,469,', 0, '', 0, 'oms:msgPush_page', 10, 1, '', 1, '/operationsManagement/msgPush', 1, ' ', 1, 0, null, 1, 0, '2024-05-09 10:45:35', '2024-12-05 17:45:22', 9000243, 9000243, 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 (693, 'oms:detail_backPay_btn', '查看投诉详情', 4, 'NT_OMS_WEB', 1, 612, '528,611,612,693,', 0, '', 0, 'oms:detail_backPay_btn', 0, 1, '', 1, '/home/complain-manage/backPayDetail', 1, ' ', 1, 0, null, 1, 1, '2024-06-07 10:55:16', '2024-12-05 17:45:22', 9000399478, 9000398292, 0);
#-->SaasRoleUserRelationServiceImplTest.sql

View File

@ -58,4 +58,40 @@ VALUES (197520, 28802, 24425, 3, 24511, 3, 4, 0, 0, 0, '2024-01-18 16:36:16', '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_pgroup_role_relation (id, role_id, group_id, is_delete, create_at, update_at, create_by, update_by)
VALUES (2193533, 24425, 862, 0, '2023-09-19 15:22:55', '2024-04-16 18:48:04', 2003043, 2003043);
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 (60976, 862, 466, 0, '2024-05-08 11:00:16', '2024-11-09 08:51:59', 9000243, 0, 1, 2, '', '["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 (60987, 862, 467, 0, '2024-05-08 11:01:06', '2024-11-09 08:51:59', 9000243, 0, 1, 2, '', '["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 (61155, 862, 469, 0, '2024-05-09 10:45:38', '2024-11-09 08:51:59', 9000243, 0, 1, 2, '', '["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 (67190, 862, 693, 0, '2024-06-07 14:34:38', '2024-11-09 08:51:59', 25923, 0, 1, 4, '', '["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 (67198, 862, 694, 0, '2024-06-07 14:34:42', '2024-11-09 08:51:59', 25923, 0, 1, 0, '', '["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 (67206, 862, 695, 0, '2024-06-07 14:34:47', '2024-11-09 08:51:59', 25923, 0, 1, 0, '', '["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 (5202137, 862, 153, 0, '2024-09-15 00:08:51', '2024-12-03 11:43:43', 9000404098, 9000400021, 1, 2, 'NT_OMS_WEB', '["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 (5212591, 862, 101996, 0, '2024-09-29 14:58:57', '2024-11-09 08:51:59', 89601, 0, 1, 2, 'NT_OMS_WEB', '["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 (5213026, 862, 102055, 0, '2024-09-30 16:32:35', '2024-11-09 08:51:59', 25923, 0, 1, 2, 'NT_OMS_WEB', '["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 (5213035, 862, 102056, 0, '2024-09-30 16:32:35', '2024-11-09 08:51:59', 25923, 0, 1, 2, 'NT_OMS_WEB', '["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 (153, 'oms:menu_page', '菜单管理', 2, 'NT_OMS_WEB', 0, 72, '528,72,153,', 0, '0', 0, 'oms:menu_page', 0, 1, '', 1, '/home/menuManage', 1, '', 1, 0, '{"moreIcon": "", "activeIcon": "", "terminalType": "", "terminalBizType": ""}', 1, 0, '2024-04-24 17:09:38', '2024-12-05 17:45:21', 59926, 9000400021, 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 (466, 'oms:imConfig_page', 'IM配置新版', 2, 'NT_OMS_WEB', 0, 80, '528,80,466,', 0, '0', 0, 'oms:imConfig_page', 6, 0, '', 1, '/msgCenter/IMConfig', 1, ' ', 1, 0, '{"moreIcon": "", "activeIcon": ""}', 1, 0, '2024-05-08 11:00:11', '2024-12-05 17:45:22', 9000243, 9000399676, 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 (467, 'oms:im_robot_page', 'IM机器人(新版)', 2, 'NT_OMS_WEB', 0, 80, '528,80,467,', 0, '0', 0, 'oms:im_robot_page', 7, 0, '', 1, '/msgCenter/IMRobot', 1, ' ', 1, 0, '{"moreIcon": "", "activeIcon": ""}', 1, 0, '2024-05-08 11:01:03', '2024-12-05 17:45:22', 9000243, 9000399676, 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 (469, 'oms:msgPush_page', '消息推送(新版)', 2, 'NT_OMS_WEB', 0, 76, '528,76,469,', 0, '', 0, 'oms:msgPush_page', 10, 1, '', 1, '/operationsManagement/msgPush', 1, ' ', 1, 0, null, 1, 0, '2024-05-09 10:45:35', '2024-12-05 17:45:22', 9000243, 9000243, 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 (693, 'oms:detail_backPay_btn', '查看投诉详情', 4, 'NT_OMS_WEB', 1, 612, '528,611,612,693,', 0, '', 0, 'oms:detail_backPay_btn', 0, 1, '', 1, '/home/complain-manage/backPayDetail', 1, ' ', 1, 0, null, 1, 1, '2024-06-07 10:55:16', '2024-12-05 17:45:22', 9000399478, 9000398292, 0);
#-->SaasRoleUserRelationServiceImplTest.sql

View File

@ -347,3 +347,7 @@ alter table saas_page_element add column `update_by` bigint DEFAULT NULL COMMENT
alter table saas_feature_resource modify column feature_code varchar(100) not null comment '资源编码-权限码';
alter table saas_feature_resource modify column uni_code varchar(100) default '' not null comment '唯一编码用于pre环境菜单同步';
-- alter table saas_pgroup_permission_relation add column `tags` json DEFAULT null COMMENT '标签';
alter table saas_pgroup_permission_relation add column `tags` VARCHAR(2048) NOT NULL DEFAULT '{}' COMMENT '标签';