From 75d8935ac3faee0e23e001f522afd1e87b937c4d Mon Sep 17 00:00:00 2001 From: dengqichen Date: Wed, 29 Oct 2025 12:17:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=A2=E9=98=9F=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=A2=9E=E5=88=A0=E6=94=B9=E5=B7=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ApplicationCategoryServiceImpl.java | 13 ++++++++++++- .../impl/TeamApplicationServiceImpl.java | 4 +++- .../service/impl/TeamMemberServiceImpl.java | 4 +++- .../deploy/service/impl/TeamServiceImpl.java | 7 ++++--- .../backend/framework/enums/ResponseCode.java | 17 ++++++++++++++++- .../db/changelog/changes/v1.0.0-data.sql | 9 ++------- backend/src/main/resources/messages.properties | 15 +++++++++++++++ 7 files changed, 55 insertions(+), 14 deletions(-) diff --git a/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/ApplicationCategoryServiceImpl.java b/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/ApplicationCategoryServiceImpl.java index f9a2ca74..bae385bb 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/ApplicationCategoryServiceImpl.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/ApplicationCategoryServiceImpl.java @@ -38,11 +38,22 @@ public class ApplicationCategoryServiceImpl extends BaseServiceImpl 0) { + throw new BusinessException(ResponseCode.APPLICATION_CATEGORY_HAS_APPLICATIONS); + } + super.delete(id); + } + @Override public Page page(ApplicationCategoryQuery query) { Page page = super.page(query); diff --git a/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/TeamApplicationServiceImpl.java b/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/TeamApplicationServiceImpl.java index 8e046468..e23a36e2 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/TeamApplicationServiceImpl.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/TeamApplicationServiceImpl.java @@ -10,6 +10,8 @@ import com.qqchen.deploy.backend.deploy.repository.IApplicationRepository; import com.qqchen.deploy.backend.deploy.repository.ITeamApplicationRepository; import com.qqchen.deploy.backend.deploy.repository.ITeamRepository; import com.qqchen.deploy.backend.deploy.service.ITeamApplicationService; +import com.qqchen.deploy.backend.framework.enums.ResponseCode; +import com.qqchen.deploy.backend.framework.exception.BusinessException; import com.qqchen.deploy.backend.framework.service.impl.BaseServiceImpl; import jakarta.annotation.Resource; import lombok.extern.slf4j.Slf4j; @@ -44,7 +46,7 @@ public class TeamApplicationServiceImpl extends BaseServiceImpl 0) { - throw new RuntimeException("该团队下存在成员,无法删除"); + throw new BusinessException(ResponseCode.TEAM_HAS_MEMBERS); } // 检查是否有关联应用 Long applicationCount = teamApplicationRepository.countByTeamIdAndDeletedFalse(id); if (applicationCount > 0) { - throw new RuntimeException("该团队下存在关联应用,无法删除"); + throw new BusinessException(ResponseCode.TEAM_HAS_APPLICATIONS); } super.delete(id); diff --git a/backend/src/main/java/com/qqchen/deploy/backend/framework/enums/ResponseCode.java b/backend/src/main/java/com/qqchen/deploy/backend/framework/enums/ResponseCode.java index f87857e3..47c7a30d 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/framework/enums/ResponseCode.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/framework/enums/ResponseCode.java @@ -155,7 +155,22 @@ public enum ResponseCode { FORM_DEFINITION_NOT_FOUND(2800, "form.definition.not.found"), FORM_DATA_NOT_FOUND(2801, "form.data.not.found"), FORM_DEFINITION_KEY_EXISTS(2802, "form.definition.key.exists"), - FORM_DEFINITION_KEY_VERSION_EXISTS(2803, "form.definition.key.version.exists"); + FORM_DEFINITION_KEY_VERSION_EXISTS(2803, "form.definition.key.version.exists"), + + // 应用分类相关错误码 (2900-2919) + APPLICATION_CATEGORY_NOT_FOUND(2900, "application.category.not.found"), + APPLICATION_CATEGORY_CODE_EXISTS(2901, "application.category.code.exists"), + APPLICATION_CATEGORY_HAS_APPLICATIONS(2902, "application.category.has.applications"), + + // 团队管理相关错误码 (2920-2949) + TEAM_NOT_FOUND(2920, "team.not.found"), + TEAM_CODE_EXISTS(2921, "team.code.exists"), + TEAM_HAS_MEMBERS(2922, "team.has.members"), + TEAM_HAS_APPLICATIONS(2923, "team.has.applications"), + TEAM_MEMBER_NOT_FOUND(2924, "team.member.not.found"), + TEAM_MEMBER_ALREADY_EXISTS(2925, "team.member.already.exists"), + TEAM_APPLICATION_NOT_FOUND(2926, "team.application.not.found"), + TEAM_APPLICATION_ALREADY_EXISTS(2927, "team.application.already.exists"); private final int code; private final String messageKey; // 国际化消息key diff --git a/backend/src/main/resources/db/changelog/changes/v1.0.0-data.sql b/backend/src/main/resources/db/changelog/changes/v1.0.0-data.sql index c553e8cd..0f8606b5 100644 --- a/backend/src/main/resources/db/changelog/changes/v1.0.0-data.sql +++ b/backend/src/main/resources/db/changelog/changes/v1.0.0-data.sql @@ -181,13 +181,8 @@ INSERT INTO sys_external_system ( 'BASIC', 'admin', 'Lianyu!@#~123456', NULL, 'SUCCESS', '2023-12-01 00:00:00', '2023-12-01 00:00:00', '{}' ), ( - 2, 'admin', '2023-12-01 00:00:00', 0, 'admin', '2023-12-01 00:00:00', 0, - 'GitLab测试环境', 'GIT', 'http://gitlab.test.com', '测试环境GitLab服务器', 2, 1, - 'TOKEN', NULL, NULL, 'test-token', - 'SUCCESS', '2023-12-01 00:00:00', '2023-12-01 00:00:00', '{}' -), ( - 3, 'admin', '2024-12-03 10:35:58.932966', 0, 'admin', '2024-12-03 10:35:58.932966', 0, - '链宇GIT', 'GIT', 'http://119.3.203.210:8088/', NULL, 1, 1, + 2, 'admin', '2024-12-03 10:35:58.932966', 0, 'admin', '2024-12-03 10:35:58.932966', 0, + '链宇GIT', 'GIT', 'https://ly-gitlab.iscmtech.com/', NULL, 1, 1, 'TOKEN', NULL, NULL, 'cNSud7D1GmYQKEMco7s5', NULL, NULL, NULL, '{}' ); diff --git a/backend/src/main/resources/messages.properties b/backend/src/main/resources/messages.properties index b54e216f..eaee5eac 100644 --- a/backend/src/main/resources/messages.properties +++ b/backend/src/main/resources/messages.properties @@ -170,3 +170,18 @@ form.definition.not.found=表单定义不存在或已删除 form.data.not.found=表单数据不存在或已删除 form.definition.key.exists=表单标识{0}已存在,请使用不同的标识 form.definition.key.version.exists=表单标识{0}的版本{1}已存在 + +# 应用分类相关 (2900-2919) +application.category.not.found=应用分类不存在或已删除 +application.category.code.exists=分类编码{0}已存在 +application.category.has.applications=该分类下存在应用,无法删除 + +# 团队管理相关 (2920-2949) +team.not.found=团队不存在或已删除 +team.code.exists=团队编码{0}已存在 +team.has.members=该团队下存在成员,无法删除 +team.has.applications=该团队下存在关联应用,无法删除 +team.member.not.found=团队成员不存在或已删除 +team.member.already.exists=该用户已是团队成员 +team.application.not.found=团队应用关联不存在或已删除 +team.application.already.exists=该应用已关联到此团队