feat: REQ-1650

This commit is contained in:
zuoqinbo 2023-11-30 11:45:21 +08:00
parent 29c75710ca
commit d252f9f230
5 changed files with 60 additions and 12 deletions

View File

@ -46,6 +46,7 @@ public interface TyrSaasRoleApi {
/** /**
* 获取角色列表 * 获取角色列表
*
* @return * @return
*/ */
@PostMapping("/api/saasRole/query") @PostMapping("/api/saasRole/query")
@ -55,18 +56,33 @@ public interface TyrSaasRoleApi {
* 删除 * 删除
*/ */
@PostMapping("/api/saasRole/delete") @PostMapping("/api/saasRole/delete")
ApiResult delete(@RequestBody List<Long> id); @Deprecated
ApiResult<Void> delete(@RequestBody List<Long> id);
/**
* 删除角色
*
* @param roleIds 待删除角色集合
* @param workSpaceId 待删除角色所属workSpaceId
* @param outId 待删除角色所属单位ID
*/
@PostMapping("/api/saasRole/strict/delete")
ApiResult<Void> deleteRole(@RequestParam(required = true) List<Long> roleIds,
@RequestParam(required = true) Long workSpaceId, @RequestParam(required = true) Long outId);
/** /**
* 根据身份id身份类型查询权限列表只返回角色信息 * 根据身份id身份类型查询权限列表只返回角色信息
*
* @param identityType 身份类型 1:工人 2:班组长 3:从业人员 4:监管人员 5:运营人员 * @param identityType 身份类型 1:工人 2:班组长 3:从业人员 4:监管人员 5:运营人员
* @return * @return
*/ */
@GetMapping("/api/saasRole/queryByIdentityIdType") @GetMapping("/api/saasRole/queryByIdentityIdType")
ApiResult<List<SaasRoleVO>> queryByIdentityIdType(@RequestParam(required = true) Long identityId,@RequestParam(required = true) Integer identityType,@RequestParam(required = true) Long workspaceId,@RequestParam(required = true) Long ouId,@RequestParam(required = true) Boolean includePermissionGroup); ApiResult<List<SaasRoleVO>> queryByIdentityIdType(@RequestParam(required = true) Long identityId, @RequestParam(required = true) Integer identityType, @RequestParam(required = true) Long workspaceId, @RequestParam(required = true) Long ouId, @RequestParam(required = true) Boolean includePermissionGroup);
/** /**
* 根据身份id身份类型查询权限列表批量,只返回角色信息 * 根据身份id身份类型查询权限列表批量,只返回角色信息
*
* @return * @return
*/ */
@PostMapping("/api/saasRole/queryBatchByIdentityIdType") @PostMapping("/api/saasRole/queryBatchByIdentityIdType")
@ -74,6 +90,7 @@ public interface TyrSaasRoleApi {
/** /**
* 根据身份id身份类型查询是否为超管 * 根据身份id身份类型查询是否为超管
*
* @return * @return
*/ */
@PostMapping("/api/saasRole/isSuperAdmin") @PostMapping("/api/saasRole/isSuperAdmin")
@ -81,24 +98,24 @@ public interface TyrSaasRoleApi {
/** /**
* 通过角色名字获取角色信息 * 通过角色名字获取角色信息
*
* @return * @return
*/ */
@PostMapping("/api/saasRole/findRoleByName") @PostMapping("/api/saasRole/findRoleByName")
ApiResult<List<QueryRoleByNameResp>> findRoleByName(@RequestBody @Valid QueryRoleByNameReq req); ApiResult<List<QueryRoleByNameResp>> findRoleByName(@RequestBody @Valid QueryRoleByNameReq req);
/** 分页查询角色含用户 **/ /**
* 分页查询角色含用户
**/
@PostMapping("/api/saasRole/queryWithUser") @PostMapping("/api/saasRole/queryWithUser")
ApiPageResult<RoleWithUserRes> queryRoleWithUser(@RequestBody RoleWithUserQueryReq req); ApiPageResult<RoleWithUserRes> queryRoleWithUser(@RequestBody RoleWithUserQueryReq req);
/** /**
*
* 通过工作台类型获取对应的标准角 * 通过工作台类型获取对应的标准角
* */
* */
@GetMapping("/api/saasRole/queryByWorkspaceType") @GetMapping("/api/saasRole/queryByWorkspaceType")
ApiResult<List<SaasRoleAndGroupVO>> queryInitRoleByWorkspaceId(@RequestParam ("workspaceType")String workspaceType); ApiResult<List<SaasRoleAndGroupVO>> queryInitRoleByWorkspaceId(@RequestParam("workspaceType") String workspaceType);
} }

View File

@ -33,6 +33,7 @@ public class PlatAccountChangeLogResp {
/** /**
* 变更类型 * 变更类型
* @see cn.axzo.tyr.client.model.enums.ChangeType
*/ */
private String changeType; private String changeType;

View File

@ -29,8 +29,8 @@ import java.util.List;
* 权限 * 权限
* *
* @version V1.0 * @version V1.0
* @author: ZhanSiHu * @author ZhanSiHu
* @date: 2023/9/6 14:55 * @date 2023/9/6 14:55
*/ */
@Slf4j @Slf4j
@RestController @RestController
@ -64,8 +64,14 @@ public class SaasRoleController implements TyrSaasRoleApi {
} }
@Override @Override
public ApiResult delete(List<Long> id) { public ApiResult<Void> deleteRole(List<Long> roleIds,Long workSpaceId,Long outId) {
return null; roleService.deleteRole(roleIds,workSpaceId,outId);
return ApiResult.ok();
}
@Override
public ApiResult<Void> delete(List<Long> roleIds) {
return ApiResult.ok();
} }
@Override @Override

View File

@ -78,4 +78,12 @@ public interface RoleService {
List<SaasRoleAndGroupVO> queryInitRoleByWorkspaceId(String workspaceType); List<SaasRoleAndGroupVO> queryInitRoleByWorkspaceId(String workspaceType);
/**
* 删除角色列表
* @param roleIds 待删除角色集合
* @param workSpaceId 待删除角色所属workSpaceId
* @param outId 待删除角色所属单位ID
*/
void deleteRole(List<Long> roleIds,Long workSpaceId,Long outId);
} }

View File

@ -5,6 +5,7 @@ import cn.axzo.basics.common.exception.ServiceException;
import cn.axzo.framework.domain.page.PageResp; import cn.axzo.framework.domain.page.PageResp;
import cn.axzo.pokonyan.config.mybatisplus.BaseEntity; import cn.axzo.pokonyan.config.mybatisplus.BaseEntity;
import cn.axzo.tyr.client.common.enums.RoleTypeEnum; import cn.axzo.tyr.client.common.enums.RoleTypeEnum;
import cn.axzo.tyr.client.model.BaseWorkspaceModel;
import cn.axzo.tyr.client.model.enums.IdentityType; import cn.axzo.tyr.client.model.enums.IdentityType;
import cn.axzo.tyr.client.model.enums.PermissionGroupType; import cn.axzo.tyr.client.model.enums.PermissionGroupType;
import cn.axzo.tyr.client.model.permission.PermissionPointTreeNode; import cn.axzo.tyr.client.model.permission.PermissionPointTreeNode;
@ -589,4 +590,19 @@ public class RoleServiceImpl implements RoleService {
}); });
return result; return result;
} }
@Override
public void deleteRole(List<Long> roleIds,Long workSpaceId,Long ouId) {
List<SaasRoleUserRelation> saasRoleUserRelations = roleUserRelationDao.lambdaQuery()
.in(CollectionUtil.isNotEmpty(roleIds),SaasRoleUserRelation::getRoleId,roleIds)
.eq(workSpaceId !=null, SaasRoleUserRelation::getWorkspaceId, workSpaceId)
.eq(ouId!=null, SaasRoleUserRelation::getOuId, ouId)
.eq(BaseEntity::getIsDelete, TableIsDeleteEnum.NORMAL.value)
.list();
if(CollectionUtil.isNotEmpty(saasRoleUserRelations)){
throw new cn.axzo.framework.domain.ServiceException("该角色下存在关联成员,无法进行删除!");
}
roleUserRelationDao.deleteByRoldId(roleIds);
}
} }