From c63155faaa1c59ff3593d258e10e510167569dae Mon Sep 17 00:00:00 2001 From: jianxing Date: Wed, 19 Jul 2023 14:15:12 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):?= =?UTF-8?q?=20=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E6=8E=A5=E5=8F=A3=E5=8F=82=E6=95=B0=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= 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 --- .../system/controller/PluginController.java | 3 +- .../io/metersphere/system/dto/PluginDTO.java | 9 ++++ .../metersphere/system/dto/PluginListDTO.java | 22 --------- .../dto/request/PluginQueryRequest.java | 49 ------------------- .../system/request/PluginUpdateRequest.java | 8 --- .../system/service/PluginService.java | 5 +- .../controller/PluginControllerTests.java | 2 - 7 files changed, 13 insertions(+), 85 deletions(-) delete mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/dto/PluginListDTO.java delete mode 100644 backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/PluginQueryRequest.java 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 index f304bb9a32..3ae0397a52 100644 --- 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 @@ -7,7 +7,6 @@ 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; @@ -37,7 +36,7 @@ public class PluginController { @GetMapping("/list") @Operation(summary = "获取插件列表") @RequiresPermissions(PermissionConstants.SYSTEM_PLUGIN_READ) - public List list() { + public List list() { return pluginService.list(); } 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 index d0f35da811..ccad65b30b 100644 --- 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 @@ -12,6 +12,15 @@ import java.util.List; public class PluginDTO extends Plugin implements Serializable { private static final long serialVersionUID = 1L; + @Schema(title = "插件前端表单配置项列表") + private List pluginForms; + @Schema(title = "关联的组织列表") private List organizations; + + @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/PluginListDTO.java b/backend/services/system-setting/src/main/java/io/metersphere/system/dto/PluginListDTO.java deleted file mode 100644 index 6f9032177b..0000000000 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/PluginListDTO.java +++ /dev/null @@ -1,22 +0,0 @@ -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 deleted file mode 100644 index d4cca2b69f..0000000000 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/dto/request/PluginQueryRequest.java +++ /dev/null @@ -1,49 +0,0 @@ -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 index f1ddc431b1..55f2538a59 100644 --- 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 @@ -1,7 +1,5 @@ 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; @@ -33,12 +31,6 @@ public class PluginUpdateRequest { @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; 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 index 09bed52927..a7f9e9ba65 100644 --- 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 @@ -1,11 +1,11 @@ package io.metersphere.system.service; +import io.metersphere.sdk.constants.PluginScenarioType; 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; @@ -31,7 +31,7 @@ public class PluginService { @Resource private PluginFrontScriptMapper pluginFrontScriptMapper; - public List list() { + public List list() { return new ArrayList<>(); } @@ -51,6 +51,7 @@ public class PluginService { plugin.setCreateTime(System.currentTimeMillis()); plugin.setUpdateTime(System.currentTimeMillis()); plugin.setXpack(false); + plugin.setScenario(PluginScenarioType.PAI.name()); pluginMapper.insert(plugin); return plugin; } 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 index cadbce6a00..e9e3344bf5 100644 --- 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 @@ -2,7 +2,6 @@ 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; @@ -54,7 +53,6 @@ public class PluginControllerTests extends BaseTest { 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);