From 8900cddf8c061d18a253edbf65e67468d3ee3af9 Mon Sep 17 00:00:00 2001 From: dengqichen Date: Mon, 13 Jan 2025 16:47:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=A7=E5=A3=B0=E9=81=93=E6=92=92=E6=97=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../build/JenkinsBaseBuildVariables.java | 6 ---- .../deploy/entity/DeployAppConfig.java | 20 ++++++----- .../deploy/query/RepositoryProjectQuery.java | 9 +++-- .../IRepositoryGroupRepository.java | 3 ++ .../IRepositoryProjectRepository.java | 3 ++ .../service/impl/ApplicationServiceImpl.java | 4 +-- .../impl/DeployAppConfigServiceImpl.java | 1 - .../db/migration/V1.0.0__init_schema.sql | 33 +++++++++++++++---- 8 files changed, 52 insertions(+), 27 deletions(-) diff --git a/backend/src/main/java/com/qqchen/deploy/backend/deploy/dto/variables/build/JenkinsBaseBuildVariables.java b/backend/src/main/java/com/qqchen/deploy/backend/deploy/dto/variables/build/JenkinsBaseBuildVariables.java index 0aff7ebc..8776a4e0 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/deploy/dto/variables/build/JenkinsBaseBuildVariables.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/deploy/dto/variables/build/JenkinsBaseBuildVariables.java @@ -65,12 +65,6 @@ public class JenkinsBaseBuildVariables { ) private String jobId; - @SchemaProperty( - title = "构建产物路径", - description = "构建产物路径", - order = 5 - ) - private String artifactPath; @SchemaProperty( diff --git a/backend/src/main/java/com/qqchen/deploy/backend/deploy/entity/DeployAppConfig.java b/backend/src/main/java/com/qqchen/deploy/backend/deploy/entity/DeployAppConfig.java index 914c43e2..2ad4989a 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/deploy/entity/DeployAppConfig.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/deploy/entity/DeployAppConfig.java @@ -21,12 +21,8 @@ import org.hibernate.annotations.Type; @Table(name = "deploy_app_config") public class DeployAppConfig extends Entity { - - @Column(name = "environment_id", nullable = false) - private Long environmentId; - - @Column(name = "application_id", nullable = false) - private Long applicationId; + @Column(name = "branch", nullable = false) + private String branch; @Column(name = "build_type", nullable = false) @Enumerated(EnumType.STRING) @@ -36,9 +32,6 @@ public class DeployAppConfig extends Entity { @Enumerated(EnumType.STRING) private DevelopmentLanguageTypeEnum languageType; - @Column(name = "workflow_definition_id", nullable = false) - private Long workflowDefinitionId; - @Type(JsonType.class) @Column(name = "form_variables_schema", columnDefinition = "text") private JsonNode formVariablesSchema; @@ -47,6 +40,15 @@ public class DeployAppConfig extends Entity { @Column(name = "build_variables", columnDefinition = "text", nullable = false) private JsonNode buildVariables; + @Column(name = "environment_id", nullable = false) + private Long environmentId; + + @Column(name = "application_id", nullable = false) + private Long applicationId; + + @Column(name = "workflow_definition_id", nullable = false) + private Long workflowDefinitionId; + @Column(name = "enabled", nullable = false) private Boolean enabled; } diff --git a/backend/src/main/java/com/qqchen/deploy/backend/deploy/query/RepositoryProjectQuery.java b/backend/src/main/java/com/qqchen/deploy/backend/deploy/query/RepositoryProjectQuery.java index f073af58..cbea0be6 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/deploy/query/RepositoryProjectQuery.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/deploy/query/RepositoryProjectQuery.java @@ -22,12 +22,15 @@ public class RepositoryProjectQuery extends BaseQuery { @QueryField(field = "visibility") private String visibility; - @QueryField(field = "groupId") - private Long groupId; - @QueryField(field = "externalSystemId") private Long externalSystemId; @QueryField(field = "projectId") private Long projectId; + + @QueryField(field = "repoGroupId") + private Long repoGroupId; + + @QueryField(field = "repoProjectId") + private Long repoProjectId; } \ No newline at end of file diff --git a/backend/src/main/java/com/qqchen/deploy/backend/deploy/repository/IRepositoryGroupRepository.java b/backend/src/main/java/com/qqchen/deploy/backend/deploy/repository/IRepositoryGroupRepository.java index 79ed5c8f..ca85b29e 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/deploy/repository/IRepositoryGroupRepository.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/deploy/repository/IRepositoryGroupRepository.java @@ -5,6 +5,7 @@ import com.qqchen.deploy.backend.framework.repository.IBaseRepository; import org.springframework.stereotype.Repository; import java.util.List; +import java.util.Optional; /** * Git仓库组Repository @@ -37,4 +38,6 @@ public interface IRepositoryGroupRepository extends IBaseRepository findByExternalSystemIdAndDeletedFalse(Long externalSystemId); + + Optional findByRepoGroupId(Long repoGroupId); } \ No newline at end of file diff --git a/backend/src/main/java/com/qqchen/deploy/backend/deploy/repository/IRepositoryProjectRepository.java b/backend/src/main/java/com/qqchen/deploy/backend/deploy/repository/IRepositoryProjectRepository.java index d21fe746..7f8bde3b 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/deploy/repository/IRepositoryProjectRepository.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/deploy/repository/IRepositoryProjectRepository.java @@ -5,6 +5,7 @@ import com.qqchen.deploy.backend.deploy.entity.RepositoryProject; import org.springframework.stereotype.Repository; import java.util.List; +import java.util.Optional; @Repository public interface IRepositoryProjectRepository extends IBaseRepository { @@ -31,4 +32,6 @@ public interface IRepositoryProjectRepository extends IBaseRepository findByExternalSystemIdAndDeletedFalse(Long externalSystemId); + + Optional findByRepoProjectId(Long repoProjectId); } \ No newline at end of file diff --git a/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/ApplicationServiceImpl.java b/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/ApplicationServiceImpl.java index e6eb009b..8e7c911b 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/ApplicationServiceImpl.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/ApplicationServiceImpl.java @@ -70,11 +70,11 @@ public class ApplicationServiceImpl extends BaseServiceImpl application.setProjectGroup(projectGroupConverter.toDto(projectGroup))); // 查询并设置代码仓库组信息 - Optional repositoryGroupOptional = repositoryGroupRepository.findById(application.getRepoGroupId()); + Optional repositoryGroupOptional = repositoryGroupRepository.findByRepoGroupId(application.getRepoGroupId()); repositoryGroupOptional.ifPresent(repositoryGroup -> application.setRepositoryGroup(repositoryGroupConverter.toDto(repositoryGroup))); // 查询并设置代码仓库项目信息 - Optional repositoryProjectOptional = repositoryProjectRepository.findById(application.getRepoProjectId()); + Optional repositoryProjectOptional = repositoryProjectRepository.findByRepoProjectId(application.getRepoProjectId()); repositoryProjectOptional.ifPresent(repositoryProject -> application.setRepositoryProject(repositoryProjectConverter.toDto(repositoryProject))); // 查询并设置外部系统信息 diff --git a/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/DeployAppConfigServiceImpl.java b/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/DeployAppConfigServiceImpl.java index 138cede7..ffd77b3e 100644 --- a/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/DeployAppConfigServiceImpl.java +++ b/backend/src/main/java/com/qqchen/deploy/backend/deploy/service/impl/DeployAppConfigServiceImpl.java @@ -152,7 +152,6 @@ public class DeployAppConfigServiceImpl extends BaseServiceImpl() { })); - WorkflowInstanceDTO workflowInstanceDTO = workflowInstanceService.startWorkflow(request); buildAndSaveDeployLog(dto, environment, application, workflowInstanceDTO); } diff --git a/backend/src/main/resources/db/migration/V1.0.0__init_schema.sql b/backend/src/main/resources/db/migration/V1.0.0__init_schema.sql index 654f81a0..0f273ee3 100644 --- a/backend/src/main/resources/db/migration/V1.0.0__init_schema.sql +++ b/backend/src/main/resources/db/migration/V1.0.0__init_schema.sql @@ -544,14 +544,13 @@ CREATE TABLE deploy_application app_code VARCHAR(50) NOT NULL COMMENT '应用编码', app_name VARCHAR(100) NOT NULL COMMENT '应用名称', app_desc VARCHAR(255) NULL COMMENT '应用描述', - repo_url VARCHAR(255) NULL COMMENT '代码仓库地址', language VARCHAR(50) NULL COMMENT '开发语言:JAVA、PYTHON、NODEJS', - enabled BIT NOT NULL DEFAULT 1 COMMENT '是否启用(0:禁用,1:启用)', - sort INT NOT NULL DEFAULT 0 COMMENT '排序号', repo_group_id BIGINT NOT NULL COMMENT '代码仓库项目ID', repo_project_id BIGINT NOT NULL COMMENT '代码仓库项目ID', project_group_id BIGINT NOT NULL COMMENT '所属项目组ID', external_system_id BIGINT NOT NULL COMMENT '外部系统ID', + enabled BIT NOT NULL DEFAULT 1 COMMENT '是否启用(0:禁用,1:启用)', + sort INT NOT NULL DEFAULT 0 COMMENT '排序号', -- 基础字段 create_by VARCHAR(100) NULL COMMENT '创建人', create_time DATETIME(6) NULL COMMENT '创建时间', @@ -641,7 +640,29 @@ CREATE TABLE deploy_log update_time DATETIME(6) NULL COMMENT '更新时间', version INT NOT NULL DEFAULT 1 COMMENT '版本号', deleted BIT NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除,1-已删除' -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_unicode_ci COMMENT ='部署日志表'; +) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT ='部署日志表'; + + +CREATE TABLE deploy_app_config +( + id BIGINT AUTO_INCREMENT PRIMARY KEY COMMENT '主键ID', + + build_type VARCHAR(50) NOT NULL, + build_variables TEXT NOT NULL, + form_variables_schema TEXT NULL, + language_type VARCHAR(50) NOT NULL, + workflow_definition_id BIGINT NOT NULL, + branch VARCHAR(50) NOT NULL, + + environment_id BIGINT NOT NULL, + application_id BIGINT NOT NULL, + enabled BIT NOT NULL, + + create_by VARCHAR(100) NULL COMMENT '创建人', + create_time DATETIME(6) NULL COMMENT '创建时间', + update_by VARCHAR(100) NULL COMMENT '更新人', + update_time DATETIME(6) NULL COMMENT '更新时间', + version INT NOT NULL DEFAULT 1 COMMENT '版本号', + deleted BIT NOT NULL DEFAULT 0 COMMENT '是否删除:0-未删除,1-已删除' +);