Merge remote-tracking branch 'origin/feature/REQ-1102' into feature/REQ-1102
This commit is contained in:
commit
4eedc3ca04
@ -22,7 +22,7 @@ public interface SaasRoleGroupApi {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/api/saasRoleGroup/save")
|
||||
ApiResult saveOrUpdate(@RequestBody SaasRoleGroupVO req);
|
||||
ApiResult<Long> saveOrUpdate(@RequestBody SaasRoleGroupVO req);
|
||||
|
||||
/**
|
||||
* 获取权限分组列表
|
||||
|
||||
@ -18,6 +18,16 @@ public class BasicDictTreeResp {
|
||||
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 工作台类型,"ent", "proj", "oms"
|
||||
*/
|
||||
private String workspaceType;
|
||||
|
||||
/**
|
||||
* 类型,"ouType", "terminal"
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
|
||||
@ -23,9 +23,8 @@ public class SaasRoleGroupController implements SaasRoleGroupApi {
|
||||
private final SaasRoleGroupService saasRoleGroupService;
|
||||
|
||||
@Override
|
||||
public ApiResult saveOrUpdate(SaasRoleGroupVO req) {
|
||||
saasRoleGroupService.saveOrUpdate(req);
|
||||
return ApiResult.ok();
|
||||
public ApiResult<Long> saveOrUpdate(SaasRoleGroupVO req) {
|
||||
return ApiResult.ok(saasRoleGroupService.saveOrUpdate(req));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -62,9 +62,8 @@ public class SaasPermissionGroupScope extends BaseEntity<SaasPermissionGroupScop
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
SaasPermissionGroupScope that = (SaasPermissionGroupScope) o;
|
||||
return Objects.equals(pgroupId, that.pgroupId) && Objects.equals(type, that.type) && Objects.equals(scopeType, that.scopeType) && Objects.equals(scopeId, that.scopeId) && Objects.equals(isDelete, that.isDelete);
|
||||
return Objects.equals(pgroupId, that.pgroupId) && Objects.equals(type, that.type) && Objects.equals(scopeType, that.scopeType) && Objects.equals(scopeId, that.scopeId);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -58,9 +58,8 @@ public class SaasPgroupPermissionRelation extends BaseEntity<SaasPgroupPermissio
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
SaasPgroupPermissionRelation that = (SaasPgroupPermissionRelation) o;
|
||||
return Objects.equals(groupId, that.groupId) && Objects.equals(featureId, that.featureId) && Objects.equals(isDelete, that.isDelete);
|
||||
return Objects.equals(groupId, that.groupId) && Objects.equals(featureId, that.featureId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -50,9 +50,8 @@ public class SaasRoleGroupRelation extends BaseEntity<SaasRoleGroupRelation> imp
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (!super.equals(o)) return false;
|
||||
SaasRoleGroupRelation that = (SaasRoleGroupRelation) o;
|
||||
return Objects.equals(roleId, that.roleId) && Objects.equals(saasRoleGroupId, that.saasRoleGroupId) && Objects.equals(isDelete, that.isDelete);
|
||||
return Objects.equals(roleId, that.roleId) && Objects.equals(saasRoleGroupId, that.saasRoleGroupId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@ import java.util.List;
|
||||
public interface SaasRoleGroupService {
|
||||
List<SaasRoleGroupVO> getList(QuerySaasRoleGroupReq req);
|
||||
|
||||
void saveOrUpdate(SaasRoleGroupVO req);
|
||||
Long saveOrUpdate(SaasRoleGroupVO req);
|
||||
|
||||
void delete(List<Long> ids);
|
||||
}
|
||||
|
||||
@ -61,6 +61,16 @@ public class PermissionGroupImpl implements PermissionGroupService {
|
||||
|
||||
@Override
|
||||
public List<SaasPermissionGroupVO> query(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不为空则先查询角色权限集关联表
|
||||
List<SaasPgroupRoleRelation> relationList = null;
|
||||
if (CollectionUtils.isNotEmpty(req.getRoleIds())) {
|
||||
@ -232,7 +242,7 @@ public class PermissionGroupImpl implements PermissionGroupService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void savePermissionPoints(SavePermissionGroupPPVO save) {
|
||||
SaasPermissionGroup saasPermissionGroup = getRequiredPermissionGroup(save.getId(), PermissionGroupType.COMMON);
|
||||
SaasPermissionGroup saasPermissionGroup = getRequiredPermissionGroup(save.getId(), null);
|
||||
List<SaasPgroupPermissionRelation> pgpRelations = Optional.ofNullable(save.getSelectedPPIds()).orElse(new ArrayList<>()).stream().map(ppId -> {
|
||||
SaasPgroupPermissionRelation target = new SaasPgroupPermissionRelation();
|
||||
target.setGroupId(saasPermissionGroup.getId());
|
||||
@ -316,7 +326,7 @@ public class PermissionGroupImpl implements PermissionGroupService {
|
||||
throw new BizException(BaseCode.BAD_REQUEST, "权限集不存在");
|
||||
}
|
||||
SaasPermissionGroup saasPermissionGroup = groups.get(0);
|
||||
if (!Objects.equals(saasPermissionGroup.getIsCommon(), type.getCode())) {
|
||||
if (Objects.nonNull(type) && !Objects.equals(saasPermissionGroup.getIsCommon(), type.getCode())) {
|
||||
throw new BizException(BaseCode.BAD_REQUEST, String.format("权限集不是%s权限集", type.getDesc()));
|
||||
}
|
||||
return saasPermissionGroup;
|
||||
@ -380,8 +390,8 @@ public class PermissionGroupImpl implements PermissionGroupService {
|
||||
if (CollectionUtils.isNotEmpty(selectedWorkspace)) {
|
||||
Map<Integer, List<SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO>> selectedWorkspaceMap = selectedWorkspace.stream()
|
||||
.collect(Collectors.groupingBy(SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO::getType));
|
||||
List<SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO> includeScopes = Optional.ofNullable(selectedWorkspaceMap.get(PermissionScope.INCLUDE)).orElse(new ArrayList<>());
|
||||
List<SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO> excludeScopes = Optional.ofNullable(selectedWorkspaceMap.get(PermissionScope.EXCLUDE)).orElse(new ArrayList<>());
|
||||
List<SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO> includeScopes = Optional.ofNullable(selectedWorkspaceMap.get(PermissionScope.INCLUDE.getCode())).orElse(new ArrayList<>());
|
||||
List<SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO> excludeScopes = Optional.ofNullable(selectedWorkspaceMap.get(PermissionScope.EXCLUDE.getCode())).orElse(new ArrayList<>());
|
||||
if (includeScopes.size() + excludeScopes.size() != selectedWorkspace.size()) {
|
||||
throw new BizException(BaseCode.BAD_REQUEST, "选择类型设置错误");
|
||||
}
|
||||
@ -393,8 +403,8 @@ public class PermissionGroupImpl implements PermissionGroupService {
|
||||
if (CollectionUtils.isNotEmpty(selectedOu)) {
|
||||
Map<Integer, List<SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO>> selectedOuMap = selectedOu.stream()
|
||||
.collect(Collectors.groupingBy(SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO::getType));
|
||||
List<SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO> includeScopes = Optional.ofNullable(selectedOuMap.get(PermissionScope.INCLUDE)).orElse(new ArrayList<>());
|
||||
List<SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO> excludeScopes = Optional.ofNullable(selectedOuMap.get(PermissionScope.EXCLUDE)).orElse(new ArrayList<>());
|
||||
List<SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO> includeScopes = Optional.ofNullable(selectedOuMap.get(PermissionScope.INCLUDE.getCode())).orElse(new ArrayList<>());
|
||||
List<SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO> excludeScopes = Optional.ofNullable(selectedOuMap.get(PermissionScope.EXCLUDE.getCode())).orElse(new ArrayList<>());
|
||||
if (includeScopes.size() + excludeScopes.size() != selectedWorkspace.size()) {
|
||||
throw new BizException(BaseCode.BAD_REQUEST, "选择类型设置错误");
|
||||
}
|
||||
|
||||
@ -13,8 +13,8 @@ import cn.axzo.tyr.client.model.res.QueryBatchByIdentityIdTypeRes;
|
||||
import cn.axzo.tyr.client.model.vo.SaasPermissionGroupVO;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleVO;
|
||||
import cn.axzo.tyr.client.model.vo.SaveOrUpdateRoleVO;
|
||||
import cn.axzo.tyr.server.repository.entity.*;
|
||||
import cn.axzo.tyr.server.repository.dao.*;
|
||||
import cn.axzo.tyr.server.repository.entity.*;
|
||||
import cn.axzo.tyr.server.service.*;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -209,6 +209,14 @@ public class RoleServiceImpl implements RoleService {
|
||||
if (Objects.isNull(saasRole)) {
|
||||
throw new BizException(BaseCode.BAD_REQUEST, "角色不存在");
|
||||
}
|
||||
if (Objects.isNull(saveOrUpdateRole.getPermissionGroupId())) {
|
||||
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 {
|
||||
saasRole = new SaasRole();
|
||||
saasRole.setCreateBy(saveOrUpdateRole.getOperatorId());
|
||||
|
||||
@ -22,7 +22,7 @@ public class SaasPermissionGroupScopeServiceImpl implements SaasPermissionGroupS
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveOrUpdate(List<SaasPermissionGroupScope> scopes) {
|
||||
if (CollectionUtils.isNotEmpty(scopes)) {
|
||||
if (CollectionUtils.isEmpty(scopes)) {
|
||||
return;
|
||||
}
|
||||
List<SaasPermissionGroupScope> exists = saasPermissionGroupScopeDao.lambdaQuery()
|
||||
|
||||
@ -23,7 +23,7 @@ public class SaasPgroupPermissionRelationServiceImpl implements SaasPgroupPermis
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveOrUpdate(List<SaasPgroupPermissionRelation> relations) {
|
||||
if (CollectionUtils.isNotEmpty(relations)) {
|
||||
if (CollectionUtils.isEmpty(relations)) {
|
||||
return;
|
||||
}
|
||||
List<SaasPgroupPermissionRelation> exists = saasPgroupPermissionRelationDao.lambdaQuery()
|
||||
|
||||
@ -73,7 +73,7 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveOrUpdate(SaasRoleGroupVO req) {
|
||||
public Long saveOrUpdate(SaasRoleGroupVO req) {
|
||||
// 拼接ouTypeCode字符串
|
||||
String ouTypeCodeStr = null;
|
||||
if (CollectionUtils.isNotEmpty(req.getOuTypeCode())) {
|
||||
@ -88,6 +88,7 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
|
||||
saasRoleGroup.setWorkspaceId(req.getWorkspaceId() != null ? req.getWorkspaceId():-1l);
|
||||
saasRoleGroup.setOuId(req.getOuId() != null ? req.getOuId():-1l);
|
||||
saasRoleGroupDao.saveOrUpdate(saasRoleGroup);
|
||||
return saasRoleGroup.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user