1
This commit is contained in:
parent
beaf761b0f
commit
028137e8a0
@ -2,8 +2,11 @@ package com.qqchen.deploy.backend.deploy.dto;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.qqchen.deploy.backend.deploy.enums.BuildTypeEnum;
|
import com.qqchen.deploy.backend.deploy.enums.BuildTypeEnum;
|
||||||
|
import com.qqchen.deploy.backend.deploy.enums.DevelopmentLanguageTypeEnum;
|
||||||
import com.qqchen.deploy.backend.framework.dto.BaseDTO;
|
import com.qqchen.deploy.backend.framework.dto.BaseDTO;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
@ -16,14 +19,21 @@ import lombok.EqualsAndHashCode;
|
|||||||
public class DeployAppConfigDTO extends BaseDTO {
|
public class DeployAppConfigDTO extends BaseDTO {
|
||||||
|
|
||||||
@Schema(description = "环境ID")
|
@Schema(description = "环境ID")
|
||||||
|
@NotBlank(message = "环境ID不能为空")
|
||||||
private Long environmentId;
|
private Long environmentId;
|
||||||
|
|
||||||
@Schema(description = "应用ID")
|
@Schema(description = "应用ID")
|
||||||
|
@NotBlank(message = "应用ID不能为空")
|
||||||
private Long applicationId;
|
private Long applicationId;
|
||||||
|
|
||||||
@Schema(description = "构建类型")
|
@Schema(description = "构建类型")
|
||||||
|
@NotNull(message = "构建类型不能为空")
|
||||||
private BuildTypeEnum buildType;
|
private BuildTypeEnum buildType;
|
||||||
|
|
||||||
@Schema(description = "构建变量")
|
@NotNull(message = "应用语言不能为空")
|
||||||
|
private DevelopmentLanguageTypeEnum languageType;
|
||||||
|
|
||||||
|
@Schema(description = "构建配置")
|
||||||
|
@NotBlank(message = "构建配置不能为空")
|
||||||
private JsonNode buildVariables;
|
private JsonNode buildVariables;
|
||||||
}
|
}
|
||||||
@ -12,7 +12,8 @@ public class JenkinsBaseBuildVariables {
|
|||||||
@SchemaProperty(
|
@SchemaProperty(
|
||||||
title = "分支名称",
|
title = "分支名称",
|
||||||
description = "Git分支名称",
|
description = "Git分支名称",
|
||||||
required = true
|
required = true,
|
||||||
|
order = 1
|
||||||
)
|
)
|
||||||
private String branch;
|
private String branch;
|
||||||
|
|
||||||
|
|||||||
@ -13,52 +13,22 @@ public class JenkinsJavaBuildVariables extends JenkinsBaseBuildVariables {
|
|||||||
|
|
||||||
|
|
||||||
@SchemaProperty(
|
@SchemaProperty(
|
||||||
title = "脚本代码",
|
title = "构建产物路径",
|
||||||
description = "脚本代码",
|
description = "构建产物路径",
|
||||||
required = true
|
order = 2
|
||||||
|
)
|
||||||
|
private String artifactPath;
|
||||||
|
|
||||||
|
|
||||||
|
@SchemaProperty(
|
||||||
|
title = "Pipeline script",
|
||||||
|
description = "流水线脚本",
|
||||||
|
required = true,
|
||||||
|
format = "monaco-editor", // 使用 Monaco Editor
|
||||||
|
defaultValue = "#!/bin/bash\n\necho \"Hello World\"",
|
||||||
|
order = 3
|
||||||
)
|
)
|
||||||
private String script;
|
private String script;
|
||||||
|
|
||||||
/**
|
|
||||||
* 脚本语言
|
|
||||||
*/
|
|
||||||
@SchemaProperty(
|
|
||||||
title = "脚本语言",
|
|
||||||
description = "脚本语言类型",
|
|
||||||
required = true,
|
|
||||||
enumValues = {"shell", "python", "javascript", "groovy"},
|
|
||||||
enumNames = {"Shell脚本 (已支持)", "Python脚本 (开发中)", "JavaScript脚本 (开发中)", "Groovy脚本 (开发中)"},
|
|
||||||
defaultValue = "shell"
|
|
||||||
)
|
|
||||||
private String language;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 解释器路径
|
|
||||||
*/
|
|
||||||
@SchemaProperty(
|
|
||||||
title = "解释器路径",
|
|
||||||
description = "脚本解释器的路径,例如:/bin/bash, /usr/bin/python3",
|
|
||||||
required = true
|
|
||||||
)
|
|
||||||
private String interpreter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 成功退出码
|
|
||||||
*/
|
|
||||||
@SchemaProperty(
|
|
||||||
title = "成功标识",
|
|
||||||
description = "脚本执行成功时的标识",
|
|
||||||
required = true
|
|
||||||
)
|
|
||||||
private Integer successExitCode;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支持的脚本语言列表
|
|
||||||
*/
|
|
||||||
@SchemaProperty(
|
|
||||||
title = "支持的脚本语言",
|
|
||||||
enumValues = {"shell", "python", "javascript", "groovy"},
|
|
||||||
enumNames = {"Shell脚本 (已支持)", "Python脚本 (开发中)", "JavaScript脚本 (开发中)", "Groovy脚本 (开发中)"}
|
|
||||||
)
|
|
||||||
private List<String> supportedLanguages;
|
|
||||||
}
|
}
|
||||||
@ -3,6 +3,7 @@ package com.qqchen.deploy.backend.deploy.entity;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import com.qqchen.deploy.backend.deploy.enums.BuildTypeEnum;
|
import com.qqchen.deploy.backend.deploy.enums.BuildTypeEnum;
|
||||||
|
import com.qqchen.deploy.backend.deploy.enums.DevelopmentLanguageTypeEnum;
|
||||||
import com.qqchen.deploy.backend.framework.domain.Entity;
|
import com.qqchen.deploy.backend.framework.domain.Entity;
|
||||||
import com.vladmihalcea.hibernate.type.json.JsonType;
|
import com.vladmihalcea.hibernate.type.json.JsonType;
|
||||||
import jakarta.persistence.Column;
|
import jakarta.persistence.Column;
|
||||||
@ -26,10 +27,14 @@ public class DeployAppConfig extends Entity<Long> {
|
|||||||
@Column(name = "application_id", nullable = false)
|
@Column(name = "application_id", nullable = false)
|
||||||
private Long applicationId;
|
private Long applicationId;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(name = "build_type", nullable = false)
|
||||||
@Enumerated(EnumType.STRING)
|
@Enumerated(EnumType.STRING)
|
||||||
private BuildTypeEnum buildType;
|
private BuildTypeEnum buildType;
|
||||||
|
|
||||||
|
@Column(name = "language_type", nullable = false)
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private DevelopmentLanguageTypeEnum languageType;
|
||||||
|
|
||||||
@Type(JsonType.class)
|
@Type(JsonType.class)
|
||||||
@Column(name = "build_variables", columnDefinition = "text", nullable = false)
|
@Column(name = "build_variables", columnDefinition = "text", nullable = false)
|
||||||
private JsonNode buildVariables;
|
private JsonNode buildVariables;
|
||||||
|
|||||||
@ -93,4 +93,9 @@ public @interface SchemaProperty {
|
|||||||
* 枚举值显示名称
|
* 枚举值显示名称
|
||||||
*/
|
*/
|
||||||
String[] enumNames() default {};
|
String[] enumNames() default {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 字段排序,值越小越靠前
|
||||||
|
*/
|
||||||
|
int order() default Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,7 +12,8 @@ public class BaseNodePanelVariables {
|
|||||||
@SchemaProperty(
|
@SchemaProperty(
|
||||||
title = "节点编码",
|
title = "节点编码",
|
||||||
description = "工作流节点的编码",
|
description = "工作流节点的编码",
|
||||||
required = true
|
required = true,
|
||||||
|
order = 1
|
||||||
)
|
)
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
@ -22,7 +23,8 @@ public class BaseNodePanelVariables {
|
|||||||
@SchemaProperty(
|
@SchemaProperty(
|
||||||
title = "节点名称",
|
title = "节点名称",
|
||||||
description = "工作流节点的显示名称",
|
description = "工作流节点的显示名称",
|
||||||
required = true
|
required = true,
|
||||||
|
order = 2
|
||||||
)
|
)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@ -31,7 +33,8 @@ public class BaseNodePanelVariables {
|
|||||||
*/
|
*/
|
||||||
@SchemaProperty(
|
@SchemaProperty(
|
||||||
title = "节点描述",
|
title = "节点描述",
|
||||||
description = "工作流节点的详细描述"
|
description = "工作流节点的详细描述",
|
||||||
|
order = 3
|
||||||
)
|
)
|
||||||
private String description;
|
private String description;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,13 +14,6 @@ import java.util.List;
|
|||||||
public class ScriptNodePanelVariables extends BaseNodePanelVariables {
|
public class ScriptNodePanelVariables extends BaseNodePanelVariables {
|
||||||
|
|
||||||
|
|
||||||
@SchemaProperty(
|
|
||||||
title = "脚本代码",
|
|
||||||
description = "脚本代码",
|
|
||||||
required = true
|
|
||||||
)
|
|
||||||
private String script;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 脚本语言
|
* 脚本语言
|
||||||
*/
|
*/
|
||||||
@ -30,27 +23,33 @@ public class ScriptNodePanelVariables extends BaseNodePanelVariables {
|
|||||||
required = true,
|
required = true,
|
||||||
enumValues = {"shell", "python", "javascript", "groovy"},
|
enumValues = {"shell", "python", "javascript", "groovy"},
|
||||||
enumNames = {"Shell脚本 (已支持)", "Python脚本 (开发中)", "JavaScript脚本 (开发中)", "Groovy脚本 (开发中)"},
|
enumNames = {"Shell脚本 (已支持)", "Python脚本 (开发中)", "JavaScript脚本 (开发中)", "Groovy脚本 (开发中)"},
|
||||||
defaultValue = "shell"
|
defaultValue = "shell",
|
||||||
|
order = 10
|
||||||
)
|
)
|
||||||
private String language;
|
private String language;
|
||||||
|
|
||||||
/**
|
@SchemaProperty(
|
||||||
* 解释器路径
|
title = "脚本代码",
|
||||||
*/
|
description = "脚本代码",
|
||||||
|
required = true,
|
||||||
|
format = "monaco-editor",
|
||||||
|
order = 20
|
||||||
|
)
|
||||||
|
private String script;
|
||||||
|
|
||||||
@SchemaProperty(
|
@SchemaProperty(
|
||||||
title = "解释器路径",
|
title = "解释器路径",
|
||||||
description = "脚本解释器的路径,例如:/bin/bash, /usr/bin/python3",
|
description = "脚本解释器的路径,例如:/bin/bash, /usr/bin/python3",
|
||||||
required = true
|
required = true,
|
||||||
|
order = 30
|
||||||
)
|
)
|
||||||
private String interpreter;
|
private String interpreter;
|
||||||
|
|
||||||
/**
|
|
||||||
* 成功退出码
|
|
||||||
*/
|
|
||||||
@SchemaProperty(
|
@SchemaProperty(
|
||||||
title = "成功标识",
|
title = "成功标识",
|
||||||
description = "脚本执行成功时的标识",
|
description = "脚本执行成功时的标识",
|
||||||
required = true
|
required = true,
|
||||||
|
order = 40
|
||||||
)
|
)
|
||||||
private Integer successExitCode;
|
private Integer successExitCode;
|
||||||
|
|
||||||
@ -60,7 +59,8 @@ public class ScriptNodePanelVariables extends BaseNodePanelVariables {
|
|||||||
@SchemaProperty(
|
@SchemaProperty(
|
||||||
title = "支持的脚本语言",
|
title = "支持的脚本语言",
|
||||||
enumValues = {"shell", "python", "javascript", "groovy"},
|
enumValues = {"shell", "python", "javascript", "groovy"},
|
||||||
enumNames = {"Shell脚本 (已支持)", "Python脚本 (开发中)", "JavaScript脚本 (开发中)", "Groovy脚本 (开发中)"}
|
enumNames = {"Shell脚本 (已支持)", "Python脚本 (开发中)", "JavaScript脚本 (开发中)", "Groovy脚本 (开发中)"},
|
||||||
|
order = 50
|
||||||
)
|
)
|
||||||
private List<String> supportedLanguages;
|
private List<String> supportedLanguages;
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,22 @@ public class GenerateSchemaUtils {
|
|||||||
// 获取所有字段,包括父类的字段
|
// 获取所有字段,包括父类的字段
|
||||||
List<Field> allFields = getAllFields(cls);
|
List<Field> allFields = getAllFields(cls);
|
||||||
|
|
||||||
|
// 按SchemaProperty的order排序
|
||||||
|
allFields.sort((a, b) -> {
|
||||||
|
SchemaProperty annotationA = a.getAnnotation(SchemaProperty.class);
|
||||||
|
SchemaProperty annotationB = b.getAnnotation(SchemaProperty.class);
|
||||||
|
if (annotationA == null && annotationB == null) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (annotationA == null) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
if (annotationB == null) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return Integer.compare(annotationA.order(), annotationB.order());
|
||||||
|
});
|
||||||
|
|
||||||
// 遍历所有字段
|
// 遍历所有字段
|
||||||
for (Field field : allFields) {
|
for (Field field : allFields) {
|
||||||
SchemaProperty annotation = field.getAnnotation(SchemaProperty.class);
|
SchemaProperty annotation = field.getAnnotation(SchemaProperty.class);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user