Merge remote-tracking branch 'origin/feature/REQ-1102' into feature/REQ-1102
This commit is contained in:
commit
7c1a1f3959
@ -10,6 +10,7 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -31,7 +32,7 @@ public interface SaasRoleApi {
|
|||||||
* 根据id查询详情
|
* 根据id查询详情
|
||||||
*/
|
*/
|
||||||
@PostMapping("/api/saasRole/getById")
|
@PostMapping("/api/saasRole/getById")
|
||||||
ApiResult<SaasRoleVO> getById(@RequestParam(required = true) Long id);
|
ApiResult<SaasRoleVO> getById(@RequestParam(required = true) @NotNull Long id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取角色列表
|
* 获取角色列表
|
||||||
|
|||||||
@ -2,8 +2,8 @@ package cn.axzo.tyr.client.feign;
|
|||||||
|
|
||||||
import cn.axzo.framework.domain.web.result.ApiListResult;
|
import cn.axzo.framework.domain.web.result.ApiListResult;
|
||||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||||
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
|
||||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
|
||||||
|
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
|
||||||
import org.springframework.cloud.openfeign.FeignClient;
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|||||||
@ -0,0 +1,29 @@
|
|||||||
|
package cn.axzo.tyr.client.model.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum PermissionGroupType {
|
||||||
|
COMMON(1, "通用"),
|
||||||
|
Special (0, "例外"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
private static final Map<Integer, PermissionGroupType> MAPPING = new HashMap<>();
|
||||||
|
static {
|
||||||
|
for (PermissionGroupType type : PermissionGroupType.values()) {
|
||||||
|
MAPPING.put(type.code, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PermissionGroupType apply(Integer code) {
|
||||||
|
return code == null ? null :MAPPING.get(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package cn.axzo.tyr.client.model.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum RoleGroupScope {
|
||||||
|
ALL(1, "全部"),
|
||||||
|
SPECIFY_ENTERPRISE_TYPE(2, "指定企业类型"),
|
||||||
|
;
|
||||||
|
|
||||||
|
private Integer code;
|
||||||
|
private String desc;
|
||||||
|
|
||||||
|
private static final Map<Integer, RoleGroupScope> MAPPING = new HashMap<>();
|
||||||
|
static {
|
||||||
|
for (RoleGroupScope type : RoleGroupScope.values()) {
|
||||||
|
MAPPING.put(type.code, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static RoleGroupScope apply(Integer code) {
|
||||||
|
return code == null ? null :MAPPING.get(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -34,5 +34,8 @@ public class QuerySaasRoleGroupReq {
|
|||||||
* 单位类型字典code
|
* 单位类型字典code
|
||||||
*/
|
*/
|
||||||
private List<String> ouTypeCode;
|
private List<String> ouTypeCode;
|
||||||
|
/**
|
||||||
|
* 被那些角色使用到的分组
|
||||||
|
*/
|
||||||
|
private List<Long> roleIds;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,4 +37,6 @@ public class QuerySaasRoleReq {
|
|||||||
* 分组id
|
* 分组id
|
||||||
*/
|
*/
|
||||||
private List<Long> sassRoleGroupIds;
|
private List<Long> sassRoleGroupIds;
|
||||||
|
|
||||||
|
private Integer isCommon;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,6 +70,10 @@
|
|||||||
<groupId>cn.axzo.basics</groupId>
|
<groupId>cn.axzo.basics</groupId>
|
||||||
<artifactId>basics-common</artifactId>
|
<artifactId>basics-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.xuxueli</groupId>
|
||||||
|
<artifactId>xxl-job-core</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
package cn.axzo.tyr.server;
|
package cn.axzo.tyr.server;
|
||||||
|
|
||||||
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.mybatis.spring.annotation.MapperScan;
|
import org.mybatis.spring.annotation.MapperScan;
|
||||||
|
import cn.axzo.tyr.server.job.OMSRoleJobHandler;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
|
||||||
import org.springframework.context.ConfigurableApplicationContext;
|
import org.springframework.context.ConfigurableApplicationContext;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.scheduling.annotation.EnableAsync;
|
import org.springframework.scheduling.annotation.EnableAsync;
|
||||||
@ -38,5 +39,16 @@ public class TyrApplication {
|
|||||||
env.getProperty("spring.rabbitmq.addresses"),
|
env.getProperty("spring.rabbitmq.addresses"),
|
||||||
env.getProperty("spring.rabbitmq.username") +
|
env.getProperty("spring.rabbitmq.username") +
|
||||||
"\n----------------------------------------------------------");
|
"\n----------------------------------------------------------");
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// test();
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public static void test() throws Exception {
|
||||||
|
// OMSRoleJobHandler executor = SpringUtil.getBean(OMSRoleJobHandler.class);
|
||||||
|
// executor.execute(null);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,13 +1,17 @@
|
|||||||
package cn.axzo.tyr.server.controller.role;
|
package cn.axzo.tyr.server.controller.role;
|
||||||
|
|
||||||
|
import cn.axzo.framework.domain.web.BizException;
|
||||||
|
import cn.axzo.framework.domain.web.code.BaseCode;
|
||||||
import cn.axzo.framework.domain.web.result.ApiResult;
|
import cn.axzo.framework.domain.web.result.ApiResult;
|
||||||
import cn.axzo.tyr.client.feign.SaasRoleApi;
|
import cn.axzo.tyr.client.feign.SaasRoleApi;
|
||||||
import cn.axzo.tyr.client.model.req.QueryByIdentityIdTypeReq;
|
import cn.axzo.tyr.client.model.req.QueryByIdentityIdTypeReq;
|
||||||
import cn.axzo.tyr.client.model.req.QuerySaasRoleReq;
|
import cn.axzo.tyr.client.model.req.QuerySaasRoleReq;
|
||||||
import cn.axzo.tyr.client.model.vo.SaasRoleVO;
|
import cn.axzo.tyr.client.model.vo.SaasRoleVO;
|
||||||
import cn.axzo.tyr.server.service.RoleService;
|
import cn.axzo.tyr.server.service.RoleService;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@ -36,7 +40,12 @@ public class SaasRoleController implements SaasRoleApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApiResult<SaasRoleVO> getById(Long id) {
|
public ApiResult<SaasRoleVO> getById(Long id) {
|
||||||
return null;
|
QuerySaasRoleReq query = QuerySaasRoleReq.builder().ids(Lists.newArrayList(id)).build();
|
||||||
|
List<SaasRoleVO> saasRoles = roleService.query(query);
|
||||||
|
if (CollectionUtils.isNotEmpty(saasRoles)) {
|
||||||
|
return ApiResult.ok(saasRoles.get(0));
|
||||||
|
}
|
||||||
|
throw new BizException(BaseCode.BAD_REQUEST, "未查询到角色");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -0,0 +1,162 @@
|
|||||||
|
package cn.axzo.tyr.server.job;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
|
||||||
|
import cn.axzo.tyr.server.repository.entity.*;
|
||||||
|
import cn.axzo.tyr.server.repository.service.*;
|
||||||
|
import com.xxl.job.core.biz.model.ReturnT;
|
||||||
|
import com.xxl.job.core.handler.IJobHandler;
|
||||||
|
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成都重新推送job
|
||||||
|
*
|
||||||
|
* @author cn
|
||||||
|
* @version 1.0
|
||||||
|
* @description
|
||||||
|
* @date 2021/9/13 11:31
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Slf4j
|
||||||
|
public class OMSRoleJobHandler extends IJobHandler {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
SaasRoleGroupDao roleGroupDao;
|
||||||
|
@Autowired
|
||||||
|
SaasRoleDao roleDao;
|
||||||
|
@Autowired
|
||||||
|
SaasPermissionGroupDao saasPermissionGroupDao;
|
||||||
|
@Autowired
|
||||||
|
SaasFeatureDao featureDao;
|
||||||
|
@Autowired
|
||||||
|
SaasRoleGroupRelationDao roleGroupRelationDao;
|
||||||
|
@Autowired
|
||||||
|
SaasRoleUserRelationDao roleUserRelationDao;
|
||||||
|
@Autowired
|
||||||
|
SaasPgroupRoleRelationDao pgroupRoleRelationDao;
|
||||||
|
@Autowired
|
||||||
|
SaasPgroupPermissionRelationDao pgroupPermissionRelationDao;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清洗OMS角色相关数据(注:先通过SQL检查和清除脏数据,要不然无法保证各个实体的关联关系)
|
||||||
|
*
|
||||||
|
* @param s
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@Transactional // 在一个事务里面做,一起提交
|
||||||
|
@Override
|
||||||
|
@XxlJob("OMSRoleJobHandler")
|
||||||
|
public ReturnT<String> execute(String s) throws Exception {
|
||||||
|
// 创建角色分组
|
||||||
|
SaasRoleGroup roleGroup = new SaasRoleGroup();
|
||||||
|
roleGroup.setWorkspaceTypeCode("6");
|
||||||
|
roleGroup.setName("管理员");
|
||||||
|
roleGroupDao.save(roleGroup);
|
||||||
|
// 查询OMS的角色 workspaceType=6 OMS的角色
|
||||||
|
List<SaasRole> oldRole = roleDao.lambdaQuery()
|
||||||
|
.eq(SaasRole::getWorkspaceType, 6)
|
||||||
|
.notIn(SaasRole::getRoleType,"super_admin")
|
||||||
|
.list();
|
||||||
|
// 重置老角色多余的字段
|
||||||
|
oldRole.forEach(e -> {
|
||||||
|
e.setWorkspaceId(-1l);
|
||||||
|
e.setOwnerOuId(-1l);
|
||||||
|
e.setWorkspaceType(-1);
|
||||||
|
e.setFitOuTypeBit(-1);
|
||||||
|
e.setFitOuNodeTypeBit(-1);
|
||||||
|
e.setPositionTemplateId(-1l);
|
||||||
|
e.setProjectTeamManageRoleResourceId(-1l);
|
||||||
|
e.setFromPreRoleId(-1l);
|
||||||
|
e.setJobCode("");
|
||||||
|
});
|
||||||
|
roleDao.updateBatchById(oldRole);
|
||||||
|
// 保存角色分组关联关系
|
||||||
|
List<SaasRoleGroupRelation> roleGroupRelation = oldRole.stream().map(e -> {
|
||||||
|
SaasRoleGroupRelation saasRoleGroupRelation = new SaasRoleGroupRelation();
|
||||||
|
saasRoleGroupRelation.setRoleId(e.getId());
|
||||||
|
saasRoleGroupRelation.setSaasRoleGroupId(roleGroup.getId());
|
||||||
|
return saasRoleGroupRelation;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
roleGroupRelationDao.saveBatch(roleGroupRelation);
|
||||||
|
// 查询角色关联的角色,打包成新的权限集
|
||||||
|
ArrayList<SaasPermissionGroup> deletePgroup = new ArrayList<>();
|
||||||
|
oldRole.forEach(role -> {
|
||||||
|
List<SaasPgroupRoleRelation> pgroupRoleRelation = pgroupRoleRelationDao.lambdaQuery().eq(SaasPgroupRoleRelation::getRoleId, role.getId()).list();
|
||||||
|
if (CollectionUtils.isEmpty(pgroupRoleRelation)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<SaasPermissionGroup> permissionGroup = saasPermissionGroupDao.lambdaQuery().in(BaseEntity::getId, pgroupRoleRelation.stream().map(SaasPgroupRoleRelation::getGroupId).collect(Collectors.toList())).list();
|
||||||
|
if (CollectionUtils.isEmpty(permissionGroup)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<SaasPgroupPermissionRelation> pgroupPermissionRelation = pgroupPermissionRelationDao.lambdaQuery().in(SaasPgroupPermissionRelation::getGroupId, permissionGroup.stream().map(BaseEntity::getId).collect(Collectors.toList())).list();
|
||||||
|
if (CollectionUtils.isEmpty(pgroupPermissionRelation)) {
|
||||||
|
// 如果没查到权限则表示当前权限集是无意义的,删掉
|
||||||
|
permissionGroup.forEach(e -> e.setIsDelete(e.getId()));
|
||||||
|
saasPermissionGroupDao.updateBatchById(permissionGroup);
|
||||||
|
// 删除角色权限集关联关系
|
||||||
|
pgroupRoleRelation.forEach(e -> e.setIsDelete(e.getId()));
|
||||||
|
pgroupRoleRelationDao.updateBatchById(pgroupRoleRelation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<SaasFeature> feature = featureDao.lambdaQuery().in(BaseEntity::getId, pgroupPermissionRelation.stream().map(SaasPgroupPermissionRelation::getFeatureId).collect(Collectors.toList())).list();
|
||||||
|
if (CollectionUtils.isEmpty(feature)) {
|
||||||
|
// 如果没查到权限则表示当前权限集是无意义的,删掉
|
||||||
|
permissionGroup.forEach(e -> e.setIsDelete(e.getId()));
|
||||||
|
saasPermissionGroupDao.updateBatchById(permissionGroup);
|
||||||
|
// 删除角色权限集关联关系
|
||||||
|
pgroupRoleRelation.forEach(e -> e.setIsDelete(e.getId()));
|
||||||
|
pgroupRoleRelationDao.updateBatchById(pgroupRoleRelation);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 创建新的权限集
|
||||||
|
SaasPermissionGroup saasPermissionGroup = new SaasPermissionGroup();
|
||||||
|
saasPermissionGroup.setName("通用权限");
|
||||||
|
saasPermissionGroup.setDescription("");
|
||||||
|
saasPermissionGroup.setCreateBy(-1L);
|
||||||
|
saasPermissionGroup.setUpdateBy(-1L);
|
||||||
|
saasPermissionGroup.setType("feature");
|
||||||
|
saasPermissionGroup.setIsCommon(1);
|
||||||
|
saasPermissionGroupDao.save(saasPermissionGroup);
|
||||||
|
deletePgroup.addAll(permissionGroup);
|
||||||
|
// 创建新的角色权限集关联关系
|
||||||
|
SaasPgroupRoleRelation saasPgroupRoleRelation = new SaasPgroupRoleRelation();
|
||||||
|
saasPgroupRoleRelation.setRoleId(role.getId());
|
||||||
|
saasPgroupRoleRelation.setGroupId(saasPermissionGroup.getId());
|
||||||
|
saasPgroupRoleRelation.setCreateBy(-1L);
|
||||||
|
saasPgroupRoleRelation.setUpdateBy(-1L);
|
||||||
|
pgroupRoleRelationDao.save(saasPgroupRoleRelation);
|
||||||
|
// 创建新的权限集权限关联关系
|
||||||
|
feature.forEach(e -> {
|
||||||
|
SaasPgroupPermissionRelation saasPgroupPermissionRelation = new SaasPgroupPermissionRelation();
|
||||||
|
saasPgroupPermissionRelation.setGroupId(saasPermissionGroup.getId());
|
||||||
|
saasPgroupPermissionRelation.setFeatureId(e.getId());
|
||||||
|
saasPgroupPermissionRelation.setCreateBy(-1L);
|
||||||
|
saasPgroupPermissionRelation.setUpdateBy(-1L);
|
||||||
|
pgroupPermissionRelationDao.save(saasPgroupPermissionRelation);
|
||||||
|
});
|
||||||
|
// 删除老的权限集权限关联关系
|
||||||
|
pgroupPermissionRelation.forEach(e -> e.setIsDelete(e.getId()));
|
||||||
|
pgroupPermissionRelationDao.updateBatchById(pgroupPermissionRelation);
|
||||||
|
// 删除老的角色权限集关联关系
|
||||||
|
pgroupRoleRelation.forEach(e -> e.setIsDelete(e.getId()));
|
||||||
|
pgroupRoleRelationDao.updateBatchById(pgroupRoleRelation);
|
||||||
|
});
|
||||||
|
// 删除权限集
|
||||||
|
deletePgroup.forEach(e -> e.setIsDelete(e.getId()));
|
||||||
|
saasPermissionGroupDao.updateBatchById(deletePgroup);
|
||||||
|
return ReturnT.SUCCESS;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -37,6 +37,42 @@ public class SaasRole extends BaseEntity<SaasRole> {
|
|||||||
*/
|
*/
|
||||||
private String roleType;
|
private String roleType;
|
||||||
|
|
||||||
|
private Long workspaceId;
|
||||||
|
|
||||||
|
private Integer workspaceType;
|
||||||
|
|
||||||
|
private Long ownerOuId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 废弃 20230911
|
||||||
|
*/
|
||||||
|
private Integer fitOuTypeBit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 废弃 20230911
|
||||||
|
*/
|
||||||
|
private Integer fitOuNodeTypeBit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 废弃 20230911
|
||||||
|
*/
|
||||||
|
private Long positionTemplateId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 废弃 20230911
|
||||||
|
*/
|
||||||
|
private Long projectTeamManageRoleResourceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 废弃 20230911
|
||||||
|
*/
|
||||||
|
private Long fromPreRoleId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 废弃 20230911
|
||||||
|
*/
|
||||||
|
private String jobCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建者
|
* 创建者
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
if (CollectionUtils.isEmpty(roleIds)) {
|
if (CollectionUtils.isEmpty(roleIds)) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
return getByIds(roleIds);
|
return getByIds(roleIds, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +63,7 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<SaasRoleVO> getByIds(List<Long> roleIds) {
|
public List<SaasRoleVO> getByIds(List<Long> roleIds, Integer isCommon) {
|
||||||
if (CollectionUtils.isEmpty(roleIds)) {
|
if (CollectionUtils.isEmpty(roleIds)) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
@ -78,7 +78,7 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
// 转map<roleId,relation>
|
// 转map<roleId,relation>
|
||||||
pgrouRelationMap = saasPgroupRoleRelations.stream().collect(Collectors.groupingBy(SaasPgroupRoleRelation::getRoleId));
|
pgrouRelationMap = saasPgroupRoleRelations.stream().collect(Collectors.groupingBy(SaasPgroupRoleRelation::getRoleId));
|
||||||
// 查询权限集
|
// 查询权限集
|
||||||
pGroupMap = permissionGroupService.query(QuerySaasPermissionGroupReq.builder()
|
pGroupMap = permissionGroupService.query(QuerySaasPermissionGroupReq.builder().isCommon(isCommon)
|
||||||
.ids(saasPgroupRoleRelations.stream().map(SaasPgroupRoleRelation::getGroupId).collect(Collectors.toList()))
|
.ids(saasPgroupRoleRelations.stream().map(SaasPgroupRoleRelation::getGroupId).collect(Collectors.toList()))
|
||||||
.build())
|
.build())
|
||||||
// 转map<pgroupId>
|
// 转map<pgroupId>
|
||||||
@ -141,7 +141,7 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
.eq(StringUtils.isNotBlank(req.getRoleType()), SaasRole::getRoleType, req.getRoleType())
|
.eq(StringUtils.isNotBlank(req.getRoleType()), SaasRole::getRoleType, req.getRoleType())
|
||||||
.orderByDesc(BaseEntity::getId)
|
.orderByDesc(BaseEntity::getId)
|
||||||
.list();
|
.list();
|
||||||
return getByIds(list.stream().map(BaseEntity::getId).collect(Collectors.toList()));
|
return getByIds(list.stream().map(BaseEntity::getId).collect(Collectors.toList()), req.getIsCommon());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -30,14 +30,31 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SaasRoleGroupVO> getList(QuerySaasRoleGroupReq req) {
|
public List<SaasRoleGroupVO> getList(QuerySaasRoleGroupReq req) {
|
||||||
|
if (CollectionUtils.isNotEmpty(req.getRoleIds())) {
|
||||||
|
List<SaasRoleGroupRelation> saasRoleGroupRelations = saasRoleGroupRelationDao.lambdaQuery()
|
||||||
|
.in(SaasRoleGroupRelation::getRoleId, req.getRoleIds())
|
||||||
|
.eq(SaasRoleGroupRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value).list();
|
||||||
|
List<Long> groupIds = saasRoleGroupRelations.stream().map(SaasRoleGroupRelation::getSaasRoleGroupId).distinct().collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isNotEmpty(req.getIds())) {
|
||||||
|
req.getIds().retainAll(groupIds);
|
||||||
|
} else {
|
||||||
|
req.setIds(groupIds);
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(req.getIds())) {
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<SaasRoleGroup> groups = saasRoleGroupDao.query(req);
|
List<SaasRoleGroup> groups = saasRoleGroupDao.query(req);
|
||||||
if (CollectionUtils.isEmpty(groups)) {
|
if (CollectionUtils.isEmpty(groups)) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
List<SaasRoleGroupRelation> saasRoleGroupRelations = saasRoleGroupRelationDao.lambdaQuery().in(SaasRoleGroupRelation::getSaasRoleGroupId, groups.stream().map(SaasRoleGroup::getId))
|
List<SaasRoleGroupRelation> saasRoleGroupRelations = saasRoleGroupRelationDao.lambdaQuery()
|
||||||
|
.in(SaasRoleGroupRelation::getSaasRoleGroupId, groups.stream().map(SaasRoleGroup::getId))
|
||||||
.eq(SaasRoleGroupRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value).list();
|
.eq(SaasRoleGroupRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value).list();
|
||||||
Map<Long, List<Long>> groupRoleMap = saasRoleGroupRelations.stream().collect(Collectors.groupingBy(SaasRoleGroupRelation::getSaasRoleGroupId, Collectors.mapping(SaasRoleGroupRelation::getRoleId, Collectors.toList())));
|
Map<Long, List<Long>> groupRoleMap = saasRoleGroupRelations.stream().collect(Collectors.groupingBy(SaasRoleGroupRelation::getSaasRoleGroupId, Collectors.mapping(SaasRoleGroupRelation::getRoleId, Collectors.toList())));
|
||||||
List<SaasRoleGroupVO> results = groups.stream().map(e -> {
|
List<SaasRoleGroupVO> results = groups.stream()
|
||||||
|
.map(e -> {
|
||||||
SaasRoleGroupVO target = BeanUtil.copyProperties(e, SaasRoleGroupVO.class);
|
SaasRoleGroupVO target = BeanUtil.copyProperties(e, SaasRoleGroupVO.class);
|
||||||
if (StringUtils.isNotBlank(e.getOuTypeCode())) {
|
if (StringUtils.isNotBlank(e.getOuTypeCode())) {
|
||||||
target.setOuTypeCode(Arrays.stream(e.getOuTypeCode().split(",")).filter(StringUtils::isNotBlank).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList()));
|
target.setOuTypeCode(Arrays.stream(e.getOuTypeCode().split(",")).filter(StringUtils::isNotBlank).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList()));
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user