From 80140309ad3285812bfb9eaae6bf5c5729f2ef03 Mon Sep 17 00:00:00 2001 From: yangsong Date: Thu, 14 Sep 2023 09:41:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E8=A7=92=E8=89=B2=E5=88=86?= =?UTF-8?q?=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tyr/client/feign/SaasRoleGroupApi.java | 4 +-- .../role/SaasRoleGroupController.java | 4 +-- .../server/service/SaasRoleGroupService.java | 2 +- .../impl/SaasRoleGroupServiceImpl.java | 31 ++++++++++--------- 4 files changed, 22 insertions(+), 19 deletions(-) diff --git a/tyr-api/src/main/java/cn/axzo/tyr/client/feign/SaasRoleGroupApi.java b/tyr-api/src/main/java/cn/axzo/tyr/client/feign/SaasRoleGroupApi.java index 0a61b026..0fbfa3dc 100644 --- a/tyr-api/src/main/java/cn/axzo/tyr/client/feign/SaasRoleGroupApi.java +++ b/tyr-api/src/main/java/cn/axzo/tyr/client/feign/SaasRoleGroupApi.java @@ -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 id); - + ApiResult delete(@RequestBody@NotEmpty List ids); } diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/controller/role/SaasRoleGroupController.java b/tyr-server/src/main/java/cn/axzo/tyr/server/controller/role/SaasRoleGroupController.java index 698dc814..466b5e31 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/controller/role/SaasRoleGroupController.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/controller/role/SaasRoleGroupController.java @@ -43,8 +43,8 @@ public class SaasRoleGroupController implements SaasRoleGroupApi { } @Override - public ApiResult delete(List id) { - + public ApiResult delete(List ids) { + saasRoleGroupService.delete(ids); return ApiResult.ok(); } } diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasRoleGroupService.java b/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasRoleGroupService.java index 456d2f59..c7504af7 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasRoleGroupService.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/service/SaasRoleGroupService.java @@ -10,5 +10,5 @@ public interface SaasRoleGroupService { void saveOrUpdate(SaasRoleGroupVO req); - void delete(Long id); + void delete(List ids); } diff --git a/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasRoleGroupServiceImpl.java b/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasRoleGroupServiceImpl.java index a2a5cac6..2e12c9b2 100644 --- a/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasRoleGroupServiceImpl.java +++ b/tyr-server/src/main/java/cn/axzo/tyr/server/service/impl/SaasRoleGroupServiceImpl.java @@ -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.*; @@ -88,18 +88,21 @@ public class SaasRoleGroupServiceImpl implements SaasRoleGroupService { saasRoleGroupDao.saveOrUpdate(saasRoleGroup); } + /** + * 只有当分组下面角色为空时才能删除 + * @param ids + */ @Override - public void delete(Long id) { - // 删除分组 - - // 删除角色分组关联关系 - - // - - - // 删除权限分组关联关系 - // 删除权限 - // 删除权限集关联关系 - // 删除权限集 + public void delete(List 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); } + }