Merge remote-tracking branch 'origin/feature/REQ-1102' into feature/REQ-1102

This commit is contained in:
zhansihu 2023-09-14 11:36:59 +08:00
commit 0fc1694edf
7 changed files with 37 additions and 48 deletions

View File

@ -1,8 +1,7 @@
package cn.axzo.tyr.server.common.enums;
package cn.axzo.tyr.client.common.enums;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import java.util.Arrays;

View File

@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import javax.validation.constraints.NotEmpty;
import java.util.List;
/**
@ -37,7 +38,6 @@ public interface SaasRoleGroupApi {
* 删除
*/
@PostMapping("/api/saasRoleGroup//api/saasPermissionGoup/delete")
ApiResult delete(@RequestBody List<Long> id);
ApiResult<Void> delete(@RequestBody@NotEmpty List<Long> ids);
}

View File

@ -36,6 +36,16 @@ public class SaasRoleGroupVO {
*/
private List<Long> roleIds;
/**
* 工作台id(自定义时传入)
*/
private Long workspaceId;
/**
* 单位id(自定义时传入)
*/
private Long ouId;
/**
* 排序
*/

View File

@ -43,8 +43,8 @@ public class SaasRoleGroupController implements SaasRoleGroupApi {
}
@Override
public ApiResult delete(List<Long> id) {
public ApiResult<Void> delete(List<Long> ids) {
saasRoleGroupService.delete(ids);
return ApiResult.ok();
}
}

View File

@ -10,5 +10,5 @@ public interface SaasRoleGroupService {
void saveOrUpdate(SaasRoleGroupVO req);
void delete(Long id);
void delete(List<Long> ids);
}

View File

@ -1,47 +1,22 @@
package cn.axzo.tyr.server.service.impl;
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum;
import cn.axzo.framework.domain.ServiceException;
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
import cn.axzo.tyr.client.model.BaseWorkspaceModel;
import cn.axzo.tyr.client.model.req.QueryByIdentityIdTypeReq;
import cn.axzo.tyr.client.model.req.QuerySaasPermissionGroupReq;
import cn.axzo.tyr.client.model.req.QuerySaasRoleGroupReq;
import cn.axzo.tyr.client.model.req.QuerySaasRoleReq;
import cn.axzo.tyr.client.model.res.QueryBatchByIdentityIdTypeRes;
import cn.axzo.tyr.client.model.roleuser.req.RoleUserReq;
import cn.axzo.tyr.client.model.vo.SaasPermissionGroupVO;
import cn.axzo.tyr.client.model.vo.SaasRoleVO;
import cn.axzo.tyr.server.common.enums.RoleTypeEnum;
import cn.axzo.tyr.server.common.util.StreamUtil;
import cn.axzo.tyr.server.repository.entity.SaasPgroupRoleRelation;
import cn.axzo.tyr.client.common.enums.RoleTypeEnum;
import cn.axzo.tyr.server.repository.entity.SaasRole;
import cn.axzo.tyr.server.repository.entity.SaasRoleGroup;
import cn.axzo.tyr.server.repository.entity.SaasRoleGroupRelation;
import cn.axzo.tyr.server.repository.entity.SaasRoleUserRelation;
import cn.axzo.tyr.server.repository.service.SaasPgroupRoleRelationDao;
import cn.axzo.tyr.server.repository.service.SaasRoleDao;
import cn.axzo.tyr.server.repository.service.SaasRoleGroupDao;
import cn.axzo.tyr.server.repository.service.SaasRoleGroupRelationDao;
import cn.axzo.tyr.server.repository.service.SaasRoleUserRelationDao;
import cn.axzo.tyr.server.service.PermissionGroupService;
import cn.axzo.tyr.server.service.RoleService;
import cn.axzo.tyr.server.service.SaasRoleUserService;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**

View File

@ -1,10 +1,10 @@
package cn.axzo.tyr.server.service.impl;
import java.util.Date;
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.req.QuerySaasRoleGroupReq;
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO;
import cn.axzo.tyr.server.repository.entity.SaasPgroupRoleRelation;
import cn.axzo.tyr.server.repository.entity.SaasRoleGroup;
import cn.axzo.tyr.server.repository.entity.SaasRoleGroupRelation;
import cn.axzo.tyr.server.repository.service.*;
@ -56,7 +56,7 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
return new ArrayList<>();
}
List<SaasRoleGroupRelation> saasRoleGroupRelations = saasRoleGroupRelationDao.lambdaQuery()
.in(SaasRoleGroupRelation::getSaasRoleGroupId, groups.stream().map(SaasRoleGroup::getId))
.in(SaasRoleGroupRelation::getSaasRoleGroupId, groups.stream().map(SaasRoleGroup::getId).collect(Collectors.toList()))
.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())));
List<SaasRoleGroupVO> results = groups.stream()
@ -85,21 +85,26 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
saasRoleGroup.setOuTypeCode(ouTypeCodeStr);
saasRoleGroup.setName(req.getName());
saasRoleGroup.setSort(req.getSort());
saasRoleGroup.setWorkspaceId(req.getWorkspaceId() != null ? req.getWorkspaceId():-1l);
saasRoleGroup.setOuId(req.getOuId() != null ? req.getOuId():-1l);
saasRoleGroupDao.saveOrUpdate(saasRoleGroup);
}
/**
* 只有当分组下面角色为空时才能删除
* @param ids
*/
@Override
public void delete(Long id) {
// 删除分组
// 删除角色分组关联关系
//
// 删除权限分组关联关系
// 删除权限
// 删除权限集关联关系
// 删除权限集
public void delete(List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return;
}
int relationCount = saasRoleGroupRelationDao.lambdaQuery().in(SaasRoleGroupRelation::getSaasRoleGroupId, ids)
.eq(SaasRoleGroupRelation::getIsDelete, TableIsDeleteEnum.NORMAL.value).count();
if (relationCount > 0) {
throw new BizException(BaseCode.BAD_REQUEST, "分组关联角色,不能删除");
}
saasRoleGroupDao.delete(ids);
}
}