修改异常类型,合并list和page方法

This commit is contained in:
yangsong 2023-09-16 14:56:20 +08:00
parent 5348476aa7
commit 189e1ffa98
9 changed files with 66 additions and 168 deletions

View File

@ -8,6 +8,7 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
@ -62,5 +63,11 @@ public class QuerySaasPermissionGroupReq extends PageRequest {
*/
private String type;
/**
* true 查询分页
* false 查询list 全部
*/
@NotNull
@Builder.Default
private Boolean fetchPage = Boolean.TRUE;
}

View File

@ -1,8 +1,8 @@
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.basics.common.exception.ServiceException;
import cn.axzo.framework.domain.page.PageResp;
import cn.axzo.framework.domain.web.result.ApiPageResult;
import cn.axzo.framework.domain.web.result.ApiResult;
import cn.axzo.tyr.client.feign.SaasPermissionGroupApi;
@ -41,9 +41,11 @@ public class SaasPermissionGroupController implements SaasPermissionGroupApi {
@Override
public ApiResult<SaasPermissionGroupVO> getById(Long id) {
List<SaasPermissionGroupVO> pGroups = permissionGroupService.query(QuerySaasPermissionGroupReq.builder().ids(Lists.newArrayList(id)).build());
PageResp<SaasPermissionGroupVO> pgPage = permissionGroupService.page(QuerySaasPermissionGroupReq.builder()
.fetchPage(Boolean.FALSE).ids(Lists.newArrayList(id)).build());
List<SaasPermissionGroupVO> pGroups = pgPage.getList();
if (CollectionUtils.isEmpty(pGroups)) {
throw new BizException(BaseCode.BAD_REQUEST, "未查询到权限组信息");
throw new ServiceException("未查询到权限组信息");
}
return ApiResult.ok(pGroups.get(0));
}

View File

@ -1,7 +1,6 @@
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.basics.common.exception.ServiceException;
import cn.axzo.framework.domain.web.result.ApiResult;
import cn.axzo.tyr.client.feign.TyrSaasRoleApi;
import cn.axzo.tyr.client.model.req.QueryByIdentityIdTypeReq;
@ -46,7 +45,7 @@ public class SaasRoleController implements TyrSaasRoleApi {
if (CollectionUtils.isNotEmpty(saasRoles)) {
return ApiResult.ok(saasRoles.get(0));
}
throw new BizException(BaseCode.BAD_REQUEST, "未查询到角色");
throw new ServiceException("未查询到角色");
}
@Override

View File

@ -1,7 +1,6 @@
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.basics.common.exception.ServiceException;
import cn.axzo.framework.domain.web.result.ApiResult;
import cn.axzo.tyr.client.feign.SaasRoleGroupApi;
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
@ -36,7 +35,7 @@ public class SaasRoleGroupController implements SaasRoleGroupApi {
public ApiResult<SaasRoleGroupVO> getById(Long id) {
List<SaasRoleGroupVO> roleGroups = saasRoleGroupService.getList(QuerySaasRoleGroupReq.builder().ids(Lists.newArrayList(id)).build());
if (CollectionUtils.isEmpty(roleGroups)) {
throw new BizException(BaseCode.BAD_REQUEST, "未查询到角色分组信息");
throw new ServiceException("未查询到角色分组信息");
}
return ApiResult.ok(roleGroups.get(0));
}

View File

@ -9,8 +9,6 @@ import cn.axzo.tyr.client.model.vo.SaveOrUpdatePermissionGroupVO;
import cn.axzo.tyr.client.model.vo.SavePermissionGroupPPVO;
import cn.axzo.tyr.server.repository.entity.SaasPermissionGroup;
import java.util.List;
/**
* 角色
*
@ -19,12 +17,12 @@ import java.util.List;
* @date: 2023/9/6 15:51
*/
public interface PermissionGroupService {
/**
* 通用查询
* 接口需要区分查分页或者查询list
* 默认查询page
* @param req
* @return
*/
List<SaasPermissionGroupVO> query(QuerySaasPermissionGroupReq req);
PageResp<SaasPermissionGroupVO> page(QuerySaasPermissionGroupReq req);
void savePermissionPoints(SavePermissionGroupPPVO save);

View File

@ -2,9 +2,8 @@ package cn.axzo.tyr.server.service.impl;
import cn.axzo.basics.common.BeanMapper;
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
import cn.axzo.basics.common.exception.ServiceException;
import cn.axzo.framework.domain.page.PageResp;
import cn.axzo.framework.domain.web.BizException;
import cn.axzo.framework.domain.web.code.BaseCode;
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
import cn.axzo.tyr.client.model.enums.PermissionGroupType;
import cn.axzo.tyr.client.model.enums.PermissionScope;
@ -19,9 +18,11 @@ import cn.axzo.tyr.server.service.PermissionPointService;
import cn.axzo.tyr.server.service.SaasPermissionGroupScopeService;
import cn.axzo.tyr.server.service.SaasPgroupPermissionRelationService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -50,116 +51,6 @@ public class PermissionGroupImpl implements PermissionGroupService {
private final SaasRoleDao saasRoleDao;
private final SaasPermissionGroupScopeService saasPermissionGroupScopeService;
@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())) {
relationList = pgroupRoleRelationDao.lambdaQuery()
.in(SaasPgroupRoleRelation::getRoleId, req.getRoleIds())
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
.list();
List<Long> hitIds = relationList.stream().map(SaasPgroupRoleRelation::getGroupId).distinct().collect(Collectors.toList());
if (org.apache.commons.collections4.CollectionUtils.isNotEmpty(req.getIds())) {
req.getIds().retainAll(hitIds);
} else {
req.setIds(hitIds);
}
// 如果没查询到关联关系则直接返回
if (CollectionUtils.isEmpty(relationList)) {
return new ArrayList<>();
}
}
// 查询权限集
List<SaasPermissionGroup> groupList = permissionGroupDao.lambdaQuery()
.in(CollectionUtils.isNotEmpty(req.getIds()), BaseEntity::getId, req.getIds())
.eq(req.getIsCommon() != null, SaasPermissionGroup::getIsCommon, req.getIsCommon())
.eq(req.getCreateBy() != null, SaasPermissionGroup::getCreateBy, req.getCreateBy())
.eq(req.getUpdateBy() != null, SaasPermissionGroup::getUpdateBy, req.getUpdateBy())
.eq(StringUtils.isNotBlank(req.getType()), SaasPermissionGroup::getType, req.getType())
.like(StringUtils.isNotBlank(req.getName()), SaasPermissionGroup::getName, req.getName())
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
.orderByDesc(BaseEntity::getId)
.list();
// 如果权限集为空则直接返回
if (CollectionUtils.isEmpty(groupList)) {
return new ArrayList<>();
}
List<Long> groupIds = groupList.stream().map(BaseEntity::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(relationList)) {
relationList = pgroupRoleRelationDao.lambdaQuery()
.in(SaasPgroupRoleRelation::getGroupId, groupIds)
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
.list();
}
// 角色和权限集是1Vn 关系权限集必然依附角色存在
Map<Long, SaasPgroupRoleRelation> pgrrMap = relationList.stream().collect(Collectors.toMap(SaasPgroupRoleRelation::getGroupId, Function.identity(), (e1, e2) -> e2));
List<SaasPermissionGroupScope> saasPermissionGroupScopesSource = saasPermissionGroupScopeDao.lambdaQuery()
.in(SaasPermissionGroupScope::getPgroupId, groupIds)
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
.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 -> {
// 过滤出选中的工作台
if (PermissionScopeType.WORKSPACE.getCode().equals(e.getScopeType())) {
if (CollectionUtils.isNotEmpty(workspaceIdWithOutCommon) && ! workspaceIdWithOutCommon.contains(e.getScopeId())) {
return false;
}
}else {
// 过滤出选中的单位
if (CollectionUtils.isNotEmpty(ouIdWithOutCommon) && ! ouIdWithOutCommon.contains(e.getScopeId())) {
return false;
}
}
return true;
}).collect(Collectors.toList());
// 组装填充字段
return groupList.stream().map(group -> {
// 查询权限集关联的权限
List<SaasPgroupPermissionRelation> permissionList = permissionRelationDao.lambdaQuery()
.eq(SaasPgroupPermissionRelation::getGroupId, group.getId())
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
.list();
List<PermissionPointTreeNode> feature = new ArrayList<>();
if (CollectionUtils.isNotEmpty(permissionList)) {
// 查询featureCode
feature = featureService.listNodesByIds(permissionList.stream().map(SaasPgroupPermissionRelation::getFeatureId).collect(Collectors.toList()));
}
return SaasPermissionGroupVO.builder()
.id(group.getId())
.name(group.getName())
.feature(feature)
.scopes(saasPermissionGroupScopes.stream().filter(e -> e.getPgroupId().equals(group.getId())).map(e -> BeanMapper.copyBean(e, SaasRolePermissionScopeVO.class)).collect(Collectors.toList()))
.createBy(group.getCreateBy())
.roleId(Optional.ofNullable(pgrrMap.get(group.getId())).map(SaasPgroupRoleRelation::getRoleId).orElse(null))
.createBy(group.getCreateBy())
.updateBy(group.getUpdateBy())
.creatorName(group.getCreatorName())
.updatorName(group.getUpdatorName())
.type(group.getType())
.isCommon(group.getIsCommon())
.createAt(group.getCreateAt())
.updateAt(group.getUpdateAt())
.build();
}
).collect(Collectors.toList());
}
@Override
public PageResp<SaasPermissionGroupVO> page(QuerySaasPermissionGroupReq req) {
if (CollectionUtils.isEmpty(req.getWorkspaceId())) {
@ -192,7 +83,7 @@ public class PermissionGroupImpl implements PermissionGroupService {
}
}
// 查询权限集
iPage = permissionGroupDao.lambdaQuery()
LambdaQueryChainWrapper<SaasPermissionGroup> lambdaQueryWrapper = permissionGroupDao.lambdaQuery()
.in(CollectionUtils.isNotEmpty(req.getIds()), BaseEntity::getId, req.getIds())
.eq(req.getIsCommon() != null, SaasPermissionGroup::getIsCommon, req.getIsCommon())
.eq(req.getCreateBy() != null, SaasPermissionGroup::getCreateBy, req.getCreateBy())
@ -200,9 +91,17 @@ public class PermissionGroupImpl implements PermissionGroupService {
.eq(StringUtils.isNotBlank(req.getType()), SaasPermissionGroup::getType, req.getType())
.like(StringUtils.isNotBlank(req.getName()), SaasPermissionGroup::getName, req.getName())
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
.orderByAsc(BaseEntity::getCreateAt).orderByAsc(BaseEntity::getId)
.page(iPage);
List<SaasPermissionGroup> groupList = iPage.getRecords();
.orderByAsc(BaseEntity::getCreateAt).orderByAsc(BaseEntity::getId);
List<SaasPermissionGroup> groupList;
if (BooleanUtils.isTrue(req.getFetchPage())) {
// 分页
iPage = lambdaQueryWrapper.page(iPage);
groupList = iPage.getRecords();
} else {
groupList = lambdaQueryWrapper.list();
iPage.setTotal(groupList.size());
}
// 如果权限集为空则直接返回
if (CollectionUtils.isEmpty(groupList)) {
return PageResp.zero(iPage.getCurrent(), iPage.getSize());
@ -337,11 +236,11 @@ public class PermissionGroupImpl implements PermissionGroupService {
.eq(SaasPermissionGroup::getId, permissionGroupId)
.eq(SaasPermissionGroup::getIsDelete, TableIsDeleteEnum.NORMAL.value).list();
if (CollectionUtils.isEmpty(groups)) {
throw new BizException(BaseCode.BAD_REQUEST, "权限集不存在");
throw new ServiceException("权限集不存在");
}
SaasPermissionGroup saasPermissionGroup = groups.get(0);
if (Objects.nonNull(type) && !Objects.equals(saasPermissionGroup.getIsCommon(), type.getCode())) {
throw new BizException(BaseCode.BAD_REQUEST, String.format("权限集不是%s权限集", type.getDesc()));
throw new ServiceException(String.format("权限集不是%s权限集", type.getDesc()));
}
return saasPermissionGroup;
}
@ -353,14 +252,14 @@ public class PermissionGroupImpl implements PermissionGroupService {
.in(SaasPgroupRoleRelation::getGroupId, group.getSpecialPermissionGroupIds())
.eq(SaasPgroupRoleRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value).list();
if (CollectionUtils.isEmpty(relations)) {
throw new BizException(BaseCode.BAD_REQUEST, "权限集不存在");
throw new ServiceException("权限集不存在");
}
List<Long> deleteGroupIds = relations.stream().map(SaasPgroupRoleRelation::getGroupId).sorted().collect(Collectors.toList());
List<SaasPermissionGroup> groups = permissionGroupDao.lambdaQuery()
.in(SaasPermissionGroup::getId, deleteGroupIds)
.eq(SaasPermissionGroup::getIsDelete, TableIsDeleteEnum.NORMAL.value).list();
if (groups.stream().anyMatch(e -> !Objects.equals(e.getIsCommon(), PermissionGroupType.SPECIAL.getCode()))) {
throw new BizException(BaseCode.BAD_REQUEST, "只能删除例外权限集");
throw new ServiceException("只能删除例外权限集");
}
//删除角色关联
pgroupRoleRelationDao.removeByIds(relations.stream().map(SaasPgroupRoleRelation::getId).sorted().collect(Collectors.toList()));
@ -390,7 +289,7 @@ public class PermissionGroupImpl implements PermissionGroupService {
// 验证角色是否存在
SaasRole saasRole = saasRoleDao.getById(permissionGroup.getRoleId());
if (Objects.isNull(saasRole)) {
throw new BizException(BaseCode.BAD_REQUEST, "权限集不存在");
throw new ServiceException("权限集不存在");
}
if (Objects.nonNull(permissionGroup.getId())) {
int relationCount = pgroupRoleRelationDao.lambdaQuery()
@ -398,7 +297,7 @@ public class PermissionGroupImpl implements PermissionGroupService {
.eq(SaasPgroupRoleRelation::getGroupId, permissionGroup.getId())
.eq(SaasPgroupRoleRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value).count();
if (relationCount == 0) {
throw new BizException(BaseCode.BAD_REQUEST, "角色和权限组不存在关联关系");
throw new ServiceException("角色和权限组不存在关联关系");
}
}
validPermissionGroupScope(permissionGroup);
@ -426,7 +325,7 @@ public class PermissionGroupImpl implements PermissionGroupService {
Optional<SaasPermissionGroup> repeatName = groups.stream().filter(g -> !Objects.equals(g.getId(), saasPermissionGroup.getId()) && StringUtils.equalsIgnoreCase(saasPermissionGroup.getName(), g.getName()))
.findFirst();
if (repeatName.isPresent()) {
throw new BizException(BaseCode.BAD_REQUEST, "同角色,分组名称不能重复");
throw new ServiceException("同角色,分组名称不能重复");
}
}
return saasPermissionGroup;
@ -441,7 +340,7 @@ public class PermissionGroupImpl implements PermissionGroupService {
List<SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO> selectedOu = permissionGroup.getSelectedOu();
Set<Integer> scopeTypes = new HashSet<>();
if (CollectionUtils.isEmpty(selectedWorkspace) && CollectionUtils.isEmpty(selectedOu)) {
throw new BizException(BaseCode.BAD_REQUEST, "例外不能为空");
throw new ServiceException("例外不能为空");
}
if (CollectionUtils.isNotEmpty(selectedWorkspace)) {
Map<Integer, List<SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO>> selectedWorkspaceMap = selectedWorkspace.stream()
@ -449,10 +348,10 @@ public class PermissionGroupImpl implements PermissionGroupService {
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, "选择类型设置错误");
throw new ServiceException("选择类型设置错误");
}
if (CollectionUtils.containsAny(includeScopes, excludeScopes)) {
throw new BizException(BaseCode.BAD_REQUEST, "项目部例外设置冲突");
throw new ServiceException("项目部例外设置冲突");
}
scopeTypes.addAll(selectedWorkspace.stream().map(SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO::getType).collect(Collectors.toSet()));
}
@ -462,16 +361,16 @@ public class PermissionGroupImpl implements PermissionGroupService {
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() != selectedOu.size()) {
throw new BizException(BaseCode.BAD_REQUEST, "选择类型设置错误");
throw new ServiceException("选择类型设置错误");
}
if (CollectionUtils.containsAny(includeScopes, excludeScopes)) {
throw new BizException(BaseCode.BAD_REQUEST, "单位例外设置冲突");
throw new ServiceException("单位例外设置冲突");
}
scopeTypes.addAll(selectedOu.stream().map(SaveOrUpdatePermissionGroupVO.PermissionGroupScopeVO::getType).collect(Collectors.toSet()));
}
// 移除这行例外设置支持移除和包含
if (scopeTypes.size() > 1) {
throw new BizException(BaseCode.BAD_REQUEST, "例外类型不能同时指定适用与不适用");
throw new ServiceException("例外类型不能同时指定适用与不适用");
}
}
}

View File

@ -1,8 +1,7 @@
package cn.axzo.tyr.server.service.impl;
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
import cn.axzo.framework.domain.web.BizException;
import cn.axzo.framework.domain.web.code.BaseCode;
import cn.axzo.basics.common.exception.ServiceException;
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
import cn.axzo.tyr.client.model.enums.PermissionGroupType;
import cn.axzo.tyr.client.model.req.QueryByIdentityIdTypeReq;
@ -99,12 +98,13 @@ public class RoleServiceImpl implements RoleService {
// 转map<roleId,relation>
pgrouRelationMap = saasPgroupRoleRelations.stream().collect(Collectors.groupingBy(SaasPgroupRoleRelation::getRoleId));
// 查询权限集
pGroupMap = permissionGroupService.query(QuerySaasPermissionGroupReq.builder()
pGroupMap = permissionGroupService.page(QuerySaasPermissionGroupReq.builder()
.isCommon(isCommon)
.ids(saasPgroupRoleRelations.stream().map(SaasPgroupRoleRelation::getGroupId).collect(Collectors.toList()))
.workspaceId(workspaceId)
.ouId(ouId)
.build())
.fetchPage(Boolean.FALSE)
.build()).getList()
// 转map<pgroupId>
.stream().collect(Collectors.groupingBy(SaasPermissionGroupVO::getId));
}
@ -253,10 +253,10 @@ public class RoleServiceImpl implements RoleService {
} else {
saasRole = saasRoleDao.getById(saveOrUpdateRole.getId());
if (Objects.isNull(saasRole)) {
throw new BizException(BaseCode.BAD_REQUEST, "角色不存在");
throw new ServiceException("角色不存在");
}
if (Objects.isNull(saveOrUpdateRole.getPermissionGroupId())) {
throw new BizException(BaseCode.BAD_REQUEST, "更新角色时权限集不能为空不存在");
throw new ServiceException("更新角色时权限集不能为空不存在");
}
}
saasRole.setName(saveOrUpdateRole.getName());
@ -281,7 +281,7 @@ public class RoleServiceImpl implements RoleService {
.filter(e -> Objects.nonNull(e) && !Objects.equals(e.getId(), saveOrUpdateRole.getId()) && StringUtils.equalsIgnoreCase(e.getName(), saasRole.getName()))
.findFirst();
if (repeatNameRole.isPresent()) {
throw new BizException(BaseCode.BAD_REQUEST, "同分组内不角色名称不能重复");
throw new ServiceException("同分组内不角色名称不能重复");
}
});
}
@ -300,7 +300,7 @@ public class RoleServiceImpl implements RoleService {
return Objects.isNull(target);
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(invalidFeatues)) {
throw new BizException(BaseCode.BAD_REQUEST, "权限点信息错误");
throw new ServiceException("权限点信息错误");
}
}
@ -335,7 +335,7 @@ public class RoleServiceImpl implements RoleService {
return Objects.isNull(target) || !Objects.equals(target.getWorkspaceTypeCode(), rg.getWorkspaceTypeCode());
}).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(invalidRoleGroups)) {
throw new BizException(BaseCode.BAD_REQUEST, "角色分组信息错误");
throw new ServiceException("角色分组信息错误");
}
}

