Merge branch 'master' into feature/REQ-2524
# Conflicts: # tyr-api/src/main/java/cn/axzo/tyr/client/model/roleuser/req/RoleUserReq.java
This commit is contained in:
commit
439573efa5
@ -1,8 +1,12 @@
|
||||
package cn.axzo.tyr.client.feign;
|
||||
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.req.ListSaasRoleGroupParam;
|
||||
import cn.axzo.tyr.client.model.req.PageSaasRoleGroupParam;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||
import cn.axzo.tyr.client.model.req.UpdateRoleGroupOffsetReq;
|
||||
import cn.axzo.tyr.client.model.res.SaasRoleGroupDTO;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@ -72,4 +76,20 @@ public interface SaasRoleGroupApi {
|
||||
*/
|
||||
@PostMapping("/api/role/group/offset/update")
|
||||
ApiResult<Void> updateRoleGroupOffset(@Valid @RequestBody UpdateRoleGroupOffsetReq request);
|
||||
|
||||
/**
|
||||
* 角色分组page接口
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/saasRoleGroup/page")
|
||||
ApiResult<PageResp<SaasRoleGroupDTO>> page(@RequestBody PageSaasRoleGroupParam request);
|
||||
|
||||
/**
|
||||
* 角色分组list接口
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/saasRoleGroup/list")
|
||||
ApiResult<List<SaasRoleGroupDTO>> list(@RequestBody ListSaasRoleGroupParam request);
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import cn.axzo.tyr.client.model.req.ListRoleReq;
|
||||
import cn.axzo.tyr.client.model.req.PageRoleReq;
|
||||
import cn.axzo.tyr.client.model.req.QueryByIdentityIdTypeReq;
|
||||
import cn.axzo.tyr.client.model.req.QueryRoleByNameReq;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleReq;
|
||||
import cn.axzo.tyr.client.model.req.RoleWithUserQueryReq;
|
||||
import cn.axzo.tyr.client.model.req.TreeRoleReq;
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package cn.axzo.tyr.client.model.req;
|
||||
|
||||
import cn.axzo.foundation.dao.support.wrapper.CriteriaField;
|
||||
import cn.axzo.foundation.dao.support.wrapper.Operator;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
|
||||
@SuperBuilder
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ListSaasRoleGroupParam {
|
||||
|
||||
@CriteriaField(field = "workspaceTypeCode", operator = Operator.EQ)
|
||||
private Integer workspaceTypeCode;
|
||||
|
||||
@CriteriaField(field = "workspaceId", operator = Operator.EQ)
|
||||
private Long workspaceId;
|
||||
|
||||
@CriteriaField(field = "ouId", operator = Operator.EQ)
|
||||
private Long ouId;
|
||||
|
||||
@CriteriaField(ignore = true)
|
||||
private Boolean needRole;
|
||||
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
package cn.axzo.tyr.client.model.req;
|
||||
|
||||
import cn.axzo.foundation.dao.support.wrapper.CriteriaField;
|
||||
import cn.axzo.foundation.page.IPageReq;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@SuperBuilder
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PageSaasRoleGroupParam extends ListSaasRoleGroupParam implements IPageReq {
|
||||
|
||||
@CriteriaField(ignore = true)
|
||||
Integer page;
|
||||
|
||||
@CriteriaField(ignore = true)
|
||||
Integer pageSize;
|
||||
|
||||
/**
|
||||
* 排序:使用示例,createTime__DESC
|
||||
*/
|
||||
@CriteriaField(ignore = true)
|
||||
List<String> sort;
|
||||
|
||||
}
|
||||
@ -0,0 +1,67 @@
|
||||
package cn.axzo.tyr.client.model.res;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SaasRoleGroupDTO {
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 工作台类型字典code
|
||||
*/
|
||||
private String workspaceTypeCode;
|
||||
|
||||
/**
|
||||
* 单位类型字典code
|
||||
*/
|
||||
private String ouTypeCode;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 所属工作台id
|
||||
*/
|
||||
private Long workspaceId;
|
||||
|
||||
/**
|
||||
* 所属单位id
|
||||
*/
|
||||
private Long ouId;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 分组CODE
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 分类CODE, 用于代班长,小组长的权限分类。
|
||||
*/
|
||||
private String categoryCode;
|
||||
|
||||
/**
|
||||
* 上级分组id
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 角色信息
|
||||
*/
|
||||
private List<SaasRoleRes> saasRoles;
|
||||
}
|
||||
@ -69,6 +69,10 @@ public class RoleUserReq {
|
||||
*/
|
||||
private boolean isRecycleModel;
|
||||
|
||||
/**
|
||||
* 操作人
|
||||
*/
|
||||
private Long operator;
|
||||
/**
|
||||
* 更新时是否覆盖特殊角色
|
||||
* 这些角色id是在nacos上的配置,在cms的单位管理-通讯录不会回显该角色
|
||||
@ -77,8 +81,4 @@ public class RoleUserReq {
|
||||
* true:不覆盖
|
||||
*/
|
||||
private Boolean uncoverSpecialRoles;
|
||||
/**
|
||||
* 操作人
|
||||
*/
|
||||
private Long operator;
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.tyr.server.controller.permission;
|
||||
|
||||
import cn.axzo.basics.common.exception.ServiceException;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.feign.FeatureResourceApi;
|
||||
import cn.axzo.tyr.client.model.req.FeatureResourceTreeSaveReq;
|
||||
@ -58,9 +59,10 @@ public class FeatureResourceController implements FeatureResourceApi {
|
||||
|
||||
@Override
|
||||
public ApiResult<Void> deleteFeatureResource(Long featureId, Long operatorId) {
|
||||
log.info("deleteFeatureResource featureId : {}, operatorId : {}", featureId, operatorId);
|
||||
featureResourceService.deleteMenuFeature(featureId, operatorId);
|
||||
return ApiResult.ok();
|
||||
throw new ServiceException("暂时不支持删除权限点");
|
||||
// log.info("deleteFeatureResource featureId : {}, operatorId : {}", featureId, operatorId);
|
||||
// featureResourceService.deleteMenuFeature(featureId, operatorId);
|
||||
// return ApiResult.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -52,6 +52,8 @@ import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Collections;
|
||||
@ -194,7 +196,6 @@ public class SaasRoleController implements TyrSaasRoleApi {
|
||||
@Override
|
||||
public ApiResult<List<SaasRoleAndGroupVO>> queryInitRoleByWorkspaceId(String workspaceType) {
|
||||
return ApiResult.ok(roleService.queryInitRoleByWorkspaceId(workspaceType));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -2,10 +2,14 @@ package cn.axzo.tyr.server.controller.role;
|
||||
|
||||
import cn.axzo.basics.common.exception.ServiceException;
|
||||
import cn.axzo.foundation.exception.Axssert;
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.feign.SaasRoleGroupApi;
|
||||
import cn.axzo.tyr.client.model.req.ListSaasRoleGroupParam;
|
||||
import cn.axzo.tyr.client.model.req.PageSaasRoleGroupParam;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||
import cn.axzo.tyr.client.model.req.UpdateRoleGroupOffsetReq;
|
||||
import cn.axzo.tyr.client.model.res.SaasRoleGroupDTO;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleGroup;
|
||||
import cn.axzo.tyr.server.service.SaasRoleGroupService;
|
||||
@ -101,6 +105,16 @@ public class SaasRoleGroupController implements SaasRoleGroupApi {
|
||||
return ApiResult.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<PageResp<SaasRoleGroupDTO>> page(PageSaasRoleGroupParam request) {
|
||||
return ApiResult.ok(saasRoleGroupService.page(request));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiResult<List<SaasRoleGroupDTO>> list(ListSaasRoleGroupParam request) {
|
||||
return ApiResult.ok(saasRoleGroupService.list(request));
|
||||
}
|
||||
|
||||
/**
|
||||
* 只支持移动一位
|
||||
* @param request
|
||||
|
||||
@ -74,10 +74,10 @@ public class CMSOtherRoleJobHandler extends IJobHandler {
|
||||
log.info("CMSOtherRoleJobHandler start");
|
||||
// 查询无法回溯的角色
|
||||
List<SaasRole> oldRole = roleDao.lambdaQuery()
|
||||
.ne(SaasRole::getWorkspaceId, -1l)
|
||||
.ne(SaasRole::getWorkspaceId, -1L)
|
||||
.eq(SaasRole::getRoleType, "init")
|
||||
.in(SaasRole::getFitOuTypeBit, Arrays.asList(1, 2, 4, 8, 16))
|
||||
.eq(SaasRole::getFromPreRoleId, 0l)
|
||||
.eq(SaasRole::getFromPreRoleId, 0L)
|
||||
.eq(BaseEntity::getIsDelete, 0)
|
||||
.list();
|
||||
if (CollectionUtils.isEmpty(oldRole)) {
|
||||
|
||||
@ -141,8 +141,8 @@ public class CMSRoleJobHandler extends IJobHandler {
|
||||
roleGroup.setWorkspaceTypeCode(workspaceTypCode);
|
||||
roleGroup.setOuTypeCode(ouType);
|
||||
roleGroup.setName(groupName);
|
||||
roleGroup.setWorkspaceId(-1l);
|
||||
roleGroup.setOuId(-1l);
|
||||
roleGroup.setWorkspaceId(-1L);
|
||||
roleGroup.setOuId(-1L);
|
||||
roleGroup.setSort(1);
|
||||
roleGroupDao.save(roleGroup);
|
||||
|
||||
@ -151,10 +151,10 @@ public class CMSRoleJobHandler extends IJobHandler {
|
||||
SaasRole newRole = new SaasRole();
|
||||
newRole.setRoleType(RoleTypeEnum.INIT.getValue());
|
||||
newRole.setName(preRole.getName());
|
||||
newRole.setCreateBy(-1l);
|
||||
newRole.setUpdateBy(-1l);
|
||||
newRole.setOwnerOuId(-1l);
|
||||
newRole.setWorkspaceId(-1l);
|
||||
newRole.setCreateBy(-1L);
|
||||
newRole.setUpdateBy(-1L);
|
||||
newRole.setOwnerOuId(-1L);
|
||||
newRole.setWorkspaceId(-1L);
|
||||
roleDao.save(newRole);
|
||||
|
||||
// 创建角色分组关联关系
|
||||
|
||||
@ -64,8 +64,8 @@ public class OMSRoleJobHandler extends IJobHandler {
|
||||
roleGroup.setWorkspaceTypeCode("6");
|
||||
roleGroup.setOuTypeCode("6");
|
||||
roleGroup.setName("管理员");
|
||||
roleGroup.setWorkspaceId(-1l);
|
||||
roleGroup.setOuId(-1l);
|
||||
roleGroup.setWorkspaceId(-1L);
|
||||
roleGroup.setOuId(-1L);
|
||||
roleGroup.setSort(1);
|
||||
roleGroupDao.save(roleGroup);
|
||||
// 查询OMS的角色 workspaceType=6 OMS的角色
|
||||
@ -75,8 +75,8 @@ public class OMSRoleJobHandler extends IJobHandler {
|
||||
.list();
|
||||
// 重置老角色多余的字段
|
||||
oldRole.forEach(e -> {
|
||||
e.setWorkspaceId(-1l);
|
||||
e.setOwnerOuId(-1l);
|
||||
e.setWorkspaceId(-1L);
|
||||
e.setOwnerOuId(-1L);
|
||||
});
|
||||
roleDao.updateBatchById(oldRole);
|
||||
// 保存角色分组关联关系
|
||||
|
||||
@ -50,7 +50,7 @@ public class SaasRoleGroupDao extends ServiceImpl<SaasRoleGroupMapper, SaasRoleG
|
||||
public void delete(List<Long> id) {
|
||||
lambdaUpdate()
|
||||
.in(BaseEntity::getId,id)
|
||||
.set(BaseEntity::getIsDelete,1l)
|
||||
.set(BaseEntity::getIsDelete, 1L)
|
||||
.update();
|
||||
}
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ import cn.axzo.tyr.client.model.req.ChangeGroupLeaderRoleReq;
|
||||
import cn.axzo.tyr.client.model.req.FeatureRoleRelationReq;
|
||||
import cn.axzo.tyr.client.model.req.QueryByIdentityIdTypeReq;
|
||||
import cn.axzo.tyr.client.model.req.QueryRoleByNameReq;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleReq;
|
||||
import cn.axzo.tyr.client.model.req.RoleWithUserQueryReq;
|
||||
import cn.axzo.tyr.client.model.res.FeatureRoleRelationResp;
|
||||
|
||||
@ -1,6 +1,10 @@
|
||||
package cn.axzo.tyr.server.service;
|
||||
|
||||
import cn.axzo.foundation.page.PageResp;
|
||||
import cn.axzo.tyr.client.model.req.ListSaasRoleGroupParam;
|
||||
import cn.axzo.tyr.client.model.req.PageSaasRoleGroupParam;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||
import cn.axzo.tyr.client.model.res.SaasRoleGroupDTO;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleGroup;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
@ -41,4 +45,9 @@ public interface SaasRoleGroupService extends IService<SaasRoleGroup> {
|
||||
* @param type 1-仅查当前code 2-对应code角色组及子级角色组 3-仅对应code角色组的子级
|
||||
* **/
|
||||
List<SaasRoleGroup> listByCodes(List<String> codes, int type);
|
||||
|
||||
List<SaasRoleGroupDTO> list(ListSaasRoleGroupParam param);
|
||||
|
||||
PageResp<SaasRoleGroupDTO> page(PageSaasRoleGroupParam param);
|
||||
|
||||
}
|
||||
|
||||
@ -1191,7 +1191,7 @@ public class RoleServiceImpl extends ServiceImpl<SaasRoleMapper, SaasRole>
|
||||
BooleanUtils.isTrue(param.getNeedPermissionOld()) ? saasPermissionsOld : saasPermissions,
|
||||
saasRoleUsers));
|
||||
}
|
||||
|
||||
|
||||
private SaasRoleRes from(SaasRole saasRole,
|
||||
Map<Long, List<SaasRoleGroupRes>> saasRoleGroups,
|
||||
Map<Long, List<SaasPermissionRes>> saasPermissions,
|
||||
|
||||
@ -595,7 +595,7 @@ public class RoleUserService implements SaasRoleUserService {
|
||||
}
|
||||
|
||||
List<SaasPgroupPermissionRelation> saasPgroupPermissionRelations = saasPgroupPermissionRelationDao.lambdaQuery()
|
||||
.eq(SaasPgroupPermissionRelation::getGroupId, saasPgroupRoleRelations.get(0).getGroupId())
|
||||
.in(SaasPgroupPermissionRelation::getGroupId, saasPgroupRoleRelations.stream().map(SaasPgroupRoleRelation::getGroupId).collect(Collectors.toList()))
|
||||
.eq(SaasPgroupPermissionRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value).list();
|
||||
|
||||
return GetUserFeatureResourceIdsResp.builder().featureResourceIds(saasPgroupPermissionRelations.stream()
|
||||
|
||||
@ -318,22 +318,23 @@ public class SaasFeatureResourceServiceImpl implements SaasFeatureResourceServic
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CacheEvict(value = SaasFeatureResourceCacheService.CACHE_FEATURE_RESOURCE_TREE,allEntries = true)
|
||||
public void deleteMenuFeature(Long featureId, Long operatorId) {
|
||||
if (featureId == null) {
|
||||
return;
|
||||
}
|
||||
List<SaasFeatureResource> featureDescendant = featureResourceDao.lambdaQuery()
|
||||
.eq(BaseEntity::getIsDelete,0)
|
||||
.apply("FIND_IN_SET('" + featureId + "', path)")
|
||||
.list();
|
||||
List<Long> featureIds = featureDescendant.stream().map(SaasFeatureResource::getId).collect(Collectors.toList());
|
||||
pgroupPermissionRelationService.deleteByFeatureIds(featureIds);
|
||||
// 删除自己及自己的子集
|
||||
featureResourceDao.lambdaUpdate()
|
||||
.eq(BaseEntity::getIsDelete,0)
|
||||
.apply("FIND_IN_SET('" + featureId + "', path)")
|
||||
.set(SaasFeatureResource::getUpdateBy, operatorId)
|
||||
.set(BaseEntity::getIsDelete,1)
|
||||
.update();
|
||||
|
||||
// if (featureId == null) {
|
||||
// return;
|
||||
// }
|
||||
// List<SaasFeatureResource> featureDescendant = featureResourceDao.lambdaQuery()
|
||||
// .eq(BaseEntity::getIsDelete,0)
|
||||
// .apply("FIND_IN_SET('" + featureId + "', path)")
|
||||
// .list();
|
||||
// List<Long> featureIds = featureDescendant.stream().map(SaasFeatureResource::getId).collect(Collectors.toList());
|
||||
// pgroupPermissionRelationService.deleteByFeatureIds(featureIds);
|
||||
// // 删除自己及自己的子集
|
||||
// featureResourceDao.lambdaUpdate()
|
||||
// .eq(BaseEntity::getIsDelete,0)
|
||||
// .apply("FIND_IN_SET('" + featureId + "', path)")
|
||||
// .set(SaasFeatureResource::getUpdateBy, operatorId)
|
||||
// .set(BaseEntity::getIsDelete,1)
|
||||
// .update();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -3,21 +3,35 @@ package cn.axzo.tyr.server.service.impl;
|
||||
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
|
||||
import cn.axzo.basics.common.exception.ServiceException;
|
||||
import cn.axzo.foundation.exception.Axssert;
|
||||
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.ListSaasRoleGroupParam;
|
||||
import cn.axzo.tyr.client.model.req.PageSaasRoleGroupParam;
|
||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||
import cn.axzo.tyr.client.model.res.SaasRoleGroupDTO;
|
||||
import cn.axzo.tyr.client.model.res.SaasRoleRes;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasRoleGroupDao;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasRoleGroupRelationDao;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleGroup;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleGroupRelation;
|
||||
import cn.axzo.tyr.server.repository.mapper.SaasRoleGroupMapper;
|
||||
import cn.axzo.tyr.server.service.RoleService;
|
||||
import cn.axzo.tyr.server.service.SaasRoleGroupRelationService;
|
||||
import cn.axzo.tyr.server.service.SaasRoleGroupService;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
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.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -25,10 +39,12 @@ import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.axzo.tyr.server.config.exception.BizResultCode.CANT_DELETE_ROLE_GROUP;
|
||||
@ -40,6 +56,8 @@ public class SaasRoleGroupServiceImpl extends ServiceImpl<SaasRoleGroupMapper, S
|
||||
implements SaasRoleGroupService {
|
||||
private final SaasRoleGroupDao saasRoleGroupDao;
|
||||
private final SaasRoleGroupRelationDao saasRoleGroupRelationDao;
|
||||
private final SaasRoleGroupRelationService saasRoleGroupRelationService;
|
||||
private final RoleService roleService;
|
||||
|
||||
@Override
|
||||
public List<SaasRoleGroupVO> getList(QuerySaasRoleGroupReq req) {
|
||||
@ -255,4 +273,63 @@ public class SaasRoleGroupServiceImpl extends ServiceImpl<SaasRoleGroupMapper, S
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SaasRoleGroupDTO> list(ListSaasRoleGroupParam param) {
|
||||
return PageConverter.drainAll(pageNumber -> {
|
||||
PageSaasRoleGroupParam pageParam = PageSaasRoleGroupParam.builder().build();
|
||||
BeanUtils.copyProperties(param, pageParam);
|
||||
pageParam.setPage(pageNumber);
|
||||
pageParam.setPageSize(500);
|
||||
return page(pageParam);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResp<SaasRoleGroupDTO> page(PageSaasRoleGroupParam param) {
|
||||
QueryWrapper<SaasRoleGroup> wrapper = QueryWrapperHelper.fromBean(param, SaasRoleGroup.class);
|
||||
wrapper.eq("is_delete", 0);
|
||||
|
||||
IPage<SaasRoleGroup> page = this.page(PageConverter.toMybatis(param, SaasRoleGroup.class), wrapper);
|
||||
|
||||
Map<Long, List<SaasRoleRes>> roles = listRoles(param, page.getRecords());
|
||||
|
||||
return PageConverter.toResp(page, (record) -> from(record, roles));
|
||||
}
|
||||
|
||||
private SaasRoleGroupDTO from(SaasRoleGroup saasRoleGroup,
|
||||
Map<Long, List<SaasRoleRes>> roles) {
|
||||
SaasRoleGroupDTO saasRoleGroupDTO = SaasRoleGroupDTO.builder().build();
|
||||
BeanUtils.copyProperties(saasRoleGroup, saasRoleGroupDTO);
|
||||
|
||||
saasRoleGroupDTO.setSaasRoles(roles.get(saasRoleGroupDTO.getId()));
|
||||
return saasRoleGroupDTO;
|
||||
}
|
||||
|
||||
private Map<Long, List<SaasRoleRes>> listRoles(PageSaasRoleGroupParam param,
|
||||
List<SaasRoleGroup> saasRoleGroups) {
|
||||
if (CollectionUtils.isEmpty(saasRoleGroups) || BooleanUtils.isNotTrue(param.getNeedRole())) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
|
||||
SaasRoleGroupRelationService.ListSaasRoleGroupRelationParam listSaasRoleGroupRelationParam = SaasRoleGroupRelationService.ListSaasRoleGroupRelationParam.builder().build();
|
||||
listSaasRoleGroupRelationParam.setSaasRoleGroupIds(Lists.transform(saasRoleGroups, SaasRoleGroup::getId));
|
||||
List<SaasRoleGroupRelation> saasRoleGroupRelations = saasRoleGroupRelationService.list(listSaasRoleGroupRelationParam);
|
||||
|
||||
List<Long> roleIds = Lists.transform(saasRoleGroupRelations, SaasRoleGroupRelation::getRoleId);
|
||||
|
||||
if (CollectionUtils.isEmpty(roleIds)) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
RoleService.ListSaasRoleParam listSaasRoleParam = RoleService.ListSaasRoleParam.builder().build();
|
||||
listSaasRoleParam.setRoleIds(roleIds);
|
||||
Map<Long, SaasRoleRes> roles = roleService.list(listSaasRoleParam).stream()
|
||||
.collect(Collectors.toMap(SaasRoleRes::getId, Function.identity()));
|
||||
|
||||
return saasRoleGroupRelations.stream()
|
||||
.collect(Collectors.groupingBy(SaasRoleGroupRelation::getSaasRoleGroupId,
|
||||
LinkedHashMap::new,
|
||||
Collectors.mapping(e -> roles.get(e.getRoleId()), Collectors.toList())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,6 +14,11 @@ spring:
|
||||
include: swagger
|
||||
main:
|
||||
allow-bean-definition-overriding: true
|
||||
lifecycle:
|
||||
timeout-per-shutdown-phase: 30s
|
||||
|
||||
server:
|
||||
shutdown: graceful
|
||||
|
||||
mybatis-plus:
|
||||
type-enums-package: cn.axzo.tyr.client.model.enums
|
||||
|
||||
@ -55,7 +55,7 @@ public class RoleUserTest {
|
||||
.ouId(123L)
|
||||
.identityId(32L)
|
||||
.identityType(IdentityType.PRACTITIONER)
|
||||
.build(), Arrays.asList(4l));
|
||||
.build(), Arrays.asList(4L));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Loading…
Reference in New Issue
Block a user