Merge remote-tracking branch 'origin/feature/REQ-1102' into feature/REQ-1102
This commit is contained in:
commit
f3e1ac397e
@ -39,7 +39,7 @@ public interface SaasPermissionGroupApi {
|
|||||||
* 查询
|
* 查询
|
||||||
*/
|
*/
|
||||||
@PostMapping("/api/saasPermissionGoup/query")
|
@PostMapping("/api/saasPermissionGoup/query")
|
||||||
ApiPageResult<SaasPermissionGroupVO> query(@RequestBody QuerySaasPermissionGroupReq req);
|
ApiPageResult<SaasPermissionGroupVO> query(@RequestBody@Valid QuerySaasPermissionGroupReq req);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除
|
* 删除
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import lombok.Builder;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotEmpty;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ -18,6 +19,7 @@ public class QuerySaasPermissionGroupReq extends PageRequest {
|
|||||||
/**
|
/**
|
||||||
* 角色id
|
* 角色id
|
||||||
*/
|
*/
|
||||||
|
@NotEmpty(message = "角色id必填")
|
||||||
private List<Long> roleIds;
|
private List<Long> roleIds;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -23,7 +23,7 @@ public interface PermissionGroupService {
|
|||||||
/**
|
/**
|
||||||
* 通用查询
|
* 通用查询
|
||||||
*/
|
*/
|
||||||
public List<SaasPermissionGroupVO> query(QuerySaasPermissionGroupReq req);
|
List<SaasPermissionGroupVO> query(QuerySaasPermissionGroupReq req);
|
||||||
|
|
||||||
PageResp<SaasPermissionGroupVO> page(QuerySaasPermissionGroupReq req);
|
PageResp<SaasPermissionGroupVO> page(QuerySaasPermissionGroupReq req);
|
||||||
|
|
||||||
|
|||||||
@ -12,8 +12,8 @@ import cn.axzo.tyr.client.model.enums.PermissionScopeType;
|
|||||||
import cn.axzo.tyr.client.model.permission.PermissionPointTreeNode;
|
import cn.axzo.tyr.client.model.permission.PermissionPointTreeNode;
|
||||||
import cn.axzo.tyr.client.model.req.QuerySaasPermissionGroupReq;
|
import cn.axzo.tyr.client.model.req.QuerySaasPermissionGroupReq;
|
||||||
import cn.axzo.tyr.client.model.vo.*;
|
import cn.axzo.tyr.client.model.vo.*;
|
||||||
import cn.axzo.tyr.server.repository.entity.*;
|
|
||||||
import cn.axzo.tyr.server.repository.dao.*;
|
import cn.axzo.tyr.server.repository.dao.*;
|
||||||
|
import cn.axzo.tyr.server.repository.entity.*;
|
||||||
import cn.axzo.tyr.server.service.PermissionGroupService;
|
import cn.axzo.tyr.server.service.PermissionGroupService;
|
||||||
import cn.axzo.tyr.server.service.PermissionPointService;
|
import cn.axzo.tyr.server.service.PermissionPointService;
|
||||||
import cn.axzo.tyr.server.service.SaasPermissionGroupScopeService;
|
import cn.axzo.tyr.server.service.SaasPermissionGroupScopeService;
|
||||||
@ -62,14 +62,14 @@ public class PermissionGroupImpl implements PermissionGroupService {
|
|||||||
@Override
|
@Override
|
||||||
public List<SaasPermissionGroupVO> query(QuerySaasPermissionGroupReq req) {
|
public List<SaasPermissionGroupVO> query(QuerySaasPermissionGroupReq req) {
|
||||||
if (CollectionUtils.isEmpty(req.getWorkspaceId())) {
|
if (CollectionUtils.isEmpty(req.getWorkspaceId())) {
|
||||||
req.setWorkspaceId(Arrays.asList(-1l));
|
req.setWorkspaceId(Arrays.asList(-1L));
|
||||||
} else if(!req.getWorkspaceId().contains(-1l)){
|
} else if(!req.getWorkspaceId().contains(-1L)){
|
||||||
req.getWorkspaceId().add(-1l);
|
req.getWorkspaceId().add(-1L);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isEmpty(req.getOuId())) {
|
if (CollectionUtils.isEmpty(req.getOuId())) {
|
||||||
req.setOuId(Arrays.asList(-1l));
|
req.setOuId(Arrays.asList(-1L));
|
||||||
} else if (!req.getOuId().contains(-1l)) {
|
} else if (!req.getOuId().contains(-1L)) {
|
||||||
req.getOuId().add(-1l);
|
req.getOuId().add(-1L);
|
||||||
}
|
}
|
||||||
// 如果角色id不为空则先查询角色权限集关联表
|
// 如果角色id不为空则先查询角色权限集关联表
|
||||||
List<SaasPgroupRoleRelation> relationList = null;
|
List<SaasPgroupRoleRelation> relationList = null;
|
||||||
@ -111,9 +111,9 @@ public class PermissionGroupImpl implements PermissionGroupService {
|
|||||||
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
||||||
.list();
|
.list();
|
||||||
// 过滤权限集作用范围
|
// 过滤权限集作用范围
|
||||||
|
List<Long> workspaceIdWithOutCommon = req.getWorkspaceId().stream().filter(workspaceId -> !workspaceId.equals(-1L)).collect(Collectors.toList());
|
||||||
|
List<Long> ouIdWithOutCommon = req.getOuId().stream().filter(ouId -> !ouId.equals(-1L)).collect(Collectors.toList());
|
||||||
List<SaasPermissionGroupScope> saasPermissionGroupScopes = saasPermissionGroupScopesSource.stream().filter(e -> {
|
List<SaasPermissionGroupScope> saasPermissionGroupScopes = saasPermissionGroupScopesSource.stream().filter(e -> {
|
||||||
List<Long> workspaceIdWithOutCommon = req.getWorkspaceId().stream().filter(workspaceId -> !workspaceId.equals(-1l)).collect(Collectors.toList());
|
|
||||||
List<Long> ouIdWithOutCommon = req.getOuId().stream().filter(ouId -> !ouId.equals(-1l)).collect(Collectors.toList());
|
|
||||||
// 过滤出选中的工作台
|
// 过滤出选中的工作台
|
||||||
if (PermissionScopeType.WORKSPACE.getCode().equals(e.getScopeType())) {
|
if (PermissionScopeType.WORKSPACE.getCode().equals(e.getScopeType())) {
|
||||||
if (CollectionUtils.isNotEmpty(workspaceIdWithOutCommon) && ! workspaceIdWithOutCommon.contains(e.getScopeId())) {
|
if (CollectionUtils.isNotEmpty(workspaceIdWithOutCommon) && ! workspaceIdWithOutCommon.contains(e.getScopeId())) {
|
||||||
@ -156,6 +156,16 @@ public class PermissionGroupImpl implements PermissionGroupService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResp<SaasPermissionGroupVO> page(QuerySaasPermissionGroupReq req) {
|
public PageResp<SaasPermissionGroupVO> page(QuerySaasPermissionGroupReq req) {
|
||||||
|
if (CollectionUtils.isEmpty(req.getWorkspaceId())) {
|
||||||
|
req.setWorkspaceId(Arrays.asList(-1L));
|
||||||
|
} else if(!req.getWorkspaceId().contains(-1L)){
|
||||||
|
req.getWorkspaceId().add(-1L);
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(req.getOuId())) {
|
||||||
|
req.setOuId(Arrays.asList(-1L));
|
||||||
|
} else if (!req.getOuId().contains(-1L)) {
|
||||||
|
req.getOuId().add(-1L);
|
||||||
|
}
|
||||||
// 如果角色id不为空则先查询角色权限集关联表
|
// 如果角色id不为空则先查询角色权限集关联表
|
||||||
IPage<SaasPermissionGroup> iPage = req.toPage();
|
IPage<SaasPermissionGroup> iPage = req.toPage();
|
||||||
if (CollectionUtils.isNotEmpty(req.getRoleIds())) {
|
if (CollectionUtils.isNotEmpty(req.getRoleIds())) {
|
||||||
@ -206,9 +216,9 @@ public class PermissionGroupImpl implements PermissionGroupService {
|
|||||||
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
||||||
.list();
|
.list();
|
||||||
// 过滤权限集作用范围
|
// 过滤权限集作用范围
|
||||||
|
List<Long> workspaceIdWithOutCommon = req.getWorkspaceId().stream().filter(workspaceId -> !workspaceId.equals(-1L)).collect(Collectors.toList());
|
||||||
|
List<Long> ouIdWithOutCommon = req.getOuId().stream().filter(ouId -> !ouId.equals(-1L)).collect(Collectors.toList());
|
||||||
List<SaasPermissionGroupScope> saasPermissionGroupScopes = saasPermissionGroupScopesSource.stream().filter(e -> {
|
List<SaasPermissionGroupScope> saasPermissionGroupScopes = saasPermissionGroupScopesSource.stream().filter(e -> {
|
||||||
List<Long> workspaceIdWithOutCommon = req.getWorkspaceId().stream().filter(workspaceId -> !workspaceId.equals(-1l)).collect(Collectors.toList());
|
|
||||||
List<Long> ouIdWithOutCommon = req.getOuId().stream().filter(ouId -> !ouId.equals(-1l)).collect(Collectors.toList());
|
|
||||||
// 过滤出选中的工作台
|
// 过滤出选中的工作台
|
||||||
if (PermissionScopeType.WORKSPACE.getCode().equals(e.getScopeType())) {
|
if (PermissionScopeType.WORKSPACE.getCode().equals(e.getScopeType())) {
|
||||||
if (CollectionUtils.isNotEmpty(workspaceIdWithOutCommon) && ! workspaceIdWithOutCommon.contains(e.getScopeId())) {
|
if (CollectionUtils.isNotEmpty(workspaceIdWithOutCommon) && ! workspaceIdWithOutCommon.contains(e.getScopeId())) {
|
||||||
@ -356,6 +366,12 @@ public class PermissionGroupImpl implements PermissionGroupService {
|
|||||||
// 删除例外scope
|
// 删除例外scope
|
||||||
saasPermissionGroupScopeDao.removeByIds(scopes.stream().map(SaasPermissionGroupScope::getId).sorted().collect(Collectors.toList()));
|
saasPermissionGroupScopeDao.removeByIds(scopes.stream().map(SaasPermissionGroupScope::getId).sorted().collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
List<SaasPgroupPermissionRelation> pgroupPermissionRelations = permissionRelationDao.lambdaQuery().in(SaasPgroupPermissionRelation::getGroupId, deleteGroupIds)
|
||||||
|
.eq(SaasPgroupPermissionRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value).list();
|
||||||
|
// 删除权限集和权限点关联关系
|
||||||
|
if (CollectionUtils.isNotEmpty(pgroupPermissionRelations)) {
|
||||||
|
permissionRelationDao.removeByIds(pgroupPermissionRelations.stream().map(SaasPgroupPermissionRelation::getId).sorted().collect(Collectors.toList()));
|
||||||
|
}
|
||||||
// 删除权限集
|
// 删除权限集
|
||||||
permissionGroupDao.lambdaUpdate()
|
permissionGroupDao.lambdaUpdate()
|
||||||
.in(BaseEntity::getId,deleteGroupIds)
|
.in(BaseEntity::getId,deleteGroupIds)
|
||||||
|
|||||||
@ -139,14 +139,14 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
public List<SaasRoleVO> query(QuerySaasRoleReq req) {
|
public List<SaasRoleVO> query(QuerySaasRoleReq req) {
|
||||||
// 如果没有传则默认查询通用维度默认值是 -1,-1+传入的参数含义是查询通用和自定义
|
// 如果没有传则默认查询通用维度默认值是 -1,-1+传入的参数含义是查询通用和自定义
|
||||||
if (CollectionUtils.isEmpty(req.getWorkspaceId())) {
|
if (CollectionUtils.isEmpty(req.getWorkspaceId())) {
|
||||||
req.setWorkspaceId(Arrays.asList(-1l));
|
req.setWorkspaceId(Arrays.asList(-1L));
|
||||||
} else if(!req.getWorkspaceId().contains(-1l)){
|
} else if(!req.getWorkspaceId().contains(-1L)){
|
||||||
req.getWorkspaceId().add(-1l);
|
req.getWorkspaceId().add(-1L);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isEmpty(req.getOuId())) {
|
if (CollectionUtils.isEmpty(req.getOuId())) {
|
||||||
req.setOuId(Arrays.asList(-1l));
|
req.setOuId(Arrays.asList(-1L));
|
||||||
} else if (!req.getOuId().contains(-1l)) {
|
} else if (!req.getOuId().contains(-1L)) {
|
||||||
req.getOuId().add(-1l);
|
req.getOuId().add(-1L);
|
||||||
}
|
}
|
||||||
// 根据工作台类型和单位类型查询角色分组
|
// 根据工作台类型和单位类型查询角色分组
|
||||||
List<SaasRoleGroup> roleGroup = new ArrayList<>();
|
List<SaasRoleGroup> roleGroup = new ArrayList<>();
|
||||||
@ -212,11 +212,6 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
if (Objects.isNull(saveOrUpdateRole.getPermissionGroupId())) {
|
if (Objects.isNull(saveOrUpdateRole.getPermissionGroupId())) {
|
||||||
throw new BizException(BaseCode.BAD_REQUEST, "更新角色时权限集不能为空不存在");
|
throw new BizException(BaseCode.BAD_REQUEST, "更新角色时权限集不能为空不存在");
|
||||||
}
|
}
|
||||||
SaasPermissionGroup group = saasPermissionGroupDao.lambdaQuery().eq(SaasPermissionGroup::getId, saveOrUpdateRole.getPermissionGroupId())
|
|
||||||
.eq(SaasPermissionGroup::getIsDelete, TableIsDeleteEnum.NORMAL.value).one();
|
|
||||||
if (Objects.isNull(group)) {
|
|
||||||
throw new BizException(BaseCode.BAD_REQUEST, "权限集不存在");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
saasRole = new SaasRole();
|
saasRole = new SaasRole();
|
||||||
saasRole.setCreateBy(saveOrUpdateRole.getOperatorId());
|
saasRole.setCreateBy(saveOrUpdateRole.getOperatorId());
|
||||||
|
|||||||
@ -5,9 +5,10 @@ import cn.axzo.framework.domain.web.BizException;
|
|||||||
import cn.axzo.framework.domain.web.code.BaseCode;
|
import cn.axzo.framework.domain.web.code.BaseCode;
|
||||||
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 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.SaasRoleGroup;
|
||||||
import cn.axzo.tyr.server.repository.entity.SaasRoleGroupRelation;
|
import cn.axzo.tyr.server.repository.entity.SaasRoleGroupRelation;
|
||||||
import cn.axzo.tyr.server.repository.dao.*;
|
|
||||||
import cn.axzo.tyr.server.service.SaasRoleGroupService;
|
import cn.axzo.tyr.server.service.SaasRoleGroupService;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -28,14 +29,19 @@ import java.util.stream.Collectors;
|
|||||||
public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
|
public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
|
||||||
private final SaasRoleGroupDao saasRoleGroupDao;
|
private final SaasRoleGroupDao saasRoleGroupDao;
|
||||||
private final SaasRoleGroupRelationDao saasRoleGroupRelationDao;
|
private final SaasRoleGroupRelationDao saasRoleGroupRelationDao;
|
||||||
private final SaasRoleDao roleDao;
|
|
||||||
private final SaasPgroupRoleRelationDao pgroupRoleRelationDao;
|
|
||||||
private final SaasPermissionGroupDao permissionGroupDao;
|
|
||||||
private final SaasPgroupPermissionRelationDao pgroupPermissionRelationDao;
|
|
||||||
private final SaasRoleUserRelationDao roleUserRelationDao;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<SaasRoleGroupVO> getList(QuerySaasRoleGroupReq req) {
|
public List<SaasRoleGroupVO> getList(QuerySaasRoleGroupReq req) {
|
||||||
|
if (CollectionUtils.isEmpty(req.getWorkspaceIds())) {
|
||||||
|
req.setWorkspaceIds(Arrays.asList(-1L));
|
||||||
|
} else if(!req.getWorkspaceIds().contains(-1L)){
|
||||||
|
req.getWorkspaceIds().add(-1L);
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(req.getOuIds())) {
|
||||||
|
req.setOuIds(Arrays.asList(-1L));
|
||||||
|
} else if (!req.getOuIds().contains(-1L)) {
|
||||||
|
req.getOuIds().add(-1L);
|
||||||
|
}
|
||||||
if (CollectionUtils.isNotEmpty(req.getRoleIds())) {
|
if (CollectionUtils.isNotEmpty(req.getRoleIds())) {
|
||||||
List<SaasRoleGroupRelation> saasRoleGroupRelations = saasRoleGroupRelationDao.lambdaQuery()
|
List<SaasRoleGroupRelation> saasRoleGroupRelations = saasRoleGroupRelationDao.lambdaQuery()
|
||||||
.in(SaasRoleGroupRelation::getRoleId, req.getRoleIds())
|
.in(SaasRoleGroupRelation::getRoleId, req.getRoleIds())
|
||||||
@ -85,8 +91,8 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
|
|||||||
saasRoleGroup.setOuTypeCode(ouTypeCodeStr);
|
saasRoleGroup.setOuTypeCode(ouTypeCodeStr);
|
||||||
saasRoleGroup.setName(req.getName());
|
saasRoleGroup.setName(req.getName());
|
||||||
saasRoleGroup.setSort(req.getSort());
|
saasRoleGroup.setSort(req.getSort());
|
||||||
saasRoleGroup.setWorkspaceId(req.getWorkspaceId() != null ? req.getWorkspaceId():-1l);
|
saasRoleGroup.setWorkspaceId(req.getWorkspaceId() != null ? req.getWorkspaceId():-1L);
|
||||||
saasRoleGroup.setOuId(req.getOuId() != null ? req.getOuId():-1l);
|
saasRoleGroup.setOuId(req.getOuId() != null ? req.getOuId():-1L);
|
||||||
saasRoleGroupDao.saveOrUpdate(saasRoleGroup);
|
saasRoleGroupDao.saveOrUpdate(saasRoleGroup);
|
||||||
return saasRoleGroup.getId();
|
return saasRoleGroup.getId();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user