View File

@ -1,13 +1,9 @@
package cn.axzo.tyr.server.service.impl;
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
import cn.axzo.framework.domain.web.BizException;
import cn.axzo.framework.domain.web.code.BaseCode;
import cn.axzo.tyr.client.model.enums.PermissionGroupType;
import cn.axzo.tyr.server.repository.entity.SaasPermissionGroup;
import cn.axzo.tyr.server.repository.entity.SaasPgroupRoleRelation;
import cn.axzo.tyr.server.repository.dao.SaasPermissionGroupDao;
import cn.axzo.basics.common.exception.ServiceException;
import cn.axzo.tyr.server.repository.dao.SaasPgroupRoleRelationDao;
import cn.axzo.tyr.server.repository.entity.SaasPgroupRoleRelation;
import cn.axzo.tyr.server.service.SaasPgroupRoleRelationService;
import cn.hutool.json.JSONUtil;
import lombok.RequiredArgsConstructor;
@ -18,7 +14,6 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
@Slf4j
@ -41,7 +36,7 @@ public class SaasPgroupRoleRelationServiceImpl implements SaasPgroupRoleRelation
// 通用权限集已经 存在
return;
}else {
throw new BizException(BaseCode.BAD_REQUEST,"传入的权限集id与已存在的通用权限集id不一致 req{}", JSONUtil.toJsonStr(commonRelation));
throw new ServiceException(String.format("传入的权限集id与已存在的通用权限集id不一致 req : %s", JSONUtil.toJsonStr(commonRelation)));
}
}
}

