From 0e88e522146a66b3d20dbaccae4071569238f346 Mon Sep 17 00:00:00 2001 From: jianxing Date: Mon, 17 Jul 2023 16:52:18 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE=E6=8F=92=E4=BB=B6=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=8E=A5=E5=8F=A3=E8=AE=BE=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --task=1012390 --user=陈建星 系统设置-系统-插件管理-后台 https://www.tapd.cn/55049933/s/1393426 --- .../io/metersphere/system/domain/Plugin.java | 56 +- .../metersphere/system/domain/PluginBlob.java | 23 - .../system/domain/PluginExample.java | 596 +++++++----------- .../system/domain/PluginFrontScript.java | 25 + ...ple.java => PluginFrontScriptExample.java} | 130 +++- .../system/domain/PluginOrganization.java | 22 + .../domain/PluginOrganizationExample.java | 340 ++++++++++ .../system/mapper/PluginBlobMapper.java | 34 - .../mapper/PluginFrontScriptMapper.java | 34 + ...Mapper.xml => PluginFrontScriptMapper.xml} | 131 ++-- .../system/mapper/PluginMapper.xml | 162 ++--- .../mapper/PluginOrganizationMapper.java | 24 + .../mapper/PluginOrganizationMapper.xml | 145 +++++ .../3.0.0/ddl/V3.0.0_11__system_setting.sql | 58 +- .../config/interceptor/SystemInterceptor.java | 2 - .../sdk/constants/PermissionConstants.java | 7 + .../sdk/constants/PluginScenarioType.java | 5 + .../handler/ResultResponseBodyAdvice.java | 4 +- .../sdk/dto/OrganizationOptionDTO.java | 20 + .../dto/request/UserRoleUpdateRequest.java | 2 +- .../resources/i18n/system_en_US.properties | 34 +- .../resources/i18n/system_zh_CN.properties | 33 +- .../resources/i18n/system_zh_TW.properties | 36 +- .../sdk/src/test/java/base/BaseTest.java | 100 ++- .../system/controller/PluginController.java | 86 +++ .../io/metersphere/system/dto/PluginDTO.java | 17 + .../metersphere/system/dto/PluginListDTO.java | 22 + .../dto/request/PluginQueryRequest.java | 49 ++ .../system/request/PluginUpdateRequest.java | 47 ++ .../system/service/PluginService.java | 77 +++ .../src/main/resources/permission.json | 20 + .../main/resources/systemGeneratorConfig.xml | 3 +- ...st.java => AuthSourceControllerTests.java} | 2 +- ...onParamTest.java => CommonParamTests.java} | 4 +- ...leCenterTest.java => FileCenterTests.java} | 2 +- ...ava => GlobalUserRoleControllerTests.java} | 38 +- ...lobalUserRoleRelationControllerTests.java} | 38 +- .../controller/PluginControllerTests.java | 129 ++++ ...va => SystemParameterControllerTests.java} | 2 +- .../param/PluginUpdateRequestDefinition.java | 25 + .../UserRoleUpdateRequestDefinition.java | 2 +- 41 files changed, 1795 insertions(+), 791 deletions(-) delete mode 100644 backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginBlob.java create mode 100644 backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginFrontScript.java rename backend/framework/domain/src/main/java/io/metersphere/system/domain/{PluginBlobExample.java => PluginFrontScriptExample.java} (57%) create mode 100644 backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginOrganization.java create mode 100644 backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginOrganizationExample.java delete mode 100644 backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginBlobMapper.java create mode 100644 backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginFrontScriptMapper.java rename backend/framework/domain/src/main/java/io/metersphere/system/mapper/{PluginBlobMapper.xml => PluginFrontScriptMapper.xml} (62%) create mode 100644 backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginOrganizationMapper.java create mode 100644 backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginOrganizationMapper.xml create mode 100644 backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PluginScenarioType.java create mode 100644 backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/OrganizationOptionDTO.java create mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/controller/PluginController.java create mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/dto/PluginDTO.java create mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/dto/PluginListDTO.java create mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/PluginQueryRequest.java create mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/request/PluginUpdateRequest.java create mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/service/PluginService.java rename backend/services/system-setting/src/test/java/io/metersphere/system/controller/{AuthSourceControllerTest.java => AuthSourceControllerTests.java} (99%) rename backend/services/system-setting/src/test/java/io/metersphere/system/controller/{CommonParamTest.java => CommonParamTests.java} (91%) rename backend/services/system-setting/src/test/java/io/metersphere/system/controller/{FileCenterTest.java => FileCenterTests.java} (99%) rename backend/services/system-setting/src/test/java/io/metersphere/system/controller/{GlobalUserRoleControllerTest.java => GlobalUserRoleControllerTests.java} (91%) rename backend/services/system-setting/src/test/java/io/metersphere/system/controller/{GlobalUserRoleRelationControllerTest.java => GlobalUserRoleRelationControllerTests.java} (87%) create mode 100644 backend/services/system-setting/src/test/java/io/metersphere/system/controller/PluginControllerTests.java rename backend/services/system-setting/src/test/java/io/metersphere/system/controller/{SystemParameterControllerTest.java => SystemParameterControllerTests.java} (99%) create mode 100644 backend/services/system-setting/src/test/java/io/metersphere/system/controller/param/PluginUpdateRequestDefinition.java diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/Plugin.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/Plugin.java index b0ba6e566a..ad5f90b2d8 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/system/domain/Plugin.java +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/Plugin.java @@ -13,55 +13,43 @@ public class Plugin implements Serializable { @Size(min = 1, max = 50, message = "{plugin.id.length_range}", groups = {Created.class, Updated.class}) private String id; - @Schema(title = "plugin name") + @Schema(title = "插件名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{plugin.name.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 255, message = "{plugin.name.length_range}", groups = {Created.class, Updated.class}) private String name; - @Schema(title = "Plugin id", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(title = "插件ID(名称加版本号)", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{plugin.plugin_id.not_blank}", groups = {Created.class}) @Size(min = 1, max = 300, message = "{plugin.plugin_id.length_range}", groups = {Created.class, Updated.class}) private String pluginId; - @Schema(title = "Ui script id", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{plugin.script_id.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 300, message = "{plugin.script_id.length_range}", groups = {Created.class, Updated.class}) - private String scriptId; + @Schema(title = "文件名", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{plugin.file_name.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 300, message = "{plugin.file_name.length_range}", groups = {Created.class, Updated.class}) + private String fileName; - @Schema(title = "Plugin clazzName", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{plugin.clazz_name.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 500, message = "{plugin.clazz_name.length_range}", groups = {Created.class, Updated.class}) - private String clazzName; - - @Schema(title = "Jmeter base clazzName", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{plugin.jmeter_clazz.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 300, message = "{plugin.jmeter_clazz.length_range}", groups = {Created.class, Updated.class}) - private String jmeterClazz; - - @Schema(title = "Plugin jar path", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{plugin.source_path.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 300, message = "{plugin.source_path.length_range}", groups = {Created.class, Updated.class}) - private String sourcePath; - - @Schema(title = "Plugin jar name", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{plugin.source_name.not_blank}", groups = {Created.class}) - @Size(min = 1, max = 300, message = "{plugin.source_name.length_range}", groups = {Created.class, Updated.class}) - private String sourceName; - - @Schema(title = "plugin init entry class") - private String execEntry; - - @Schema(title = "") + @Schema(title = "创建时间") private Long createTime; - @Schema(title = "") + @Schema(title = "更新时间") private Long updateTime; - @Schema(title = "") + @Schema(title = "创建人") private String createUser; - @Schema(title = "Is xpack plugin") + @Schema(title = "是否启用插件") + private Boolean enable; + + @Schema(title = "是否是全局插件") + private Boolean global; + + @Schema(title = "是否是企业版插件") private Boolean xpack; - @Schema(title = "Plugin usage scenarios", requiredMode = Schema.RequiredMode.REQUIRED) + @Schema(title = "插件描述") + private String description; + + @Schema(title = "插件使用场景PAI/PLATFORM", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{plugin.scenario.not_blank}", groups = {Created.class}) @Size(min = 1, max = 50, message = "{plugin.scenario.length_range}", groups = {Created.class, Updated.class}) private String scenario; diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginBlob.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginBlob.java deleted file mode 100644 index 18c270f375..0000000000 --- a/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginBlob.java +++ /dev/null @@ -1,23 +0,0 @@ -package io.metersphere.system.domain; - -import io.metersphere.validation.groups.*; -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.*; -import java.io.Serializable; -import lombok.Data; - -@Data -public class PluginBlob implements Serializable { - @Schema(title = "ID", requiredMode = Schema.RequiredMode.REQUIRED) - @NotBlank(message = "{plugin_blob.id.not_blank}", groups = {Updated.class}) - @Size(min = 1, max = 50, message = "{plugin_blob.id.length_range}", groups = {Created.class, Updated.class}) - private String id; - - @Schema(title = "plugin form option") - private byte[] formOption; - - @Schema(title = "plugin form script") - private byte[] formScript; - - private static final long serialVersionUID = 1L; -} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginExample.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginExample.java index daafaf99e1..1abc22f0a7 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginExample.java @@ -314,423 +314,73 @@ public class PluginExample { return (Criteria) this; } - public Criteria andScriptIdIsNull() { - addCriterion("script_id is null"); + public Criteria andFileNameIsNull() { + addCriterion("file_name is null"); return (Criteria) this; } - public Criteria andScriptIdIsNotNull() { - addCriterion("script_id is not null"); + public Criteria andFileNameIsNotNull() { + addCriterion("file_name is not null"); return (Criteria) this; } - public Criteria andScriptIdEqualTo(String value) { - addCriterion("script_id =", value, "scriptId"); + public Criteria andFileNameEqualTo(String value) { + addCriterion("file_name =", value, "fileName"); return (Criteria) this; } - public Criteria andScriptIdNotEqualTo(String value) { - addCriterion("script_id <>", value, "scriptId"); + public Criteria andFileNameNotEqualTo(String value) { + addCriterion("file_name <>", value, "fileName"); return (Criteria) this; } - public Criteria andScriptIdGreaterThan(String value) { - addCriterion("script_id >", value, "scriptId"); + public Criteria andFileNameGreaterThan(String value) { + addCriterion("file_name >", value, "fileName"); return (Criteria) this; } - public Criteria andScriptIdGreaterThanOrEqualTo(String value) { - addCriterion("script_id >=", value, "scriptId"); + public Criteria andFileNameGreaterThanOrEqualTo(String value) { + addCriterion("file_name >=", value, "fileName"); return (Criteria) this; } - public Criteria andScriptIdLessThan(String value) { - addCriterion("script_id <", value, "scriptId"); + public Criteria andFileNameLessThan(String value) { + addCriterion("file_name <", value, "fileName"); return (Criteria) this; } - public Criteria andScriptIdLessThanOrEqualTo(String value) { - addCriterion("script_id <=", value, "scriptId"); + public Criteria andFileNameLessThanOrEqualTo(String value) { + addCriterion("file_name <=", value, "fileName"); return (Criteria) this; } - public Criteria andScriptIdLike(String value) { - addCriterion("script_id like", value, "scriptId"); + public Criteria andFileNameLike(String value) { + addCriterion("file_name like", value, "fileName"); return (Criteria) this; } - public Criteria andScriptIdNotLike(String value) { - addCriterion("script_id not like", value, "scriptId"); + public Criteria andFileNameNotLike(String value) { + addCriterion("file_name not like", value, "fileName"); return (Criteria) this; } - public Criteria andScriptIdIn(List values) { - addCriterion("script_id in", values, "scriptId"); + public Criteria andFileNameIn(List values) { + addCriterion("file_name in", values, "fileName"); return (Criteria) this; } - public Criteria andScriptIdNotIn(List values) { - addCriterion("script_id not in", values, "scriptId"); + public Criteria andFileNameNotIn(List values) { + addCriterion("file_name not in", values, "fileName"); return (Criteria) this; } - public Criteria andScriptIdBetween(String value1, String value2) { - addCriterion("script_id between", value1, value2, "scriptId"); + public Criteria andFileNameBetween(String value1, String value2) { + addCriterion("file_name between", value1, value2, "fileName"); return (Criteria) this; } - public Criteria andScriptIdNotBetween(String value1, String value2) { - addCriterion("script_id not between", value1, value2, "scriptId"); - return (Criteria) this; - } - - public Criteria andClazzNameIsNull() { - addCriterion("clazz_name is null"); - return (Criteria) this; - } - - public Criteria andClazzNameIsNotNull() { - addCriterion("clazz_name is not null"); - return (Criteria) this; - } - - public Criteria andClazzNameEqualTo(String value) { - addCriterion("clazz_name =", value, "clazzName"); - return (Criteria) this; - } - - public Criteria andClazzNameNotEqualTo(String value) { - addCriterion("clazz_name <>", value, "clazzName"); - return (Criteria) this; - } - - public Criteria andClazzNameGreaterThan(String value) { - addCriterion("clazz_name >", value, "clazzName"); - return (Criteria) this; - } - - public Criteria andClazzNameGreaterThanOrEqualTo(String value) { - addCriterion("clazz_name >=", value, "clazzName"); - return (Criteria) this; - } - - public Criteria andClazzNameLessThan(String value) { - addCriterion("clazz_name <", value, "clazzName"); - return (Criteria) this; - } - - public Criteria andClazzNameLessThanOrEqualTo(String value) { - addCriterion("clazz_name <=", value, "clazzName"); - return (Criteria) this; - } - - public Criteria andClazzNameLike(String value) { - addCriterion("clazz_name like", value, "clazzName"); - return (Criteria) this; - } - - public Criteria andClazzNameNotLike(String value) { - addCriterion("clazz_name not like", value, "clazzName"); - return (Criteria) this; - } - - public Criteria andClazzNameIn(List values) { - addCriterion("clazz_name in", values, "clazzName"); - return (Criteria) this; - } - - public Criteria andClazzNameNotIn(List values) { - addCriterion("clazz_name not in", values, "clazzName"); - return (Criteria) this; - } - - public Criteria andClazzNameBetween(String value1, String value2) { - addCriterion("clazz_name between", value1, value2, "clazzName"); - return (Criteria) this; - } - - public Criteria andClazzNameNotBetween(String value1, String value2) { - addCriterion("clazz_name not between", value1, value2, "clazzName"); - return (Criteria) this; - } - - public Criteria andJmeterClazzIsNull() { - addCriterion("jmeter_clazz is null"); - return (Criteria) this; - } - - public Criteria andJmeterClazzIsNotNull() { - addCriterion("jmeter_clazz is not null"); - return (Criteria) this; - } - - public Criteria andJmeterClazzEqualTo(String value) { - addCriterion("jmeter_clazz =", value, "jmeterClazz"); - return (Criteria) this; - } - - public Criteria andJmeterClazzNotEqualTo(String value) { - addCriterion("jmeter_clazz <>", value, "jmeterClazz"); - return (Criteria) this; - } - - public Criteria andJmeterClazzGreaterThan(String value) { - addCriterion("jmeter_clazz >", value, "jmeterClazz"); - return (Criteria) this; - } - - public Criteria andJmeterClazzGreaterThanOrEqualTo(String value) { - addCriterion("jmeter_clazz >=", value, "jmeterClazz"); - return (Criteria) this; - } - - public Criteria andJmeterClazzLessThan(String value) { - addCriterion("jmeter_clazz <", value, "jmeterClazz"); - return (Criteria) this; - } - - public Criteria andJmeterClazzLessThanOrEqualTo(String value) { - addCriterion("jmeter_clazz <=", value, "jmeterClazz"); - return (Criteria) this; - } - - public Criteria andJmeterClazzLike(String value) { - addCriterion("jmeter_clazz like", value, "jmeterClazz"); - return (Criteria) this; - } - - public Criteria andJmeterClazzNotLike(String value) { - addCriterion("jmeter_clazz not like", value, "jmeterClazz"); - return (Criteria) this; - } - - public Criteria andJmeterClazzIn(List values) { - addCriterion("jmeter_clazz in", values, "jmeterClazz"); - return (Criteria) this; - } - - public Criteria andJmeterClazzNotIn(List values) { - addCriterion("jmeter_clazz not in", values, "jmeterClazz"); - return (Criteria) this; - } - - public Criteria andJmeterClazzBetween(String value1, String value2) { - addCriterion("jmeter_clazz between", value1, value2, "jmeterClazz"); - return (Criteria) this; - } - - public Criteria andJmeterClazzNotBetween(String value1, String value2) { - addCriterion("jmeter_clazz not between", value1, value2, "jmeterClazz"); - return (Criteria) this; - } - - public Criteria andSourcePathIsNull() { - addCriterion("source_path is null"); - return (Criteria) this; - } - - public Criteria andSourcePathIsNotNull() { - addCriterion("source_path is not null"); - return (Criteria) this; - } - - public Criteria andSourcePathEqualTo(String value) { - addCriterion("source_path =", value, "sourcePath"); - return (Criteria) this; - } - - public Criteria andSourcePathNotEqualTo(String value) { - addCriterion("source_path <>", value, "sourcePath"); - return (Criteria) this; - } - - public Criteria andSourcePathGreaterThan(String value) { - addCriterion("source_path >", value, "sourcePath"); - return (Criteria) this; - } - - public Criteria andSourcePathGreaterThanOrEqualTo(String value) { - addCriterion("source_path >=", value, "sourcePath"); - return (Criteria) this; - } - - public Criteria andSourcePathLessThan(String value) { - addCriterion("source_path <", value, "sourcePath"); - return (Criteria) this; - } - - public Criteria andSourcePathLessThanOrEqualTo(String value) { - addCriterion("source_path <=", value, "sourcePath"); - return (Criteria) this; - } - - public Criteria andSourcePathLike(String value) { - addCriterion("source_path like", value, "sourcePath"); - return (Criteria) this; - } - - public Criteria andSourcePathNotLike(String value) { - addCriterion("source_path not like", value, "sourcePath"); - return (Criteria) this; - } - - public Criteria andSourcePathIn(List values) { - addCriterion("source_path in", values, "sourcePath"); - return (Criteria) this; - } - - public Criteria andSourcePathNotIn(List values) { - addCriterion("source_path not in", values, "sourcePath"); - return (Criteria) this; - } - - public Criteria andSourcePathBetween(String value1, String value2) { - addCriterion("source_path between", value1, value2, "sourcePath"); - return (Criteria) this; - } - - public Criteria andSourcePathNotBetween(String value1, String value2) { - addCriterion("source_path not between", value1, value2, "sourcePath"); - return (Criteria) this; - } - - public Criteria andSourceNameIsNull() { - addCriterion("source_name is null"); - return (Criteria) this; - } - - public Criteria andSourceNameIsNotNull() { - addCriterion("source_name is not null"); - return (Criteria) this; - } - - public Criteria andSourceNameEqualTo(String value) { - addCriterion("source_name =", value, "sourceName"); - return (Criteria) this; - } - - public Criteria andSourceNameNotEqualTo(String value) { - addCriterion("source_name <>", value, "sourceName"); - return (Criteria) this; - } - - public Criteria andSourceNameGreaterThan(String value) { - addCriterion("source_name >", value, "sourceName"); - return (Criteria) this; - } - - public Criteria andSourceNameGreaterThanOrEqualTo(String value) { - addCriterion("source_name >=", value, "sourceName"); - return (Criteria) this; - } - - public Criteria andSourceNameLessThan(String value) { - addCriterion("source_name <", value, "sourceName"); - return (Criteria) this; - } - - public Criteria andSourceNameLessThanOrEqualTo(String value) { - addCriterion("source_name <=", value, "sourceName"); - return (Criteria) this; - } - - public Criteria andSourceNameLike(String value) { - addCriterion("source_name like", value, "sourceName"); - return (Criteria) this; - } - - public Criteria andSourceNameNotLike(String value) { - addCriterion("source_name not like", value, "sourceName"); - return (Criteria) this; - } - - public Criteria andSourceNameIn(List values) { - addCriterion("source_name in", values, "sourceName"); - return (Criteria) this; - } - - public Criteria andSourceNameNotIn(List values) { - addCriterion("source_name not in", values, "sourceName"); - return (Criteria) this; - } - - public Criteria andSourceNameBetween(String value1, String value2) { - addCriterion("source_name between", value1, value2, "sourceName"); - return (Criteria) this; - } - - public Criteria andSourceNameNotBetween(String value1, String value2) { - addCriterion("source_name not between", value1, value2, "sourceName"); - return (Criteria) this; - } - - public Criteria andExecEntryIsNull() { - addCriterion("exec_entry is null"); - return (Criteria) this; - } - - public Criteria andExecEntryIsNotNull() { - addCriterion("exec_entry is not null"); - return (Criteria) this; - } - - public Criteria andExecEntryEqualTo(String value) { - addCriterion("exec_entry =", value, "execEntry"); - return (Criteria) this; - } - - public Criteria andExecEntryNotEqualTo(String value) { - addCriterion("exec_entry <>", value, "execEntry"); - return (Criteria) this; - } - - public Criteria andExecEntryGreaterThan(String value) { - addCriterion("exec_entry >", value, "execEntry"); - return (Criteria) this; - } - - public Criteria andExecEntryGreaterThanOrEqualTo(String value) { - addCriterion("exec_entry >=", value, "execEntry"); - return (Criteria) this; - } - - public Criteria andExecEntryLessThan(String value) { - addCriterion("exec_entry <", value, "execEntry"); - return (Criteria) this; - } - - public Criteria andExecEntryLessThanOrEqualTo(String value) { - addCriterion("exec_entry <=", value, "execEntry"); - return (Criteria) this; - } - - public Criteria andExecEntryLike(String value) { - addCriterion("exec_entry like", value, "execEntry"); - return (Criteria) this; - } - - public Criteria andExecEntryNotLike(String value) { - addCriterion("exec_entry not like", value, "execEntry"); - return (Criteria) this; - } - - public Criteria andExecEntryIn(List values) { - addCriterion("exec_entry in", values, "execEntry"); - return (Criteria) this; - } - - public Criteria andExecEntryNotIn(List values) { - addCriterion("exec_entry not in", values, "execEntry"); - return (Criteria) this; - } - - public Criteria andExecEntryBetween(String value1, String value2) { - addCriterion("exec_entry between", value1, value2, "execEntry"); - return (Criteria) this; - } - - public Criteria andExecEntryNotBetween(String value1, String value2) { - addCriterion("exec_entry not between", value1, value2, "execEntry"); + public Criteria andFileNameNotBetween(String value1, String value2) { + addCriterion("file_name not between", value1, value2, "fileName"); return (Criteria) this; } @@ -924,6 +574,126 @@ public class PluginExample { return (Criteria) this; } + public Criteria andEnableIsNull() { + addCriterion("`enable` is null"); + return (Criteria) this; + } + + public Criteria andEnableIsNotNull() { + addCriterion("`enable` is not null"); + return (Criteria) this; + } + + public Criteria andEnableEqualTo(Boolean value) { + addCriterion("`enable` =", value, "enable"); + return (Criteria) this; + } + + public Criteria andEnableNotEqualTo(Boolean value) { + addCriterion("`enable` <>", value, "enable"); + return (Criteria) this; + } + + public Criteria andEnableGreaterThan(Boolean value) { + addCriterion("`enable` >", value, "enable"); + return (Criteria) this; + } + + public Criteria andEnableGreaterThanOrEqualTo(Boolean value) { + addCriterion("`enable` >=", value, "enable"); + return (Criteria) this; + } + + public Criteria andEnableLessThan(Boolean value) { + addCriterion("`enable` <", value, "enable"); + return (Criteria) this; + } + + public Criteria andEnableLessThanOrEqualTo(Boolean value) { + addCriterion("`enable` <=", value, "enable"); + return (Criteria) this; + } + + public Criteria andEnableIn(List values) { + addCriterion("`enable` in", values, "enable"); + return (Criteria) this; + } + + public Criteria andEnableNotIn(List values) { + addCriterion("`enable` not in", values, "enable"); + return (Criteria) this; + } + + public Criteria andEnableBetween(Boolean value1, Boolean value2) { + addCriterion("`enable` between", value1, value2, "enable"); + return (Criteria) this; + } + + public Criteria andEnableNotBetween(Boolean value1, Boolean value2) { + addCriterion("`enable` not between", value1, value2, "enable"); + return (Criteria) this; + } + + public Criteria andGlobalIsNull() { + addCriterion("`global` is null"); + return (Criteria) this; + } + + public Criteria andGlobalIsNotNull() { + addCriterion("`global` is not null"); + return (Criteria) this; + } + + public Criteria andGlobalEqualTo(Boolean value) { + addCriterion("`global` =", value, "global"); + return (Criteria) this; + } + + public Criteria andGlobalNotEqualTo(Boolean value) { + addCriterion("`global` <>", value, "global"); + return (Criteria) this; + } + + public Criteria andGlobalGreaterThan(Boolean value) { + addCriterion("`global` >", value, "global"); + return (Criteria) this; + } + + public Criteria andGlobalGreaterThanOrEqualTo(Boolean value) { + addCriterion("`global` >=", value, "global"); + return (Criteria) this; + } + + public Criteria andGlobalLessThan(Boolean value) { + addCriterion("`global` <", value, "global"); + return (Criteria) this; + } + + public Criteria andGlobalLessThanOrEqualTo(Boolean value) { + addCriterion("`global` <=", value, "global"); + return (Criteria) this; + } + + public Criteria andGlobalIn(List values) { + addCriterion("`global` in", values, "global"); + return (Criteria) this; + } + + public Criteria andGlobalNotIn(List values) { + addCriterion("`global` not in", values, "global"); + return (Criteria) this; + } + + public Criteria andGlobalBetween(Boolean value1, Boolean value2) { + addCriterion("`global` between", value1, value2, "global"); + return (Criteria) this; + } + + public Criteria andGlobalNotBetween(Boolean value1, Boolean value2) { + addCriterion("`global` not between", value1, value2, "global"); + return (Criteria) this; + } + public Criteria andXpackIsNull() { addCriterion("xpack is null"); return (Criteria) this; @@ -984,6 +754,76 @@ public class PluginExample { return (Criteria) this; } + public Criteria andDescriptionIsNull() { + addCriterion("description is null"); + return (Criteria) this; + } + + public Criteria andDescriptionIsNotNull() { + addCriterion("description is not null"); + return (Criteria) this; + } + + public Criteria andDescriptionEqualTo(String value) { + addCriterion("description =", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotEqualTo(String value) { + addCriterion("description <>", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionGreaterThan(String value) { + addCriterion("description >", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionGreaterThanOrEqualTo(String value) { + addCriterion("description >=", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLessThan(String value) { + addCriterion("description <", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLessThanOrEqualTo(String value) { + addCriterion("description <=", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionLike(String value) { + addCriterion("description like", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotLike(String value) { + addCriterion("description not like", value, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionIn(List values) { + addCriterion("description in", values, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotIn(List values) { + addCriterion("description not in", values, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionBetween(String value1, String value2) { + addCriterion("description between", value1, value2, "description"); + return (Criteria) this; + } + + public Criteria andDescriptionNotBetween(String value1, String value2) { + addCriterion("description not between", value1, value2, "description"); + return (Criteria) this; + } + public Criteria andScenarioIsNull() { addCriterion("scenario is null"); return (Criteria) this; diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginFrontScript.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginFrontScript.java new file mode 100644 index 0000000000..2c5bff357d --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginFrontScript.java @@ -0,0 +1,25 @@ +package io.metersphere.system.domain; + +import io.metersphere.validation.groups.*; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.*; +import java.io.Serializable; +import lombok.Data; + +@Data +public class PluginFrontScript implements Serializable { + @Schema(title = "插件的ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{plugin_front_script.plugin_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{plugin_front_script.plugin_id.length_range}", groups = {Created.class, Updated.class}) + private String pluginId; + + @Schema(title = "插件中对应表单配置的ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{plugin_front_script.script_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{plugin_front_script.script_id.length_range}", groups = {Created.class, Updated.class}) + private String scriptId; + + @Schema(title = "脚本内容") + private String script; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginBlobExample.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginFrontScriptExample.java similarity index 57% rename from backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginBlobExample.java rename to backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginFrontScriptExample.java index ff37f01f75..3ab4ebfa04 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginBlobExample.java +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginFrontScriptExample.java @@ -3,14 +3,14 @@ package io.metersphere.system.domain; import java.util.ArrayList; import java.util.List; -public class PluginBlobExample { +public class PluginFrontScriptExample { protected String orderByClause; protected boolean distinct; protected List oredCriteria; - public PluginBlobExample() { + public PluginFrontScriptExample() { oredCriteria = new ArrayList(); } @@ -104,73 +104,143 @@ public class PluginBlobExample { criteria.add(new Criterion(condition, value1, value2)); } - public Criteria andIdIsNull() { - addCriterion("id is null"); + public Criteria andPluginIdIsNull() { + addCriterion("plugin_id is null"); return (Criteria) this; } - public Criteria andIdIsNotNull() { - addCriterion("id is not null"); + public Criteria andPluginIdIsNotNull() { + addCriterion("plugin_id is not null"); return (Criteria) this; } - public Criteria andIdEqualTo(String value) { - addCriterion("id =", value, "id"); + public Criteria andPluginIdEqualTo(String value) { + addCriterion("plugin_id =", value, "pluginId"); return (Criteria) this; } - public Criteria andIdNotEqualTo(String value) { - addCriterion("id <>", value, "id"); + public Criteria andPluginIdNotEqualTo(String value) { + addCriterion("plugin_id <>", value, "pluginId"); return (Criteria) this; } - public Criteria andIdGreaterThan(String value) { - addCriterion("id >", value, "id"); + public Criteria andPluginIdGreaterThan(String value) { + addCriterion("plugin_id >", value, "pluginId"); return (Criteria) this; } - public Criteria andIdGreaterThanOrEqualTo(String value) { - addCriterion("id >=", value, "id"); + public Criteria andPluginIdGreaterThanOrEqualTo(String value) { + addCriterion("plugin_id >=", value, "pluginId"); return (Criteria) this; } - public Criteria andIdLessThan(String value) { - addCriterion("id <", value, "id"); + public Criteria andPluginIdLessThan(String value) { + addCriterion("plugin_id <", value, "pluginId"); return (Criteria) this; } - public Criteria andIdLessThanOrEqualTo(String value) { - addCriterion("id <=", value, "id"); + public Criteria andPluginIdLessThanOrEqualTo(String value) { + addCriterion("plugin_id <=", value, "pluginId"); return (Criteria) this; } - public Criteria andIdLike(String value) { - addCriterion("id like", value, "id"); + public Criteria andPluginIdLike(String value) { + addCriterion("plugin_id like", value, "pluginId"); return (Criteria) this; } - public Criteria andIdNotLike(String value) { - addCriterion("id not like", value, "id"); + public Criteria andPluginIdNotLike(String value) { + addCriterion("plugin_id not like", value, "pluginId"); return (Criteria) this; } - public Criteria andIdIn(List values) { - addCriterion("id in", values, "id"); + public Criteria andPluginIdIn(List values) { + addCriterion("plugin_id in", values, "pluginId"); return (Criteria) this; } - public Criteria andIdNotIn(List values) { - addCriterion("id not in", values, "id"); + public Criteria andPluginIdNotIn(List values) { + addCriterion("plugin_id not in", values, "pluginId"); return (Criteria) this; } - public Criteria andIdBetween(String value1, String value2) { - addCriterion("id between", value1, value2, "id"); + public Criteria andPluginIdBetween(String value1, String value2) { + addCriterion("plugin_id between", value1, value2, "pluginId"); return (Criteria) this; } - public Criteria andIdNotBetween(String value1, String value2) { - addCriterion("id not between", value1, value2, "id"); + public Criteria andPluginIdNotBetween(String value1, String value2) { + addCriterion("plugin_id not between", value1, value2, "pluginId"); + return (Criteria) this; + } + + public Criteria andScriptIdIsNull() { + addCriterion("script_id is null"); + return (Criteria) this; + } + + public Criteria andScriptIdIsNotNull() { + addCriterion("script_id is not null"); + return (Criteria) this; + } + + public Criteria andScriptIdEqualTo(String value) { + addCriterion("script_id =", value, "scriptId"); + return (Criteria) this; + } + + public Criteria andScriptIdNotEqualTo(String value) { + addCriterion("script_id <>", value, "scriptId"); + return (Criteria) this; + } + + public Criteria andScriptIdGreaterThan(String value) { + addCriterion("script_id >", value, "scriptId"); + return (Criteria) this; + } + + public Criteria andScriptIdGreaterThanOrEqualTo(String value) { + addCriterion("script_id >=", value, "scriptId"); + return (Criteria) this; + } + + public Criteria andScriptIdLessThan(String value) { + addCriterion("script_id <", value, "scriptId"); + return (Criteria) this; + } + + public Criteria andScriptIdLessThanOrEqualTo(String value) { + addCriterion("script_id <=", value, "scriptId"); + return (Criteria) this; + } + + public Criteria andScriptIdLike(String value) { + addCriterion("script_id like", value, "scriptId"); + return (Criteria) this; + } + + public Criteria andScriptIdNotLike(String value) { + addCriterion("script_id not like", value, "scriptId"); + return (Criteria) this; + } + + public Criteria andScriptIdIn(List values) { + addCriterion("script_id in", values, "scriptId"); + return (Criteria) this; + } + + public Criteria andScriptIdNotIn(List values) { + addCriterion("script_id not in", values, "scriptId"); + return (Criteria) this; + } + + public Criteria andScriptIdBetween(String value1, String value2) { + addCriterion("script_id between", value1, value2, "scriptId"); + return (Criteria) this; + } + + public Criteria andScriptIdNotBetween(String value1, String value2) { + addCriterion("script_id not between", value1, value2, "scriptId"); return (Criteria) this; } } diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginOrganization.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginOrganization.java new file mode 100644 index 0000000000..f6547d91ea --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginOrganization.java @@ -0,0 +1,22 @@ +package io.metersphere.system.domain; + +import io.metersphere.validation.groups.*; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.*; +import java.io.Serializable; +import lombok.Data; + +@Data +public class PluginOrganization implements Serializable { + @Schema(title = "插件ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{plugin_organization.plugin_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{plugin_organization.plugin_id.length_range}", groups = {Created.class, Updated.class}) + private String pluginId; + + @Schema(title = "组织ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{plugin_organization.organization_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{plugin_organization.organization_id.length_range}", groups = {Created.class, Updated.class}) + private String organizationId; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginOrganizationExample.java b/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginOrganizationExample.java new file mode 100644 index 0000000000..eb66b32c5f --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/domain/PluginOrganizationExample.java @@ -0,0 +1,340 @@ +package io.metersphere.system.domain; + +import java.util.ArrayList; +import java.util.List; + +public class PluginOrganizationExample { + protected String orderByClause; + + protected boolean distinct; + + protected List oredCriteria; + + public PluginOrganizationExample() { + oredCriteria = new ArrayList(); + } + + public void setOrderByClause(String orderByClause) { + this.orderByClause = orderByClause; + } + + public String getOrderByClause() { + return orderByClause; + } + + public void setDistinct(boolean distinct) { + this.distinct = distinct; + } + + public boolean isDistinct() { + return distinct; + } + + public List getOredCriteria() { + return oredCriteria; + } + + public void or(Criteria criteria) { + oredCriteria.add(criteria); + } + + public Criteria or() { + Criteria criteria = createCriteriaInternal(); + oredCriteria.add(criteria); + return criteria; + } + + public Criteria createCriteria() { + Criteria criteria = createCriteriaInternal(); + if (oredCriteria.size() == 0) { + oredCriteria.add(criteria); + } + return criteria; + } + + protected Criteria createCriteriaInternal() { + Criteria criteria = new Criteria(); + return criteria; + } + + public void clear() { + oredCriteria.clear(); + orderByClause = null; + distinct = false; + } + + protected abstract static class GeneratedCriteria { + protected List criteria; + + protected GeneratedCriteria() { + super(); + criteria = new ArrayList(); + } + + public boolean isValid() { + return criteria.size() > 0; + } + + public List getAllCriteria() { + return criteria; + } + + public List getCriteria() { + return criteria; + } + + protected void addCriterion(String condition) { + if (condition == null) { + throw new RuntimeException("Value for condition cannot be null"); + } + criteria.add(new Criterion(condition)); + } + + protected void addCriterion(String condition, Object value, String property) { + if (value == null) { + throw new RuntimeException("Value for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value)); + } + + protected void addCriterion(String condition, Object value1, Object value2, String property) { + if (value1 == null || value2 == null) { + throw new RuntimeException("Between values for " + property + " cannot be null"); + } + criteria.add(new Criterion(condition, value1, value2)); + } + + public Criteria andPluginIdIsNull() { + addCriterion("plugin_id is null"); + return (Criteria) this; + } + + public Criteria andPluginIdIsNotNull() { + addCriterion("plugin_id is not null"); + return (Criteria) this; + } + + public Criteria andPluginIdEqualTo(String value) { + addCriterion("plugin_id =", value, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdNotEqualTo(String value) { + addCriterion("plugin_id <>", value, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdGreaterThan(String value) { + addCriterion("plugin_id >", value, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdGreaterThanOrEqualTo(String value) { + addCriterion("plugin_id >=", value, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdLessThan(String value) { + addCriterion("plugin_id <", value, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdLessThanOrEqualTo(String value) { + addCriterion("plugin_id <=", value, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdLike(String value) { + addCriterion("plugin_id like", value, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdNotLike(String value) { + addCriterion("plugin_id not like", value, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdIn(List values) { + addCriterion("plugin_id in", values, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdNotIn(List values) { + addCriterion("plugin_id not in", values, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdBetween(String value1, String value2) { + addCriterion("plugin_id between", value1, value2, "pluginId"); + return (Criteria) this; + } + + public Criteria andPluginIdNotBetween(String value1, String value2) { + addCriterion("plugin_id not between", value1, value2, "pluginId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdIsNull() { + addCriterion("organization_id is null"); + return (Criteria) this; + } + + public Criteria andOrganizationIdIsNotNull() { + addCriterion("organization_id is not null"); + return (Criteria) this; + } + + public Criteria andOrganizationIdEqualTo(String value) { + addCriterion("organization_id =", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdNotEqualTo(String value) { + addCriterion("organization_id <>", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdGreaterThan(String value) { + addCriterion("organization_id >", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdGreaterThanOrEqualTo(String value) { + addCriterion("organization_id >=", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdLessThan(String value) { + addCriterion("organization_id <", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdLessThanOrEqualTo(String value) { + addCriterion("organization_id <=", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdLike(String value) { + addCriterion("organization_id like", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdNotLike(String value) { + addCriterion("organization_id not like", value, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdIn(List values) { + addCriterion("organization_id in", values, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdNotIn(List values) { + addCriterion("organization_id not in", values, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdBetween(String value1, String value2) { + addCriterion("organization_id between", value1, value2, "organizationId"); + return (Criteria) this; + } + + public Criteria andOrganizationIdNotBetween(String value1, String value2) { + addCriterion("organization_id not between", value1, value2, "organizationId"); + return (Criteria) this; + } + } + + public static class Criteria extends GeneratedCriteria { + + protected Criteria() { + super(); + } + } + + public static class Criterion { + private String condition; + + private Object value; + + private Object secondValue; + + private boolean noValue; + + private boolean singleValue; + + private boolean betweenValue; + + private boolean listValue; + + private String typeHandler; + + public String getCondition() { + return condition; + } + + public Object getValue() { + return value; + } + + public Object getSecondValue() { + return secondValue; + } + + public boolean isNoValue() { + return noValue; + } + + public boolean isSingleValue() { + return singleValue; + } + + public boolean isBetweenValue() { + return betweenValue; + } + + public boolean isListValue() { + return listValue; + } + + public String getTypeHandler() { + return typeHandler; + } + + protected Criterion(String condition) { + super(); + this.condition = condition; + this.typeHandler = null; + this.noValue = true; + } + + protected Criterion(String condition, Object value, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.typeHandler = typeHandler; + if (value instanceof List) { + this.listValue = true; + } else { + this.singleValue = true; + } + } + + protected Criterion(String condition, Object value) { + this(condition, value, null); + } + + protected Criterion(String condition, Object value, Object secondValue, String typeHandler) { + super(); + this.condition = condition; + this.value = value; + this.secondValue = secondValue; + this.typeHandler = typeHandler; + this.betweenValue = true; + } + + protected Criterion(String condition, Object value, Object secondValue) { + this(condition, value, secondValue, null); + } + } +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginBlobMapper.java b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginBlobMapper.java deleted file mode 100644 index 48996273b1..0000000000 --- a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginBlobMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -package io.metersphere.system.mapper; - -import io.metersphere.system.domain.PluginBlob; -import io.metersphere.system.domain.PluginBlobExample; -import java.util.List; -import org.apache.ibatis.annotations.Param; - -public interface PluginBlobMapper { - long countByExample(PluginBlobExample example); - - int deleteByExample(PluginBlobExample example); - - int deleteByPrimaryKey(String id); - - int insert(PluginBlob record); - - int insertSelective(PluginBlob record); - - List selectByExampleWithBLOBs(PluginBlobExample example); - - List selectByExample(PluginBlobExample example); - - PluginBlob selectByPrimaryKey(String id); - - int updateByExampleSelective(@Param("record") PluginBlob record, @Param("example") PluginBlobExample example); - - int updateByExampleWithBLOBs(@Param("record") PluginBlob record, @Param("example") PluginBlobExample example); - - int updateByExample(@Param("record") PluginBlob record, @Param("example") PluginBlobExample example); - - int updateByPrimaryKeySelective(PluginBlob record); - - int updateByPrimaryKeyWithBLOBs(PluginBlob record); -} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginFrontScriptMapper.java b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginFrontScriptMapper.java new file mode 100644 index 0000000000..0be7dee207 --- /dev/null +++ b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginFrontScriptMapper.java @@ -0,0 +1,34 @@ +package io.metersphere.system.mapper; + +import io.metersphere.system.domain.PluginFrontScript; +import io.metersphere.system.domain.PluginFrontScriptExample; +import java.util.List; +import org.apache.ibatis.annotations.Param; + +public interface PluginFrontScriptMapper { + long countByExample(PluginFrontScriptExample example); + + int deleteByExample(PluginFrontScriptExample example); + + int deleteByPrimaryKey(@Param("pluginId") String pluginId, @Param("scriptId") String scriptId); + + int insert(PluginFrontScript record); + + int insertSelective(PluginFrontScript record); + + List selectByExampleWithBLOBs(PluginFrontScriptExample example); + + List selectByExample(PluginFrontScriptExample example); + + PluginFrontScript selectByPrimaryKey(@Param("pluginId") String pluginId, @Param("scriptId") String scriptId); + + int updateByExampleSelective(@Param("record") PluginFrontScript record, @Param("example") PluginFrontScriptExample example); + + int updateByExampleWithBLOBs(@Param("record") PluginFrontScript record, @Param("example") PluginFrontScriptExample example); + + int updateByExample(@Param("record") PluginFrontScript record, @Param("example") PluginFrontScriptExample example); + + int updateByPrimaryKeySelective(PluginFrontScript record); + + int updateByPrimaryKeyWithBLOBs(PluginFrontScript record); +} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginBlobMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginFrontScriptMapper.xml similarity index 62% rename from backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginBlobMapper.xml rename to backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginFrontScriptMapper.xml index 92c35236b6..035d292550 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginBlobMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginFrontScriptMapper.xml @@ -1,12 +1,12 @@ - - - + + + + - - - + + @@ -67,12 +67,12 @@ - id + plugin_id, script_id - form_option, form_script + script - select distinct @@ -80,7 +80,7 @@ , - from plugin_blob + from plugin_front_script @@ -88,13 +88,13 @@ order by ${orderByClause} - select distinct - from plugin_blob + from plugin_front_script @@ -102,72 +102,74 @@ order by ${orderByClause} - select , - from plugin_blob - where id = #{id,jdbcType=VARCHAR} + from plugin_front_script + where plugin_id = #{pluginId,jdbcType=VARCHAR} + and script_id = #{scriptId,jdbcType=VARCHAR} - - delete from plugin_blob - where id = #{id,jdbcType=VARCHAR} + + delete from plugin_front_script + where plugin_id = #{pluginId,jdbcType=VARCHAR} + and script_id = #{scriptId,jdbcType=VARCHAR} - - delete from plugin_blob + + delete from plugin_front_script - - insert into plugin_blob (id, form_option, form_script + + insert into plugin_front_script (plugin_id, script_id, script ) - values (#{id,jdbcType=VARCHAR}, #{formOption,jdbcType=LONGVARBINARY}, #{formScript,jdbcType=LONGVARBINARY} + values (#{pluginId,jdbcType=VARCHAR}, #{scriptId,jdbcType=VARCHAR}, #{script,jdbcType=LONGVARCHAR} ) - - insert into plugin_blob + + insert into plugin_front_script - - id, + + plugin_id, - - form_option, + + script_id, - - form_script, + + script, - - #{id,jdbcType=VARCHAR}, + + #{pluginId,jdbcType=VARCHAR}, - - #{formOption,jdbcType=LONGVARBINARY}, + + #{scriptId,jdbcType=VARCHAR}, - - #{formScript,jdbcType=LONGVARBINARY}, + + #{script,jdbcType=LONGVARCHAR}, - + select count(*) from plugin_front_script - update plugin_blob + update plugin_front_script - - id = #{record.id,jdbcType=VARCHAR}, + + plugin_id = #{record.pluginId,jdbcType=VARCHAR}, - - form_option = #{record.formOption,jdbcType=LONGVARBINARY}, + + script_id = #{record.scriptId,jdbcType=VARCHAR}, - - form_script = #{record.formScript,jdbcType=LONGVARBINARY}, + + script = #{record.script,jdbcType=LONGVARCHAR}, @@ -175,37 +177,36 @@ - update plugin_blob - set id = #{record.id,jdbcType=VARCHAR}, - form_option = #{record.formOption,jdbcType=LONGVARBINARY}, - form_script = #{record.formScript,jdbcType=LONGVARBINARY} + update plugin_front_script + set plugin_id = #{record.pluginId,jdbcType=VARCHAR}, + script_id = #{record.scriptId,jdbcType=VARCHAR}, + script = #{record.script,jdbcType=LONGVARCHAR} - update plugin_blob - set id = #{record.id,jdbcType=VARCHAR} + update plugin_front_script + set plugin_id = #{record.pluginId,jdbcType=VARCHAR}, + script_id = #{record.scriptId,jdbcType=VARCHAR} - - update plugin_blob + + update plugin_front_script - - form_option = #{formOption,jdbcType=LONGVARBINARY}, - - - form_script = #{formScript,jdbcType=LONGVARBINARY}, + + script = #{script,jdbcType=LONGVARCHAR}, - where id = #{id,jdbcType=VARCHAR} + where plugin_id = #{pluginId,jdbcType=VARCHAR} + and script_id = #{scriptId,jdbcType=VARCHAR} - - update plugin_blob - set form_option = #{formOption,jdbcType=LONGVARBINARY}, - form_script = #{formScript,jdbcType=LONGVARBINARY} - where id = #{id,jdbcType=VARCHAR} + + update plugin_front_script + set script = #{script,jdbcType=LONGVARCHAR} + where plugin_id = #{pluginId,jdbcType=VARCHAR} + and script_id = #{scriptId,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginMapper.xml b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginMapper.xml index 5920ab45d0..5dd3ee50f0 100644 --- a/backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginMapper.xml +++ b/backend/framework/domain/src/main/java/io/metersphere/system/mapper/PluginMapper.xml @@ -5,16 +5,14 @@ - - - - - - + + + + @@ -76,8 +74,8 @@ - id, `name`, plugin_id, script_id, clazz_name, jmeter_clazz, source_path, source_name, - exec_entry, create_time, update_time, create_user, xpack, scenario + id, `name`, plugin_id, file_name, create_time, update_time, create_user, `enable`, + `global`, xpack, description, scenario + select + + distinct + + + from plugin_organization + + + + + order by ${orderByClause} + + + + delete from plugin_organization + where plugin_id = #{pluginId,jdbcType=VARCHAR} + and organization_id = #{organizationId,jdbcType=VARCHAR} + + + delete from plugin_organization + + + + + + insert into plugin_organization (plugin_id, organization_id) + values (#{pluginId,jdbcType=VARCHAR}, #{organizationId,jdbcType=VARCHAR}) + + + insert into plugin_organization + + + plugin_id, + + + organization_id, + + + + + #{pluginId,jdbcType=VARCHAR}, + + + #{organizationId,jdbcType=VARCHAR}, + + + + + + update plugin_organization + + + plugin_id = #{record.pluginId,jdbcType=VARCHAR}, + + + organization_id = #{record.organizationId,jdbcType=VARCHAR}, + + + + + + + + update plugin_organization + set plugin_id = #{record.pluginId,jdbcType=VARCHAR}, + organization_id = #{record.organizationId,jdbcType=VARCHAR} + + + + + \ No newline at end of file diff --git a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_11__system_setting.sql b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_11__system_setting.sql index bd4fbffaa6..84a351f3cf 100644 --- a/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_11__system_setting.sql +++ b/backend/framework/domain/src/main/resources/migration/3.0.0/ddl/V3.0.0_11__system_setting.sql @@ -141,24 +141,41 @@ CREATE INDEX idx_type ON operation_log(`type`); CREATE TABLE IF NOT EXISTS plugin ( - `id` VARCHAR(50) NOT NULL COMMENT 'ID', - `name` VARCHAR(255) COMMENT 'plugin name', - `plugin_id` VARCHAR(300) NOT NULL COMMENT 'Plugin id', - `script_id` VARCHAR(300) NOT NULL COMMENT 'Ui script id', - `clazz_name` VARCHAR(500) NOT NULL COMMENT 'Plugin clazzName', - `jmeter_clazz` VARCHAR(300) NOT NULL COMMENT 'Jmeter base clazzName', - `source_path` VARCHAR(300) NOT NULL COMMENT 'Plugin jar path', - `source_name` VARCHAR(300) NOT NULL COMMENT 'Plugin jar name', - `exec_entry` VARCHAR(300) COMMENT 'plugin init entry class', - `create_time` BIGINT COMMENT '', - `update_time` BIGINT COMMENT '', - `create_user` VARCHAR(50) COMMENT '', - `xpack` BIT COMMENT 'Is xpack plugin', - `scenario` VARCHAR(50) NOT NULL COMMENT 'Plugin usage scenarios', + `id` VARCHAR(50) NOT NULL COMMENT 'ID' , + `name` VARCHAR(255) NOT NULL COMMENT '插件名称' , + `plugin_id` VARCHAR(300) NOT NULL COMMENT '插件ID(名称加版本号)' , + `file_name` VARCHAR(300) NOT NULL COMMENT '文件名' , + `create_time` BIGINT NOT NULL COMMENT '创建时间' , + `update_time` BIGINT NOT NULL COMMENT '更新时间' , + `create_user` VARCHAR(50) NOT NULL COMMENT '创建人' , + `enable` BIT NOT NULL DEFAULT 1 COMMENT '是否启用插件' , + `global` BIT NOT NULL DEFAULT 1 COMMENT '是否是全局插件' , + `xpack` BIT NOT NULL DEFAULT 0 COMMENT '是否是企业版插件' , + `description` VARCHAR(500) COMMENT '插件描述' , + `scenario` VARCHAR(50) NOT NULL COMMENT '插件使用场景PAI/PLATFORM' , PRIMARY KEY (id) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci COMMENT = '插件'; + +CREATE TABLE IF NOT EXISTS plugin_front_script +( + `plugin_id` VARCHAR(50) NOT NULL COMMENT '插件的ID' , + `script_id` VARCHAR(50) NOT NULL COMMENT '插件中对应表单配置的ID' , + `script` TEXT COMMENT '脚本内容' , + PRIMARY KEY (plugin_id,script_id) ) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci COMMENT = '插件'; + COLLATE = utf8mb4_general_ci COMMENT = '插件的前端配置脚本'; + +CREATE TABLE IF NOT EXISTS plugin_organization +( + `plugin_id` VARCHAR(50) NOT NULL COMMENT '插件ID' , + `organization_id` VARCHAR(50) NOT NULL COMMENT '组织ID' , + PRIMARY KEY (plugin_id,organization_id) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE = utf8mb4_general_ci COMMENT = '插件和组织的关联表'; CREATE TABLE IF NOT EXISTS quota ( @@ -411,17 +428,6 @@ CREATE TABLE IF NOT EXISTS message_task_blob DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '消息通知任务大字段'; -CREATE TABLE IF NOT EXISTS plugin_blob -( - `id` VARCHAR(50) NOT NULL COMMENT 'ID', - `form_option` LONGBLOB COMMENT 'plugin form option', - `form_script` LONGBLOB COMMENT 'plugin form script', - PRIMARY KEY (id) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 - COLLATE = utf8mb4_general_ci COMMENT = '插件大字段'; - - DROP TABLE IF EXISTS test_resource_pool_organization; CREATE TABLE test_resource_pool_organization( `id` VARCHAR(50) NOT NULL COMMENT '测试资源池项目关系ID' , diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/config/interceptor/SystemInterceptor.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/config/interceptor/SystemInterceptor.java index bb274f98f3..f213aca5ea 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/config/interceptor/SystemInterceptor.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/config/interceptor/SystemInterceptor.java @@ -18,8 +18,6 @@ public class SystemInterceptor { configList.add(new MybatisInterceptorConfig(TestResourcePoolBlob.class, "configuration", CompressUtils.class, "zip", "unzip")); configList.add(new MybatisInterceptorConfig(AuthSource.class, "configuration", CompressUtils.class, "zip", "unzip")); configList.add(new MybatisInterceptorConfig(NoviceStatistics.class, "dataOption", CompressUtils.class, "zip", "unzip")); - configList.add(new MybatisInterceptorConfig(PluginBlob.class, "formOption", CompressUtils.class, "zip", "unzip")); - configList.add(new MybatisInterceptorConfig(PluginBlob.class, "formScript", CompressUtils.class, "zip", "unzip")); configList.add(new MybatisInterceptorConfig(ServiceIntegration.class, "configuration", CompressUtils.class, "zip", "unzip")); configList.add(new MybatisInterceptorConfig(UserExtend.class, "platformInfo", CompressUtils.class, "zip", "unzip")); diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PermissionConstants.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PermissionConstants.java index 98b984a42d..fe423a80e8 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PermissionConstants.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PermissionConstants.java @@ -34,6 +34,13 @@ public class PermissionConstants { public static final String ORGANIZATION_USER_ROLE_READ_DELETE = "ORGANIZATION_USER_ROLE:READ+DELETE"; /*------ end: ORGANIZATION_USER_ROLE ------*/ + /*------ start: SYSTEM_PLUGIN ------*/ + public static final String SYSTEM_PLUGIN_READ = "SYSTEM_PLUGIN_READ:READ"; + public static final String SYSTEM_PLUGIN_ADD = "SYSTEM_PLUGIN_READ:READ+ADD"; + public static final String SYSTEM_PLUGIN_UPDATE = "SYSTEM_PLUGIN_READ:READ+UPDATE"; + public static final String SYSTEM_PLUGIN_DELETE = "SYSTEM_PLUGIN_READ:READ+DELETE"; + /*------ end: SYSTEM_PLUGIN ------*/ + public static final String SYSTEM_USER_READ = "SYSTEM_USER:READ"; public static final String SYSTEM_USER_READ_ADD = "SYSTEM_USER:READ+ADD"; public static final String SYSTEM_USER_READ_IMPORT = "SYSTEM_USER:READ+IMPORT"; diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PluginScenarioType.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PluginScenarioType.java new file mode 100644 index 0000000000..5f5b96ec66 --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/constants/PluginScenarioType.java @@ -0,0 +1,5 @@ +package io.metersphere.sdk.constants; + +public enum PluginScenarioType { + PAI, PLATFORM +} diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/handler/ResultResponseBodyAdvice.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/handler/ResultResponseBodyAdvice.java index 60a825f1a9..42bf19a958 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/handler/ResultResponseBodyAdvice.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/controller/handler/ResultResponseBodyAdvice.java @@ -28,7 +28,8 @@ public class ResultResponseBodyAdvice implements ResponseBodyAdvice { public Object beforeBodyWrite(Object o, MethodParameter methodParameter, MediaType mediaType, Class> converterType, ServerHttpRequest serverHttpRequest, ServerHttpResponse serverHttpResponse) { // 处理空值 if (o == null && StringHttpMessageConverter.class.isAssignableFrom(converterType)) { - return null; + serverHttpResponse.getHeaders().setContentType(MediaType.APPLICATION_JSON); + return JSON.toJSONString(ResultHolder.success(o)); } if (methodParameter.hasMethodAnnotation(NoResultHolder.class)) { @@ -37,6 +38,7 @@ public class ResultResponseBodyAdvice implements ResponseBodyAdvice { if (!(o instanceof ResultHolder)) { if (o instanceof String) { + serverHttpResponse.getHeaders().setContentType(MediaType.APPLICATION_JSON); return JSON.toJSONString(ResultHolder.success(o)); } return ResultHolder.success(o); diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/OrganizationOptionDTO.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/OrganizationOptionDTO.java new file mode 100644 index 0000000000..f455173175 --- /dev/null +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/OrganizationOptionDTO.java @@ -0,0 +1,20 @@ +package io.metersphere.sdk.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; + +@Data +public class OrganizationOptionDTO implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(title = "组织ID") + private String id; + + @Schema(title = "组织编号") + private Long num; + + @Schema(title = "组织名称") + private String name; +} diff --git a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/request/UserRoleUpdateRequest.java b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/request/UserRoleUpdateRequest.java index 5bce9d9544..ed3fc9fd44 100644 --- a/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/request/UserRoleUpdateRequest.java +++ b/backend/framework/sdk/src/main/java/io/metersphere/sdk/dto/request/UserRoleUpdateRequest.java @@ -33,7 +33,7 @@ public class UserRoleUpdateRequest implements Serializable { @Schema(title = "所属类型 SYSTEM ORGANIZATION PROJECT", requiredMode = Schema.RequiredMode.REQUIRED) @NotBlank(message = "{user_role.type.not_blank}", groups = {Created.class}) - @EnumValue(enumClass = UserRoleType.class, groups = {Created.class}) + @EnumValue(enumClass = UserRoleType.class, groups = {Created.class, Updated.class}) @Size(min = 1, max = 20, message = "{user_role.type.length_range}", groups = {Created.class, Updated.class}) private String type; } diff --git a/backend/framework/sdk/src/main/resources/i18n/system_en_US.properties b/backend/framework/sdk/src/main/resources/i18n/system_en_US.properties index 630edaa1b5..edcb005820 100644 --- a/backend/framework/sdk/src/main/resources/i18n/system_en_US.properties +++ b/backend/framework/sdk/src/main/resources/i18n/system_en_US.properties @@ -54,21 +54,6 @@ operation_log_resource.operating_log_id.not_blank=Operating log resource operati operation_log_resource.operating_log_id.length_range=Operating log resource operating log id must be between {min} and {max} characters long operation_log_resource.source_id.not_blank=Operating log resource source id must not be blank operation_log_resource.source_id.length_range=Operating log resource source id must be between {min} and {max} characters long -plugin.id.not_blank=Plugin id must not be blank -plugin.plugin_id.not_blank=Plugin plugin id must not be blank -plugin.plugin_id.length_range=Plugin plugin id must be between {min} and {max} characters long -plugin.script_id.not_blank=Plugin script id must not be blank -plugin.script_id.length_range=Plugin script id must be between {min} and {max} characters long -plugin.clazz_name.not_blank=Plugin clazz name must not be blank -plugin.clazz_name.length_range=Plugin clazz name must be between {min} and {max} characters long -plugin.jmeter_clazz.not_blank=Plugin jmeter clazz must not be blank -plugin.jmeter_clazz.length_range=Plugin jmeter clazz must be between {min} and {max} characters long -plugin.source_path.not_blank=Plugin source path must not be blank -plugin.source_path.length_range=Plugin source path must be between {min} and {max} characters long -plugin.source_name.not_blank=Plugin source name must not be blank -plugin.source_name.length_range=Plugin source name must be between {min} and {max} characters long -plugin.scenario.not_blank=Plugin scenario must not be blank -plugin.scenario.length_range=Plugin scenario must be between {min} and {max} characters long plugin_blob.id.not_blank=Plugin blob plugin id must not be blank quota.id.not_blank=Quota id must not be blank schedule.id.not_blank=Schedule id must not be blank @@ -164,7 +149,24 @@ organization_user_role_permission_error=no organization user role permission user_role_exist=User role already exists user_role_not_exist=User role not exist user_role_not_edit=User role can not edit - +# plugin +plugin.id.not_blank=id cannot be empty +plugin.id.length_range=id length must be between {min} and {max} +plugin.name.not_blank=name cannot be empty +plugin.name.length_range=name length must be between {min} and {max} +plugin.plugin_id.not_blank=pluginId cannot be empty +plugin.plugin_id.length_range=pluginId length must be between {min} and {max} +plugin.file_name.not_blank=fileName cannot be empty +plugin.file_name.length_range=fileName length must be between {min} and {max} +plugin.create_user.not_blank=createUser cannot be empty +plugin.create_user.length_range=createUser length must be between {min} and {max} +plugin.scenario.not_blank=scenario cannot be empty +plugin.scenario.length_range=scenario length must be between {min} and {max} +permission.system_plugin.name=Plugin +permission.system_plugin.read=READ +permission.system_plugin.add=CREATE +permission.system_plugin.edit=UPDATE +permission.system_plugin.delete=DELETE diff --git a/backend/framework/sdk/src/main/resources/i18n/system_zh_CN.properties b/backend/framework/sdk/src/main/resources/i18n/system_zh_CN.properties index cae0f42fd5..62b68cfb2c 100644 --- a/backend/framework/sdk/src/main/resources/i18n/system_zh_CN.properties +++ b/backend/framework/sdk/src/main/resources/i18n/system_zh_CN.properties @@ -54,21 +54,6 @@ operation_log_resource.operating_log_id.not_blank=操作日志资源操作日志 operation_log_resource.operating_log_id.length_range=操作日志资源操作日志ID长度必须在{min}和{max}之间 operation_log_resource.source_id.not_blank=操作日志资源来源ID不能为空 operation_log_resource.source_id.length_range=操作日志资源来源ID长度必须在{min}和{max}之间 -plugin.id.not_blank=插件主键不能为空 -plugin.plugin_id.not_blank=插件ID不能为空 -plugin.plugin_id.length_range=插件ID长度必须在{min}和{max}之间 -plugin.script_id.not_blank=插件脚本ID不能为空 -plugin.script_id.length_range=插件脚本ID长度必须在{min}和{max}之间 -plugin.clazz_name.not_blank=插件类名不能为空 -plugin.clazz_name.length_range=插件类名长度必须在{min}和{max}之间 -plugin.jmeter_clazz.not_blank=插件jmeter类名不能为空 -plugin.jmeter_clazz.length_range=插件jmeter类名长度必须在{min}和{max}之间 -plugin.source_path.not_blank=插件源路径不能为空 -plugin.source_path.length_range=插件源路径长度必须在{min}和{max}之间 -plugin.source_name.not_blank=插件源名称不能为空 -plugin.source_name.length_range=插件源名称长度必须在{min}和{max}之间 -plugin.scenario.not_blank=插件场景不能为空 -plugin.scenario.length_range=插件场景长度必须在{min}和{max}之间 plugin_blob.id.not_blank=插件ID不能为空 quota.id.not_blank=配额ID不能为空 schedule.id.not_blank=定时任务ID不能为空 @@ -163,3 +148,21 @@ organization_user_role_permission_error=没有权限操作非组织用户组 user_role_exist=用户组已存在 user_role_not_exist=用户组不存在 user_role_not_edit=用户组无法编辑 +# plugin +plugin.id.not_blank=ID不能为空 +plugin.id.length_range=ID长度必须在{min}和{max}之间 +plugin.name.not_blank=插件名称不能为空 +plugin.name.length_range=插件名称长度必须在{min}和{max}之间 +plugin.plugin_id.not_blank=插件ID(名称加版本号)不能为空 +plugin.plugin_id.length_range=插件ID(名称加版本号)长度必须在{min}和{max}之间 +plugin.file_name.not_blank=文件名不能为空 +plugin.file_name.length_range=文件名长度必须在{min}和{max}之间 +plugin.create_user.not_blank=创建人不能为空 +plugin.create_user.length_range=创建人长度必须在{min}和{max}之间 +plugin.scenario.not_blank=插件使用场景PAI/PLATFORM不能为空 +plugin.scenario.length_range=插件使用场景PAI/PLATFORM长度必须在{min}和{max}之间 +permission.system_plugin.name=插件 +permission.system_plugin.read=查看插件 +permission.system_plugin.add=创建插件 +permission.system_plugin.edit=更新插件 +permission.system_plugin.delete=删除插件 \ No newline at end of file diff --git a/backend/framework/sdk/src/main/resources/i18n/system_zh_TW.properties b/backend/framework/sdk/src/main/resources/i18n/system_zh_TW.properties index 57ae3c9841..7a46e063a5 100644 --- a/backend/framework/sdk/src/main/resources/i18n/system_zh_TW.properties +++ b/backend/framework/sdk/src/main/resources/i18n/system_zh_TW.properties @@ -54,21 +54,6 @@ operation_log_resource.operating_log_id.not_blank=操作日誌資源操作日誌 operation_log_resource.operating_log_id.length_range=操作日誌資源操作日誌ID長度必須在{min}和{max}之間 operation_log_resource.source_id.not_blank=操作日誌資源來源ID不能為空 operation_log_resource.source_id.length_range=操作日誌資源來源ID長度必須在{min}和{max}之間 -plugin.id.not_blank=插件主鍵不能為空 -plugin.plugin_id.not_blank=插件ID不能為空 -plugin.plugin_id.length_range=插件ID長度必須在{min}和{max}之間 -plugin.script_id.not_blank=插件腳本ID不能為空 -plugin.script_id.length_range=插件腳本ID長度必須在{min}和{max}之間 -plugin.clazz_name.not_blank=插件類名不能為空 -plugin.clazz_name.length_range=插件類名長度必須在{min}和{max}之間 -plugin.jmeter_clazz.not_blank=插件jmeter類名不能為空 -plugin.jmeter_clazz.length_range=插件jmeter類名長度必須在{min}和{max}之間 -plugin.source_path.not_blank=插件源路徑不能為空 -plugin.source_path.length_range=插件源路徑長度必須在{min}和{max}之間 -plugin.source_name.not_blank=插件源名稱不能為空 -plugin.source_name.length_range=插件源名稱長度必須在{min}和{max}之間 -plugin.scenario.not_blank=插件場景不能為空 -plugin.scenario.length_range=插件場景長度必須在{min}和{max}之間 plugin_blob.id.not_blank=插件ID不能為空 quota.id.not_blank=配額ID不能為空 schedule.id.not_blank=定時任務ID不能為空 @@ -162,4 +147,23 @@ global_user_role_relation_system_permission_error=沒有權限操作非系統級 organization_user_role_permission_error=沒有權限操作非組織用戶組 user_role_exist=用戶組已存在 user_role_not_exist=用戶組不存在 -user_role_not_edit=用戶組無法編輯 \ No newline at end of file +user_role_not_edit=用戶組無法編輯 +# plugin +plugin.id.not_blank=ID不能為空 +plugin.id.length_range=ID長度必須在{min}和{max}之间 +plugin.name.not_blank=插件名称不能為空 +plugin.name.length_range=插件名称長度必須在{min}和{max}之间 +plugin.plugin_id.not_blank=插件ID(名称加版本号)不能為空 +plugin.plugin_id.length_range=插件ID(名称加版本号)長度必須在{min}和{max}之间 +plugin.file_name.not_blank=文件名不能為空 +plugin.file_name.length_range=文件名長度必須在{min}和{max}之间 +plugin.create_user.not_blank=创建人不能為空 +plugin.create_user.length_range=创建人長度必須在{min}和{max}之间 +plugin.scenario.not_blank=插件使用场景PAI/PLATFORM不能為空 +plugin.scenario.length_range=插件使用场景PAI/PLATFORM長度必須在{min}和{max}之间 +permission.system_plugin.name=插件 +permission.system_plugin.read=查看插件 +permission.system_plugin.add=創建插件 +permission.system_plugin.edit=更新插件 +permission.system_plugin.delete=刪除插件 + diff --git a/backend/framework/sdk/src/test/java/base/BaseTest.java b/backend/framework/sdk/src/test/java/base/BaseTest.java index a73371447d..7268609087 100644 --- a/backend/framework/sdk/src/test/java/base/BaseTest.java +++ b/backend/framework/sdk/src/test/java/base/BaseTest.java @@ -6,12 +6,12 @@ import com.jayway.jsonpath.JsonPath; import io.metersphere.sdk.constants.SessionConstants; import io.metersphere.sdk.constants.UserRoleType; import io.metersphere.sdk.controller.handler.result.IResultCode; +import io.metersphere.sdk.domain.OperationLogExample; import io.metersphere.sdk.exception.MSException; import io.metersphere.sdk.log.constants.OperationLogType; +import io.metersphere.sdk.mapper.OperationLogMapper; import io.metersphere.sdk.util.JSON; import io.metersphere.sdk.util.Pager; -import io.metersphere.sdk.domain.OperationLogExample; -import io.metersphere.sdk.mapper.OperationLogMapper; import io.metersphere.system.domain.UserRolePermission; import io.metersphere.system.mapper.UserRolePermissionMapper; import io.metersphere.validation.groups.Created; @@ -27,12 +27,19 @@ import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMock import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; +import org.springframework.mock.web.MockMultipartFile; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.ResultActions; import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder; +import org.springframework.test.web.servlet.request.MockMultipartHttpServletRequestBuilder; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; +import org.springframework.util.LinkedMultiValueMap; +import org.springframework.util.MultiValueMap; +import java.io.File; +import java.io.IOException; +import java.nio.file.Files; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -56,6 +63,12 @@ public abstract class BaseTest { @Resource private UserRolePermissionMapper userRolePermissionMapper; + protected static final String DEFAULT_LIST = "list"; + protected static final String DEFAULT_GET = "get/{0}"; + protected static final String DEFAULT_ADD = "add"; + protected static final String DEFAULT_UPDATE = "update"; + protected static final String DEFAULT_DELETE = "delete/{0}"; + /** * 可以重写该方法定义 BASE_PATH */ @@ -144,6 +157,74 @@ public abstract class BaseTest { return this.requestPostWithOk(url, param, uriVariables).andReturn(); } + protected ResultActions requestMultipartWithOk(String url, MultiValueMap paramMap, Object... uriVariables) throws Exception { + MockHttpServletRequestBuilder requestBuilder = getMultipartRequestBuilder(url, paramMap, uriVariables); + return mockMvc.perform(requestBuilder) + .andExpect(content().contentType(MediaType.APPLICATION_JSON)) + .andExpect(status().isOk()); + } + + protected MvcResult requestMultipartWithOkAndReturn(String url, MultiValueMap paramMap, Object... uriVariables) throws Exception { + return this.requestMultipartWithOk(url, paramMap, uriVariables).andReturn(); + } + private MockHttpServletRequestBuilder getPermissionMultipartRequestBuilder(String permissionId, String url, + MultiValueMap paramMap, + Object[] uriVariables) { + AuthInfo authInfo = getPermissionAuthInfo(permissionId); + return getMultipartRequestBuilderWithParam(url, paramMap, uriVariables) + .header(SessionConstants.HEADER_TOKEN, authInfo.getSessionId()) + .header(SessionConstants.CSRF_TOKEN, authInfo.getCsrfToken()); + } + + private MockHttpServletRequestBuilder getMultipartRequestBuilder(String url, + MultiValueMap paramMap, + Object[] uriVariables) { + return getMultipartRequestBuilderWithParam(url, paramMap, uriVariables) + .header(SessionConstants.HEADER_TOKEN, adminAuthInfo.getSessionId()) + .header(SessionConstants.CSRF_TOKEN, adminAuthInfo.getCsrfToken()); + } + + /** + * 构建 multipart 带参数的请求 + * @param url + * @param paramMap + * @param uriVariables + * @return + */ + private MockMultipartHttpServletRequestBuilder getMultipartRequestBuilderWithParam(String url, MultiValueMap paramMap, Object[] uriVariables) { + MockMultipartHttpServletRequestBuilder requestBuilder = + MockMvcRequestBuilders.multipart(getBasePath() + url, uriVariables); + paramMap.forEach((key, value) -> { + List list = value; + for (Object o : list) { + try { + MockMultipartFile multipartFile; + if (o instanceof File) { + File file = (File) o; + multipartFile = new MockMultipartFile(key, file.getName(), + MediaType.APPLICATION_OCTET_STREAM_VALUE, Files.readAllBytes(file.toPath())); + } else { + multipartFile = new MockMultipartFile(key, null, + MediaType.APPLICATION_JSON_VALUE, o.toString().getBytes()); + } + + requestBuilder.file(multipartFile); + } catch (IOException e) { + throw new RuntimeException(e); + } + + } + }); + return requestBuilder; + } + + protected MultiValueMap getDefaultMultiPartParam(Object param, File file) { + MultiValueMap paramMap = new LinkedMultiValueMap<>(); + paramMap.add("file", file); + paramMap.add("request", JSON.toJSONString(param)); + return paramMap; + } + protected T getResultData(MvcResult mvcResult, Class clazz) throws Exception { Object data = JSON.parseMap(mvcResult.getResponse().getContentAsString()).get("data"); return JSON.parseObject(JSON.toJSONString(data), clazz); @@ -250,17 +331,18 @@ public abstract class BaseTest { * 校验权限 * 实现步骤 * 1. 在 application.properties 配置权限的初始化 sql - * spring.sql.init.mode=always - * spring.sql.init.schema-locations=classpath*:dml/init_permission_test.sql + * spring.sql.init.mode=always + * spring.sql.init.schema-locations=classpath*:dml/init_permission_test.sql * 2. 在 init_permission_test.sql 中配置权限, - * 初始化名称为 permissionId 前缀(SYSTEM, ORGANIZATION, PROJECT)的用户组和用户,并关联 + * 初始化名称为 permissionId 前缀(SYSTEM, ORGANIZATION, PROJECT)的用户组和用户,并关联 * 3. 向该用户组中添加权限测试是否生效,删除权限测试是否可以访问 + * * @param permissionId * @param url * @param requestBuilderGetFunc 请求构造器,一个 builder 只能使用一次,需要重新生成 * @throws Exception */ - private void requestPermissionTest(String permissionId, String url, Supplier requestBuilderGetFunc) throws Exception { + private void requestPermissionTest(String permissionId, String url, Supplier requestBuilderGetFunc) throws Exception { String roleId = permissionId.split("_")[0]; // 先给初始化的用户组添加权限 UserRolePermission userRolePermission = initUserRolePermission(roleId, permissionId); @@ -297,6 +379,7 @@ public abstract class BaseTest { /** * 调用 is-login 接口刷新权限 + * * @param permissionId * @throws Exception */ @@ -312,8 +395,13 @@ public abstract class BaseTest { requestPermissionTest(permissionId, url, () -> getPermissionRequestBuilder(permissionId, url, uriVariables)); } + protected void requestMultipartPermissionTest(String permissionId, String url, MultiValueMap paramMap, Object... uriVariables) throws Exception { + requestPermissionTest(permissionId, url, () -> getPermissionMultipartRequestBuilder(permissionId, url, paramMap, uriVariables)); + } + /** * 给用户组绑定对应权限 + * * @param roleId * @param permissionId * @return diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/controller/PluginController.java b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/PluginController.java new file mode 100644 index 0000000000..f304bb9a32 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/controller/PluginController.java @@ -0,0 +1,86 @@ +package io.metersphere.system.controller; + +import io.metersphere.sdk.constants.PermissionConstants; +import io.metersphere.sdk.log.annotation.Log; +import io.metersphere.sdk.log.constants.OperationLogType; +import io.metersphere.sdk.util.BeanUtils; +import io.metersphere.sdk.util.SessionUtils; +import io.metersphere.system.domain.Plugin; +import io.metersphere.system.dto.PluginDTO; +import io.metersphere.system.dto.PluginListDTO; +import io.metersphere.system.request.PluginUpdateRequest; +import io.metersphere.system.service.PluginService; +import io.metersphere.validation.groups.Created; +import io.metersphere.validation.groups.Updated; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; + +/** + * @author : jianxing + * @date : 2023-7-13 + */ +@RestController +@RequestMapping("/plugin") +@Tag(name = "插件") +public class PluginController { + + @Resource + private PluginService pluginService; + + @GetMapping("/list") + @Operation(summary = "获取插件列表") + @RequiresPermissions(PermissionConstants.SYSTEM_PLUGIN_READ) + public List list() { + return pluginService.list(); + } + + @GetMapping("/get/{id}") + @Operation(summary = "获取插件详情") + @RequiresPermissions(PermissionConstants.SYSTEM_PLUGIN_READ) + public PluginDTO get(@PathVariable String id) { + return pluginService.get(id); + } + + @PostMapping("/add") + @Operation(summary = "创建插件") + @RequiresPermissions(PermissionConstants.SYSTEM_PLUGIN_ADD) + @Log(type = OperationLogType.UPDATE, expression = "#msClass.addLog(#request)", msClass = PluginService.class) + public Plugin add(@Validated({Created.class}) @RequestPart(value = "request") PluginUpdateRequest request, + @RequestPart(value = "file") MultipartFile file) { + request.setCreateUser(SessionUtils.getUserId()); + return pluginService.add(request, file); + } + + @PostMapping("/update") + @Operation(summary = "更新插件") + @RequiresPermissions(PermissionConstants.SYSTEM_PLUGIN_UPDATE) + @Log(type = OperationLogType.ADD, expression = "#msClass.updateLog(#request)", msClass = PluginService.class) + public Plugin update(@Validated({Updated.class}) @RequestPart(value = "request") PluginUpdateRequest request, + @RequestPart(value = "file", required = false) MultipartFile file) { + Plugin plugin = new Plugin(); + BeanUtils.copyBean(plugin, request); + return pluginService.update(request, file); + } + + @GetMapping("/delete/{id}") + @Operation(summary = "删除插件") + @RequiresPermissions(PermissionConstants.SYSTEM_PLUGIN_DELETE) + @Log(type = OperationLogType.DELETE, expression = "#msClass.deleteLog(#id)", msClass = PluginService.class) + public String delete(@PathVariable String id) { + return pluginService.delete(id); + } + + @GetMapping("/script/get/{pluginId}/{scriptId}") + @Operation(summary = "获取插件对应表单的脚本内容") + @RequiresPermissions(PermissionConstants.SYSTEM_PLUGIN_READ) + public String getScript(@PathVariable String pluginId, String scriptId) { + return pluginService.getScript(pluginId, scriptId); + } +} \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/PluginDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/PluginDTO.java new file mode 100644 index 0000000000..d0f35da811 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/PluginDTO.java @@ -0,0 +1,17 @@ +package io.metersphere.system.dto; + +import io.metersphere.sdk.dto.OrganizationOptionDTO; +import io.metersphere.system.domain.Plugin; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class PluginDTO extends Plugin implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(title = "关联的组织列表") + private List organizations; +} \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/PluginListDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/PluginListDTO.java new file mode 100644 index 0000000000..6f9032177b --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/PluginListDTO.java @@ -0,0 +1,22 @@ +package io.metersphere.system.dto; + +import io.metersphere.system.domain.Plugin; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +@Data +public class PluginListDTO extends Plugin implements Serializable { + private static final long serialVersionUID = 1L; + + @Schema(title = "插件前端表单配置项列表") + private List pluginForms; + + @Data + class PluginForm { + private String id; + private String name; + } +} \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/PluginQueryRequest.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/PluginQueryRequest.java new file mode 100644 index 0000000000..d4cca2b69f --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/PluginQueryRequest.java @@ -0,0 +1,49 @@ +package io.metersphere.system.dto.request; + +import io.metersphere.sdk.dto.BasePageRequest; +import io.metersphere.validation.groups.Created; +import io.metersphere.validation.groups.Updated; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; +import lombok.Data; + +import java.io.Serializable; +@Data +public class PluginQueryRequest extends BasePageRequest implements Serializable { + + private static final long serialVersionUID = 1L; + @Schema(title = "ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{plugin.id.not_blank}", groups = {Updated.class}) + @Size(min = 1, max = 50, message = "{plugin.id.length_range}", groups = {Created.class, Updated.class}) + private String id; + + @Schema(title = "插件名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{plugin.name.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 255, message = "{plugin.name.length_range}", groups = {Created.class, Updated.class}) + private String name; + + @Schema(title = "插件ID(名称加版本号)", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{plugin.plugin_id.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 300, message = "{plugin.plugin_id.length_range}", groups = {Created.class, Updated.class}) + private String pluginId; + + @Schema(title = "文件名", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{plugin.file_name.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 300, message = "{plugin.file_name.length_range}", groups = {Created.class, Updated.class}) + private String fileName; + + @Schema(title = "是否是全局插件") + private Boolean global; + + @Schema(title = "是否是企业版插件") + private Boolean xpack; + + @Schema(title = "插件描述") + private String description; + + @Schema(title = "插件使用场景PAI/PLATFORM", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{plugin.scenario.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{plugin.scenario.length_range}", groups = {Created.class, Updated.class}) + private String scenario; +} \ No newline at end of file diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/request/PluginUpdateRequest.java b/backend/services/system-setting/src/main/java/io/metersphere/system/request/PluginUpdateRequest.java new file mode 100644 index 0000000000..f1ddc431b1 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/request/PluginUpdateRequest.java @@ -0,0 +1,47 @@ +package io.metersphere.system.request; + +import io.metersphere.sdk.constants.PluginScenarioType; +import io.metersphere.sdk.valid.EnumValue; +import io.metersphere.validation.groups.Created; +import io.metersphere.validation.groups.Updated; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; +import lombok.Data; + +import java.util.List; + +@Data +public class PluginUpdateRequest { + @Schema(title = "ID", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{plugin.id.not_blank}", groups = {Updated.class}) + @Size(min = 1, max = 50, message = "{plugin.id.length_range}", groups = {Created.class, Updated.class}) + private String id; + + @Schema(title = "插件名称", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{plugin.name.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 255, message = "{plugin.name.length_range}", groups = {Created.class, Updated.class}) + private String name; + + @Schema(title = "是否启用插件, 默认启用") + private Boolean enable = true; + + @Schema(title = "是否是全局插件, 默认全局") + private Boolean global = true; + + @Schema(title = "插件描述") + @Size(min = 1, max = 500, message = "{plugin.scenario.length_range}", groups = {Created.class, Updated.class}) + private String description; + + @Schema(title = "插件使用场景PAI/PLATFORM", requiredMode = Schema.RequiredMode.REQUIRED) + @NotBlank(message = "{plugin.scenario.not_blank}", groups = {Created.class}) + @Size(min = 1, max = 50, message = "{plugin.scenario.length_range}", groups = {Created.class, Updated.class}) + @EnumValue(enumClass = PluginScenarioType.class, groups = {Created.class, Updated.class}) + private String scenario; + + @Schema(hidden = true) + private String createUser; + + @Schema(title = "关联的组织ID") + private List organizationIds; +} diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/service/PluginService.java b/backend/services/system-setting/src/main/java/io/metersphere/system/service/PluginService.java new file mode 100644 index 0000000000..09bed52927 --- /dev/null +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/service/PluginService.java @@ -0,0 +1,77 @@ +package io.metersphere.system.service; + + +import io.metersphere.sdk.util.BeanUtils; +import io.metersphere.system.domain.Plugin; +import io.metersphere.system.domain.PluginFrontScript; +import io.metersphere.system.dto.PluginDTO; +import io.metersphere.system.dto.PluginListDTO; +import io.metersphere.system.mapper.PluginFrontScriptMapper; +import io.metersphere.system.mapper.PluginMapper; +import io.metersphere.system.request.PluginUpdateRequest; +import jakarta.annotation.Resource; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; + +/** + * @author jianxing + * @date : 2023-7-13 + */ +@Service +@Transactional(rollbackFor = Exception.class) +public class PluginService { + + @Resource + private PluginMapper pluginMapper; + @Resource + private PluginFrontScriptMapper pluginFrontScriptMapper; + + public List list() { + return new ArrayList<>(); + } + + public PluginDTO get(String id) { + Plugin plugin = pluginMapper.selectByPrimaryKey(id); + PluginDTO pluginDTO = new PluginDTO(); + BeanUtils.copyBean(plugin, pluginDTO); + return pluginDTO; + } + + public Plugin add(PluginUpdateRequest request, MultipartFile file) { + Plugin plugin = new Plugin(); + BeanUtils.copyBean(plugin, request); + plugin.setId(UUID.randomUUID().toString()); + plugin.setPluginId(UUID.randomUUID().toString()); + plugin.setFileName(file.getName()); + plugin.setCreateTime(System.currentTimeMillis()); + plugin.setUpdateTime(System.currentTimeMillis()); + plugin.setXpack(false); + pluginMapper.insert(plugin); + return plugin; + } + + public Plugin update(PluginUpdateRequest request, MultipartFile file) { + Plugin plugin = new Plugin(); + BeanUtils.copyBean(plugin, request); + plugin.setCreateTime(null); + plugin.setUpdateTime(null); + plugin.setCreateUser(null); + pluginMapper.updateByPrimaryKeySelective(plugin); + return plugin; + } + + public String delete(String id) { + pluginMapper.deleteByPrimaryKey(id); + return id; + } + + public String getScript(String pluginId, String scriptId) { + PluginFrontScript frontScript = pluginFrontScriptMapper.selectByPrimaryKey(pluginId, scriptId); + return frontScript == null ? null : frontScript.getScript(); + } +} \ No newline at end of file diff --git a/backend/services/system-setting/src/main/resources/permission.json b/backend/services/system-setting/src/main/resources/permission.json index 95c9c986e3..8a9fb908e1 100644 --- a/backend/services/system-setting/src/main/resources/permission.json +++ b/backend/services/system-setting/src/main/resources/permission.json @@ -73,6 +73,26 @@ "name": "permission.system_test_resource_pool.delete" } ] + }, + { + "id": "SYSTEM_PLUGIN:READ", + "name": "permission.system_plugin.read", + "resourceId": "SYSTEM_PLUGIN" + }, + { + "id": "SYSTEM_PLUGIN:READ+ADD", + "name": "permission.system_plugin.add", + "resourceId": "SYSTEM_PLUGIN" + }, + { + "id": "SYSTEM_PLUGIN:READ+UPDATE", + "name": "permission.system_plugin.edit", + "resourceId": "SYSTEM_PLUGIN" + }, + { + "id": "SYSTEM_PLUGIN:READ+DELETE", + "name": "permission.system_plugin.delete", + "resourceId": "SYSTEM_PLUGIN" } ] }, diff --git a/backend/services/system-setting/src/main/resources/systemGeneratorConfig.xml b/backend/services/system-setting/src/main/resources/systemGeneratorConfig.xml index 5c1af88626..57f952e638 100644 --- a/backend/services/system-setting/src/main/resources/systemGeneratorConfig.xml +++ b/backend/services/system-setting/src/main/resources/systemGeneratorConfig.xml @@ -77,7 +77,8 @@
-
+
+
diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/AuthSourceControllerTest.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/AuthSourceControllerTests.java similarity index 99% rename from backend/services/system-setting/src/test/java/io/metersphere/system/controller/AuthSourceControllerTest.java rename to backend/services/system-setting/src/test/java/io/metersphere/system/controller/AuthSourceControllerTests.java index 0cf4fbd999..534d13e6b3 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/AuthSourceControllerTest.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/AuthSourceControllerTests.java @@ -31,7 +31,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest @AutoConfigureMockMvc @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class AuthSourceControllerTest extends BaseTest { +public class AuthSourceControllerTests extends BaseTest { public static final String AUTH_SOURCE_ADD = "/system/authsource/add"; diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/CommonParamTest.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/CommonParamTests.java similarity index 91% rename from backend/services/system-setting/src/test/java/io/metersphere/system/controller/CommonParamTest.java rename to backend/services/system-setting/src/test/java/io/metersphere/system/controller/CommonParamTests.java index ec7f5f3ae3..362897d430 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/CommonParamTest.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/CommonParamTests.java @@ -16,7 +16,7 @@ import java.util.Map; @SpringBootTest @AutoConfigureMockMvc @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -class CommonParamTest extends BaseTest { +class CommonParamTests extends BaseTest { /** * 校验 BasePageRequestDefinition 参数 @@ -24,7 +24,7 @@ class CommonParamTest extends BaseTest { */ @Test void testBasePageRequestDefinition() throws Exception { - String url = GlobalUserRoleRelationControllerTest.BASE_URL + GlobalUserRoleRelationControllerTest.LIST; + String url = GlobalUserRoleRelationControllerTests.BASE_URL + "list"; paramValidateTest(BasePageRequestDefinition.class, url); BasePageRequestDefinition basePageRequestDefinition = new BasePageRequestDefinition(); // @@校验 sort 字段 sql 防注入,有点复杂,手动写校验 diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/FileCenterTest.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/FileCenterTests.java similarity index 99% rename from backend/services/system-setting/src/test/java/io/metersphere/system/controller/FileCenterTest.java rename to backend/services/system-setting/src/test/java/io/metersphere/system/controller/FileCenterTests.java index 22d3ef7945..eee0680296 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/FileCenterTest.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/FileCenterTests.java @@ -13,7 +13,7 @@ import org.springframework.mock.web.MockMultipartFile; @SpringBootTest @AutoConfigureMockMvc @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class FileCenterTest { +public class FileCenterTests { @Resource private MinioRepository repository; diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleControllerTest.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleControllerTests.java similarity index 91% rename from backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleControllerTest.java rename to backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleControllerTests.java index 74182b7b2d..29a31061b5 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleControllerTest.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleControllerTests.java @@ -35,7 +35,7 @@ import static io.metersphere.system.service.GlobalUserRoleService.GLOBAL_SCOPE; @SpringBootTest @AutoConfigureMockMvc @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -class GlobalUserRoleControllerTest extends BaseTest { +class GlobalUserRoleControllerTests extends BaseTest { @Resource private UserRoleMapper userRoleMapper; @Resource @@ -43,10 +43,6 @@ class GlobalUserRoleControllerTest extends BaseTest { @Resource private BaseUserRoleRelationService baseUserRoleRelationService; private static final String BASE_PATH = "/user/role/global/"; - private static final String LIST = "list"; - private static final String ADD = "add"; - private static final String UPDATE = "update"; - private static final String DELETE = "delete/{0}"; private static final String PERMISSION_SETTING = "permission/setting/{0}"; private static final String PERMISSION_UPDATE = "permission/update"; @@ -60,7 +56,7 @@ class GlobalUserRoleControllerTest extends BaseTest { @Test void list() throws Exception { // @@请求成功 - MvcResult mvcResult = this.requestGetWithOk(LIST) + MvcResult mvcResult = this.requestGetWithOk(DEFAULT_LIST) .andReturn(); List userRoles = getResultDataArray(mvcResult, UserRole.class); @@ -75,7 +71,7 @@ class GlobalUserRoleControllerTest extends BaseTest { Assertions.assertTrue(CollectionUtils.isSubCollection(internalUserRoleIds, userRoleIds)); // @@校验权限 - requestGetPermissionTest(PermissionConstants.SYSTEM_USER_ROLE_READ, LIST); + requestGetPermissionTest(PermissionConstants.SYSTEM_USER_ROLE_READ, DEFAULT_LIST); } @Test @@ -86,7 +82,7 @@ class GlobalUserRoleControllerTest extends BaseTest { request.setName("test"); request.setType(UserRoleType.SYSTEM.name()); request.setDescription("test desc"); - MvcResult mvcResult = this.requestPostWithOkAndReturn(ADD, request); + MvcResult mvcResult = this.requestPostWithOkAndReturn(DEFAULT_ADD, request); UserRole resultData = getResultData(mvcResult, UserRole.class); UserRole userRole = userRoleMapper.selectByPrimaryKey(resultData.getId()); // 校验请求成功数据 @@ -98,13 +94,13 @@ class GlobalUserRoleControllerTest extends BaseTest { checkLog(this.addUserRole.getId(), OperationLogType.ADD); // @@重名校验异常 - assertErrorCode(this.requestPost(ADD, request), GLOBAL_USER_ROLE_EXIST); + assertErrorCode(this.requestPost(DEFAULT_ADD, request), GLOBAL_USER_ROLE_EXIST); // @@异常参数校验 - createdGroupParamValidateTest(UserRoleUpdateRequestDefinition.class, ADD); + createdGroupParamValidateTest(UserRoleUpdateRequestDefinition.class, DEFAULT_ADD); // @@校验权限 - requestPostPermissionTest(PermissionConstants.SYSTEM_USER_ROLE_ADD, ADD, request); + requestPostPermissionTest(PermissionConstants.SYSTEM_USER_ROLE_ADD, DEFAULT_ADD, request); } @Test @@ -116,7 +112,7 @@ class GlobalUserRoleControllerTest extends BaseTest { request.setName("test update"); request.setType(UserRoleType.SYSTEM.name()); request.setDescription("test desc !!!!"); - this.requestPostWithOk(UPDATE, request); + this.requestPostWithOk(DEFAULT_UPDATE, request); // 校验请求成功数据 UserRole userRoleResult = userRoleMapper.selectByPrimaryKey(request.getId()); Assertions.assertEquals(request.getName(), userRoleResult.getName()); @@ -128,23 +124,23 @@ class GlobalUserRoleControllerTest extends BaseTest { // @@操作非全局用户组异常 BeanUtils.copyBean(request, getNonGlobalUserRole()); - assertErrorCode(this.requestPost(UPDATE, request), GLOBAL_USER_ROLE_PERMISSION); + assertErrorCode(this.requestPost(DEFAULT_UPDATE, request), GLOBAL_USER_ROLE_PERMISSION); // @@操作内置用户组异常 request.setId(ADMIN.getValue()); request.setName(ADMIN.getValue()); - assertErrorCode(this.requestPost(UPDATE, request), INTERNAL_USER_ROLE_PERMISSION); + assertErrorCode(this.requestPost(DEFAULT_UPDATE, request), INTERNAL_USER_ROLE_PERMISSION); // @@重名校验异常 request.setId(addUserRole.getId()); request.setName("系统管理员"); - assertErrorCode(this.requestPost(UPDATE, request), GLOBAL_USER_ROLE_EXIST); + assertErrorCode(this.requestPost(DEFAULT_UPDATE, request), GLOBAL_USER_ROLE_EXIST); // @@异常参数校验 - updatedGroupParamValidateTest(UserRoleUpdateRequestDefinition.class, UPDATE); + updatedGroupParamValidateTest(UserRoleUpdateRequestDefinition.class, DEFAULT_UPDATE); // @@校验权限 - requestPostPermissionTest(PermissionConstants.SYSTEM_USER_ROLE_UPDATE, UPDATE, request); + requestPostPermissionTest(PermissionConstants.SYSTEM_USER_ROLE_UPDATE, DEFAULT_UPDATE, request); } @Test @@ -247,7 +243,7 @@ class GlobalUserRoleControllerTest extends BaseTest { @Order(3) void delete() throws Exception { // @@请求成功 - this.requestGet(DELETE, addUserRole.getId()); + this.requestGet(DEFAULT_DELETE, addUserRole.getId()); // 校验请求成功数据 Assertions.assertNull(userRoleMapper.selectByPrimaryKey(addUserRole.getId())); // 校验用户组与权限的关联关系是否删除 @@ -259,13 +255,13 @@ class GlobalUserRoleControllerTest extends BaseTest { checkLog(addUserRole.getId(), OperationLogType.DELETE); // @@操作非全局用户组异常 - assertErrorCode(this.requestGet(DELETE, getNonGlobalUserRole().getId()), GLOBAL_USER_ROLE_PERMISSION); + assertErrorCode(this.requestGet(DEFAULT_DELETE, getNonGlobalUserRole().getId()), GLOBAL_USER_ROLE_PERMISSION); // @@操作内置用户组异常 - assertErrorCode(this.requestGet(DELETE, ADMIN.getValue()), INTERNAL_USER_ROLE_PERMISSION); + assertErrorCode(this.requestGet(DEFAULT_DELETE, ADMIN.getValue()), INTERNAL_USER_ROLE_PERMISSION); // @@校验权限 - requestGetPermissionTest(PermissionConstants.SYSTEM_USER_ROLE_DELETE, DELETE, addUserRole.getId()); + requestGetPermissionTest(PermissionConstants.SYSTEM_USER_ROLE_DELETE, DEFAULT_DELETE, addUserRole.getId()); } /** diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleRelationControllerTest.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleRelationControllerTests.java similarity index 87% rename from backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleRelationControllerTest.java rename to backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleRelationControllerTests.java index 71c09139df..87c16a05fd 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleRelationControllerTest.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/GlobalUserRoleRelationControllerTests.java @@ -35,11 +35,9 @@ import static io.metersphere.system.controller.result.SystemResultCode.*; @SpringBootTest @AutoConfigureMockMvc @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -class GlobalUserRoleRelationControllerTest extends BaseTest { +class GlobalUserRoleRelationControllerTests extends BaseTest { public static final String BASE_URL = "/user/role/relation/global/"; - public static final String LIST = "list"; - public static final String ADD = "add"; - public static final String DELETE = "delete/{0}"; + // 保存创建的数据,方便之后的修改和删除测试使用 private static UserRoleRelation addUserRoleRelation; @Resource @@ -60,7 +58,7 @@ class GlobalUserRoleRelationControllerTest extends BaseTest { request.setRoleId(ADMIN.getValue()); // @@正常请求 - MvcResult mvcResult = this.requestPostWithOkAndReturn(LIST, request); + MvcResult mvcResult = this.requestPostWithOkAndReturn(DEFAULT_LIST, request); Pager> pageResult = getPageResult(mvcResult, UserRoleRelationUserDTO.class); List listRes = pageResult.getList(); Set userIdSet = listRes.stream() @@ -77,18 +75,18 @@ class GlobalUserRoleRelationControllerTest extends BaseTest { // @@操作非系统级别用户组异常 request.setRoleId(ORG_ADMIN.getValue()); - assertErrorCode(this.requestPost(LIST, request), GLOBAL_USER_ROLE_RELATION_SYSTEM_PERMISSION); + assertErrorCode(this.requestPost(DEFAULT_LIST, request), GLOBAL_USER_ROLE_RELATION_SYSTEM_PERMISSION); // @@操作非全局用户组异常 UserRole nonGlobalUserRole = getNonGlobalUserRole(); request.setRoleId(nonGlobalUserRole.getId()); - assertErrorCode(this.requestPost(LIST, request), GLOBAL_USER_ROLE_PERMISSION); + assertErrorCode(this.requestPost(DEFAULT_LIST, request), GLOBAL_USER_ROLE_PERMISSION); // @@异常参数校验 - paramValidateTest(GlobalUserRoleRelationQueryRequestDefinition.class, LIST); + paramValidateTest(GlobalUserRoleRelationQueryRequestDefinition.class, DEFAULT_LIST); // @@校验权限 - requestPostPermissionTest(PermissionConstants.SYSTEM_USER_ROLE_READ, LIST, request); + requestPostPermissionTest(PermissionConstants.SYSTEM_USER_ROLE_READ, DEFAULT_LIST, request); } @Test @@ -102,7 +100,7 @@ class GlobalUserRoleRelationControllerTest extends BaseTest { GlobalUserRoleRelationUpdateRequest request = new GlobalUserRoleRelationUpdateRequest(); request.setUserId(ADMIN.getValue()); request.setRoleId(nonInternalUserRole.getId()); - this.requestPostWithOk(ADD, request); + this.requestPostWithOk(DEFAULT_ADD, request); UserRoleRelationExample example = new UserRoleRelationExample(); example.createCriteria() .andRoleIdEqualTo(request.getRoleId()) @@ -116,31 +114,31 @@ class GlobalUserRoleRelationControllerTest extends BaseTest { // @@重复添加校验 request.setUserId(ADMIN.getValue()); request.setRoleId(ADMIN.getValue()); - assertErrorCode(this.requestPost(ADD, request), USER_ROLE_RELATION_EXIST); + assertErrorCode(this.requestPost(DEFAULT_ADD, request), USER_ROLE_RELATION_EXIST); // @@操作非系统用户组异常 request.setUserId(ADMIN.getValue()); request.setRoleId(ORG_ADMIN.getValue()); - assertErrorCode(this.requestPost(ADD, request), GLOBAL_USER_ROLE_RELATION_SYSTEM_PERMISSION); + assertErrorCode(this.requestPost(DEFAULT_ADD, request), GLOBAL_USER_ROLE_RELATION_SYSTEM_PERMISSION); // @@操作非全局用户组异常 UserRole nonGlobalUserRole = getNonGlobalUserRole(); request.setUserId(ADMIN.getValue()); request.setRoleId(nonGlobalUserRole.getId()); - assertErrorCode(this.requestPost(ADD, request), GLOBAL_USER_ROLE_PERMISSION); + assertErrorCode(this.requestPost(DEFAULT_ADD, request), GLOBAL_USER_ROLE_PERMISSION); // @@异常参数校验 - createdGroupParamValidateTest(GlobalUserRoleRelationUpdateRequestDefinition.class, ADD); + createdGroupParamValidateTest(GlobalUserRoleRelationUpdateRequestDefinition.class, DEFAULT_ADD); // @@校验权限 - requestPostPermissionTest(PermissionConstants.SYSTEM_USER_ROLE_UPDATE, ADD, request); + requestPostPermissionTest(PermissionConstants.SYSTEM_USER_ROLE_UPDATE, DEFAULT_ADD, request); } @Test @Order(1) void delete() throws Exception { // @@请求成功 - this.requestGetWithOk(DELETE, addUserRoleRelation.getId()); + this.requestGetWithOk(DEFAULT_DELETE, addUserRoleRelation.getId()); UserRoleRelation userRoleRelation = userRoleRelationMapper.selectByPrimaryKey(addUserRoleRelation.getId()); Assertions.assertNull(userRoleRelation); @@ -148,11 +146,11 @@ class GlobalUserRoleRelationControllerTest extends BaseTest { checkLog(addUserRoleRelation.getId(), OperationLogType.DELETE); // @@操作非系统级别用户组异常 - assertErrorCode(this.requestGet(DELETE, getNonSystemUserRoleRelation().getId()), + assertErrorCode(this.requestGet(DEFAULT_DELETE, getNonSystemUserRoleRelation().getId()), GLOBAL_USER_ROLE_RELATION_SYSTEM_PERMISSION); // @@操作非全局用户组异常 - assertErrorCode(this.requestGet(DELETE, getNonGlobalUserRoleRelation().getId()), GLOBAL_USER_ROLE_PERMISSION); + assertErrorCode(this.requestGet(DEFAULT_DELETE, getNonGlobalUserRoleRelation().getId()), GLOBAL_USER_ROLE_PERMISSION); // @@删除admin系统管理员用户组异常 UserRoleRelationExample example = new UserRoleRelationExample(); @@ -160,11 +158,11 @@ class GlobalUserRoleRelationControllerTest extends BaseTest { .andRoleIdEqualTo(ADMIN.getValue()) .andUserIdEqualTo(ADMIN.getValue()); List userRoleRelations = userRoleRelationMapper.selectByExample(example); - assertErrorCode(this.requestGet(DELETE, userRoleRelations.get(0).getId()), + assertErrorCode(this.requestGet(DEFAULT_DELETE, userRoleRelations.get(0).getId()), USER_ROLE_RELATION_REMOVE_ADMIN_USER_PERMISSION); // @@校验权限 - requestGetPermissionTest(PermissionConstants.SYSTEM_USER_ROLE_UPDATE, DELETE, addUserRoleRelation.getId()); + requestGetPermissionTest(PermissionConstants.SYSTEM_USER_ROLE_UPDATE, DEFAULT_DELETE, addUserRoleRelation.getId()); } /** diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/PluginControllerTests.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/PluginControllerTests.java new file mode 100644 index 0000000000..cadbce6a00 --- /dev/null +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/PluginControllerTests.java @@ -0,0 +1,129 @@ +package io.metersphere.system.controller; + +import base.BaseTest; +import io.metersphere.sdk.constants.PermissionConstants; +import io.metersphere.sdk.constants.PluginScenarioType; +import io.metersphere.system.domain.Plugin; +import io.metersphere.system.mapper.PluginMapper; +import io.metersphere.system.request.PluginUpdateRequest; +import jakarta.annotation.Resource; +import org.junit.jupiter.api.MethodOrderer; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestMethodOrder; +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.web.servlet.MvcResult; +import org.springframework.util.MultiValueMap; + +import java.io.File; + +/** + * @author jianxing + * @date : 2023-7-14 + */ +@SpringBootTest +@AutoConfigureMockMvc +@TestMethodOrder(MethodOrderer.OrderAnnotation.class) +public class PluginControllerTests extends BaseTest { + private static final String BASE_PATH = "/plugin/"; + private static final String SCRIPT_GET = "script/get/{0}/{1}"; + @Resource + private PluginMapper pluginMapper; + private static Plugin addPlugin; + @Override + protected String getBasePath() { + return BASE_PATH; + } + + @Test + public void list() throws Exception { + // @@请求成功 + this.requestGetWithOk(DEFAULT_LIST) + .andReturn(); +// List pluginList = getResultDataArray(mvcResult, Plugin.class); + // todo 校验数据是否正确 + // @@校验权限 + requestGetPermissionTest(PermissionConstants.SYSTEM_PLUGIN_READ, DEFAULT_LIST); + } + + @Test + @Order(0) + public void add() throws Exception { + // @@请求成功 + PluginUpdateRequest request = new PluginUpdateRequest(); + request.setName("test"); + request.setDescription("test desc"); + request.setScenario(PluginScenarioType.PAI.name()); + MultiValueMap multiValueMap = getDefaultMultiPartParam(request, + new File("src/test/resources/application.properties")); + MvcResult mvcResult = this.requestMultipartWithOkAndReturn(DEFAULT_ADD, multiValueMap); + Plugin resultData = getResultData(mvcResult, Plugin.class); + Plugin plugin = pluginMapper.selectByPrimaryKey(resultData.getId()); + this.addPlugin = plugin; + // todo 校验请求成功数据 + // @@校验日志 + // checkLog(this.addPlugin.getId(), OperationLogType.ADD); + // @@异常参数校验 +// createdGroupParamValidateTest(PluginUpdateRequestDefinition.class, ADD); + // @@校验权限 + requestMultipartPermissionTest(PermissionConstants.SYSTEM_PLUGIN_ADD, DEFAULT_ADD, multiValueMap); + } + + @Test + @Order(1) + public void get() throws Exception { + // @@请求成功 + this.requestGetWithOk(DEFAULT_GET, this.addPlugin.getId()) + .andReturn(); +// Plugin plugin = getResultData(mvcResult, Plugin.class); + // todo 校验数据是否正确 + // @@校验权限 + requestGetPermissionTest(PermissionConstants.SYSTEM_PLUGIN_READ, DEFAULT_GET, this.addPlugin.getId()); + } + + @Test + @Order(2) + public void getScript() throws Exception { + // @@请求成功 + this.requestGetWithOk(SCRIPT_GET, this.addPlugin.getId(), "script id") + .andReturn(); +// Plugin plugin = getResultData(mvcResult, Plugin.class); + // todo 校验数据是否正确 + // @@校验权限 + requestGetPermissionTest(PermissionConstants.SYSTEM_PLUGIN_READ, SCRIPT_GET, this.addPlugin.getId(), "script id"); + } + + + @Test + public void update() throws Exception { + // @@请求成功 + PluginUpdateRequest request = new PluginUpdateRequest(); + request.setId(addPlugin.getId()); + request.setName("test update"); + + MultiValueMap multiValueMap = getDefaultMultiPartParam(request, + new File("src/test/resources/application.properties")); + this.requestMultipartWithOk(DEFAULT_UPDATE, multiValueMap); + // 校验请求成功数据 +// Plugin plugin = pluginMapper.selectByPrimaryKey(request.getId()); + // todo 校验请求成功数据 + // @@校验日志 + // checkLog(request.getId(), OperationLogType.UPDATE); + // @@异常参数校验 +// updatedGroupParamValidateTest(PluginUpdateRequestDefinition.class, UPDATE); + // @@校验权限 + requestMultipartPermissionTest(PermissionConstants.SYSTEM_PLUGIN_UPDATE, DEFAULT_UPDATE, multiValueMap); + } + + @Test + public void delete() throws Exception { + // @@请求成功 + this.requestGetWithOk(DEFAULT_DELETE, addPlugin.getId()); + // todo 校验请求成功数据 + // @@校验日志 + // checkLog(addPlugin.getId(), OperationLogType.DELETE); + // @@校验权限 + requestGetPermissionTest(PermissionConstants.SYSTEM_PLUGIN_DELETE, DEFAULT_DELETE, addPlugin.getId()); + } +} \ No newline at end of file diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemParameterControllerTest.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemParameterControllerTests.java similarity index 99% rename from backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemParameterControllerTest.java rename to backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemParameterControllerTests.java index 7c7b30aec2..349368368f 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemParameterControllerTest.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/SystemParameterControllerTests.java @@ -25,7 +25,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers. @SpringBootTest @AutoConfigureMockMvc @TestMethodOrder(MethodOrderer.OrderAnnotation.class) -public class SystemParameterControllerTest { +public class SystemParameterControllerTests { @Resource private MockMvc mockMvc; diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/param/PluginUpdateRequestDefinition.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/param/PluginUpdateRequestDefinition.java new file mode 100644 index 0000000000..9467acaef1 --- /dev/null +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/param/PluginUpdateRequestDefinition.java @@ -0,0 +1,25 @@ +package io.metersphere.system.controller.param; + +import io.metersphere.validation.groups.Created; +import io.metersphere.validation.groups.Updated; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; +import lombok.Data; + +@Data +public class PluginUpdateRequestDefinition { + @NotBlank(message = "{plugin.id.not_blank}", groups = {Updated.class}) + @Size(min = 1, max = 50, message = "{plugin.id.length_range}", groups = {Created.class, Updated.class}) + private String id; + + @NotBlank(groups = {Created.class}) + @Size(min = 1, max = 255, groups = {Created.class, Updated.class}) + private String name; + + @Size(min = 1, max = 500, groups = {Created.class, Updated.class}) + private String description; + + @NotBlank(groups = {Created.class}) + @Size(min = 1, max = 50, groups = {Created.class, Updated.class}) + private String scenario; +} diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/param/UserRoleUpdateRequestDefinition.java b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/param/UserRoleUpdateRequestDefinition.java index 0c75bd699c..c8662cbfbe 100644 --- a/backend/services/system-setting/src/test/java/io/metersphere/system/controller/param/UserRoleUpdateRequestDefinition.java +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/controller/param/UserRoleUpdateRequestDefinition.java @@ -23,7 +23,7 @@ public class UserRoleUpdateRequestDefinition { private String name; @NotBlank(groups = {Created.class}) - @EnumValue(enumClass = UserRoleType.class, groups = {Created.class}) + @EnumValue(enumClass = UserRoleType.class, groups = {Created.class, Updated.class}) @Size(min = 1, max = 20, groups = {Created.class, Updated.class}) private String type; }