删除角色分组

This commit is contained in:
yangsong 2023-09-14 09:41:31 +08:00
parent 3677cad80e
commit 80140309ad
4 changed files with 22 additions and 19 deletions

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

View File

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

View File

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

View File

@ -1,10 +1,10 @@
package cn.axzo.tyr.server.service.impl; package cn.axzo.tyr.server.service.impl;
import java.util.Date;
import cn.axzo.basics.common.constant.enums.TableIsDeleteEnum; 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.req.QuerySaasRoleGroupReq;
import cn.axzo.tyr.client.model.vo.SaasRoleGroupVO; 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.SaasRoleGroup;
import cn.axzo.tyr.server.repository.entity.SaasRoleGroupRelation; import cn.axzo.tyr.server.repository.entity.SaasRoleGroupRelation;
import cn.axzo.tyr.server.repository.service.*; import cn.axzo.tyr.server.repository.service.*;
@ -88,18 +88,21 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService {
saasRoleGroupDao.saveOrUpdate(saasRoleGroup); saasRoleGroupDao.saveOrUpdate(saasRoleGroup);
} }
/**
* 只有当分组下面角色为空时才能删除
* @param ids
*/
@Override @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);
// 删除权限集关联关系
// 删除权限集
} }
} }