Merge remote-tracking branch 'origin/feature/REQ-1102' into feature/REQ-1102
This commit is contained in:
commit
02ebffb1ef
@ -46,11 +46,6 @@ public class SaveOrUpdateRoleVO {
|
|||||||
@Valid
|
@Valid
|
||||||
private List<GroupInfoVO> groupTree;
|
private List<GroupInfoVO> groupTree;
|
||||||
|
|
||||||
/**
|
|
||||||
* 通用权限集id(编辑时有效)
|
|
||||||
*/
|
|
||||||
private Long permissionGroupId;
|
|
||||||
|
|
||||||
private String permissionGroupName;
|
private String permissionGroupName;
|
||||||
|
|
||||||
private String permissionGroupDescription;
|
private String permissionGroupDescription;
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
package cn.axzo.tyr.server.service;
|
|
||||||
|
|
||||||
import cn.axzo.tyr.server.repository.entity.SaasPgroupRoleRelation;
|
|
||||||
|
|
||||||
public interface SaasPgroupRoleRelationService {
|
|
||||||
/**
|
|
||||||
* 处理通用权限集
|
|
||||||
* @param commonRelation
|
|
||||||
*/
|
|
||||||
void saveOrUpdateCommon(SaasPgroupRoleRelation commonRelation);
|
|
||||||
}
|
|
||||||
@ -296,7 +296,7 @@ public class PermissionGroupImpl implements PermissionGroupService {
|
|||||||
// 验证角色是否存在
|
// 验证角色是否存在
|
||||||
SaasRole saasRole = saasRoleDao.getById(permissionGroup.getRoleId());
|
SaasRole saasRole = saasRoleDao.getById(permissionGroup.getRoleId());
|
||||||
if (Objects.isNull(saasRole)) {
|
if (Objects.isNull(saasRole)) {
|
||||||
throw new ServiceException("权限集不存在");
|
throw new ServiceException("角色不存在");
|
||||||
}
|
}
|
||||||
if (Objects.nonNull(permissionGroup.getId())) {
|
if (Objects.nonNull(permissionGroup.getId())) {
|
||||||
int relationCount = pgroupRoleRelationDao.lambdaQuery()
|
int relationCount = pgroupRoleRelationDao.lambdaQuery()
|
||||||
|
|||||||
@ -16,7 +16,10 @@ import cn.axzo.tyr.client.model.vo.SaasRoleVO;
|
|||||||
import cn.axzo.tyr.client.model.vo.SaveOrUpdateRoleVO;
|
import cn.axzo.tyr.client.model.vo.SaveOrUpdateRoleVO;
|
||||||
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.repository.entity.*;
|
||||||
import cn.axzo.tyr.server.service.*;
|
import cn.axzo.tyr.server.service.PermissionGroupService;
|
||||||
|
import cn.axzo.tyr.server.service.RoleService;
|
||||||
|
import cn.axzo.tyr.server.service.SaasPgroupPermissionRelationService;
|
||||||
|
import cn.axzo.tyr.server.service.SaasRoleGroupRelationService;
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@ -50,7 +53,7 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
PermissionGroupService permissionGroupService;
|
PermissionGroupService permissionGroupService;
|
||||||
@Autowired
|
@Autowired
|
||||||
SaasPgroupRoleRelationDao permissionGroupRelation;
|
SaasPgroupRoleRelationDao saasPgroupRoleRelationDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
SaasRoleGroupDao saasRoleGroupDao;
|
SaasRoleGroupDao saasRoleGroupDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -62,8 +65,6 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
SaasFeatureDao saasFeatureDao;
|
SaasFeatureDao saasFeatureDao;
|
||||||
@Autowired
|
@Autowired
|
||||||
SaasPgroupRoleRelationService saasPgroupRoleRelationService;
|
|
||||||
@Autowired
|
|
||||||
SaasPgroupPermissionRelationService saasPgroupPermissionRelationService;
|
SaasPgroupPermissionRelationService saasPgroupPermissionRelationService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -232,8 +233,10 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
pgrr.setUpdateBy(saveOrUpdateRole.getOperatorId());
|
pgrr.setUpdateBy(saveOrUpdateRole.getOperatorId());
|
||||||
pgrr.setCreateAt(now);
|
pgrr.setCreateAt(now);
|
||||||
pgrr.setUpdateAt(now);
|
pgrr.setUpdateAt(now);
|
||||||
// 新增或保存角色通用权限映射
|
// 保存角色通用权限映射,通用权限的映射关系不会被变更
|
||||||
saasPgroupRoleRelationService.saveOrUpdateCommon(pgrr);
|
if (Objects.isNull(saveOrUpdateRole.getId())) {
|
||||||
|
saasPgroupRoleRelationDao.save(pgrr);
|
||||||
|
}
|
||||||
// 保存权限集和权限点映射关系
|
// 保存权限集和权限点映射关系
|
||||||
List<SaasPgroupPermissionRelation> pgpRelations = Optional.ofNullable(saveOrUpdateRole.getSelectedPPIds()).orElse(new ArrayList<>()).stream().map(ppId -> {
|
List<SaasPgroupPermissionRelation> pgpRelations = Optional.ofNullable(saveOrUpdateRole.getSelectedPPIds()).orElse(new ArrayList<>()).stream().map(ppId -> {
|
||||||
SaasPgroupPermissionRelation target = new SaasPgroupPermissionRelation();
|
SaasPgroupPermissionRelation target = new SaasPgroupPermissionRelation();
|
||||||
@ -281,9 +284,6 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
if (Objects.isNull(saasRole)) {
|
if (Objects.isNull(saasRole)) {
|
||||||
throw new ServiceException("角色不存在");
|
throw new ServiceException("角色不存在");
|
||||||
}
|
}
|
||||||
if (Objects.isNull(saveOrUpdateRole.getPermissionGroupId())) {
|
|
||||||
throw new ServiceException("更新角色时权限集不能为空不存在");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
saasRole.setName(saveOrUpdateRole.getName());
|
saasRole.setName(saveOrUpdateRole.getName());
|
||||||
saasRole.setDescription(saasRole.getDescription());
|
saasRole.setDescription(saasRole.getDescription());
|
||||||
@ -332,13 +332,29 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
|
|
||||||
private SaasPermissionGroup validPermissionGroupCommon(SaveOrUpdateRoleVO saveOrUpdateRole) {
|
private SaasPermissionGroup validPermissionGroupCommon(SaveOrUpdateRoleVO saveOrUpdateRole) {
|
||||||
SaasPermissionGroup saasPermissionGroup;
|
SaasPermissionGroup saasPermissionGroup;
|
||||||
if (Objects.isNull(saveOrUpdateRole.getPermissionGroupId())) {
|
if (Objects.isNull(saveOrUpdateRole.getId())) {
|
||||||
|
//新增
|
||||||
saasPermissionGroup = new SaasPermissionGroup();
|
saasPermissionGroup = new SaasPermissionGroup();
|
||||||
saasPermissionGroup.setIsCommon(PermissionGroupType.COMMON.getCode());
|
saasPermissionGroup.setIsCommon(PermissionGroupType.COMMON.getCode());
|
||||||
saasPermissionGroup.setCreateBy(saveOrUpdateRole.getOperatorId());
|
saasPermissionGroup.setCreateBy(saveOrUpdateRole.getOperatorId());
|
||||||
saasPermissionGroup.setCreatorName(saveOrUpdateRole.getOperatorName());
|
saasPermissionGroup.setCreatorName(saveOrUpdateRole.getOperatorName());
|
||||||
} else {
|
} else {
|
||||||
saasPermissionGroup = permissionGroupService.getRequiredPermissionGroup(saveOrUpdateRole.getPermissionGroupId(), PermissionGroupType.COMMON);
|
// 修改验证
|
||||||
|
List<SaasPgroupRoleRelation> relations = saasPgroupRoleRelationDao.lambdaQuery().eq(SaasPgroupRoleRelation::getRoleId, saveOrUpdateRole.getId())
|
||||||
|
.eq(SaasPgroupRoleRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value).list();
|
||||||
|
if (CollectionUtils.isEmpty(relations)) {
|
||||||
|
throw new ServiceException("数据错误,通用权限集不存在");
|
||||||
|
}
|
||||||
|
List<Long> pgroupIds = relations.stream().map(SaasPgroupRoleRelation::getGroupId).sorted().collect(Collectors.toList());
|
||||||
|
List<SaasPermissionGroup> commonGroups = saasPermissionGroupDao.lambdaQuery().in(SaasPermissionGroup::getId, pgroupIds).eq(SaasPermissionGroup::getIsCommon, PermissionGroupType.COMMON.getCode())
|
||||||
|
.eq(SaasPermissionGroup::getIsDelete, TableIsDeleteEnum.NORMAL.value).list();
|
||||||
|
if (CollectionUtils.isEmpty(commonGroups)) {
|
||||||
|
throw new ServiceException("数据错误,通用权限集不存在");
|
||||||
|
}
|
||||||
|
if (commonGroups.size() > 1) {
|
||||||
|
throw new ServiceException("数据错误,存在多个通用权限集");
|
||||||
|
}
|
||||||
|
saasPermissionGroup = commonGroups.get(0);
|
||||||
}
|
}
|
||||||
saasPermissionGroup.setName(saveOrUpdateRole.getPermissionGroupName());
|
saasPermissionGroup.setName(saveOrUpdateRole.getPermissionGroupName());
|
||||||
saasPermissionGroup.setDescription(saveOrUpdateRole.getPermissionGroupDescription());
|
saasPermissionGroup.setDescription(saveOrUpdateRole.getPermissionGroupDescription());
|
||||||
@ -369,7 +385,7 @@ public class RoleServiceImpl implements RoleService {
|
|||||||
* 根据角色id查询权限集关联关系
|
* 根据角色id查询权限集关联关系
|
||||||
*/
|
*/
|
||||||
public List<SaasPgroupRoleRelation> queryPermissionGroupRelation(List<Long> roleIds) {
|
public List<SaasPgroupRoleRelation> queryPermissionGroupRelation(List<Long> roleIds) {
|
||||||
return permissionGroupRelation.lambdaQuery()
|
return saasPgroupRoleRelationDao.lambdaQuery()
|
||||||
.in(SaasPgroupRoleRelation::getRoleId, roleIds)
|
.in(SaasPgroupRoleRelation::getRoleId, roleIds)
|
||||||
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
|
||||||
.list();
|
.list();
|
||||||
|
|||||||
@ -1,42 +0,0 @@
|
|||||||
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.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;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
@Slf4j
|
|
||||||
@Service
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class SaasPgroupRoleRelationServiceImpl implements SaasPgroupRoleRelationService {
|
|
||||||
private final SaasPgroupRoleRelationDao saasPgroupRoleRelationDao;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void saveOrUpdateCommon(SaasPgroupRoleRelation commonRelation) {
|
|
||||||
List<SaasPgroupRoleRelation> relations = saasPgroupRoleRelationDao.lambdaQuery().eq(SaasPgroupRoleRelation::getRoleId, commonRelation.getRoleId())
|
|
||||||
.eq(SaasPgroupRoleRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value).list();
|
|
||||||
if (CollectionUtils.isEmpty(relations)) {
|
|
||||||
saasPgroupRoleRelationDao.save(commonRelation);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<SaasPgroupRoleRelation> prr = relations.stream().filter(e -> Objects.equals(commonRelation.getGroupId(), e.getGroupId())).collect(Collectors.toList());
|
|
||||||
if (CollectionUtils.isNotEmpty(prr)) {
|
|
||||||
// 通用权限集已经 存在
|
|
||||||
return;
|
|
||||||
}else {
|
|
||||||
throw new ServiceException(String.format("传入的权限集id与已存在的通用权限集id不一致 req : %s", JSONUtil.toJsonStr(commonRelation)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user