View File

@ -1,8 +1,7 @@
package cn.axzo.tyr.server.service.impl;
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
import cn.axzo.framework.domain.web.BizException;
import cn.axzo.framework.domain.web.code.BaseCode;
import cn.axzo.basics.common.exception.ServiceException;
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
import cn.axzo.tyr.server.repository.dao.SaasRoleGroupDao;
@ -100,7 +99,7 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
.eq(SaasRoleGroupRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value)
.count();
if (relationCount > 0) {
throw new BizException(BaseCode.BAD_REQUEST, "分组关联角色,不能删除");
throw new ServiceException("分组关联角色,不能删除");
}
saasRoleGroupDao.delete(ids);
}
@ -117,7 +116,7 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
saasRoleGroup = saasRoleGroupDao.lambdaQuery().eq(SaasRoleGroup::getId, req.getId())
.eq(SaasRoleGroup::getIsDelete, TableIsDeleteEnum.NORMAL.value).one();
if (Objects.isNull(saasRoleGroup)) {
throw new BizException(BaseCode.BAD_REQUEST, "角色分组不存在");
throw new ServiceException("角色分组不存在");
}
}
List<SaasRoleGroup> groups = saasRoleGroupDao.lambdaQuery().eq(SaasRoleGroup::getWorkspaceTypeCode, req.getWorkspaceTypeCode())
@ -126,7 +125,7 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
Optional<SaasRoleGroup> repeatGroupName = groups.stream()
.filter(g -> !Objects.equals(g.getId(), req.getId()) && StringUtils.equalsIgnoreCase(g.getName(), req.getName())).findFirst();
if (repeatGroupName.isPresent()) {
throw new BizException(BaseCode.BAD_REQUEST, "同工作台类型内,分组名称不能重复");
throw new ServiceException("同工作台类型内,分组名称不能重复");
}
}
// 拼接ouTypeCode字符串