From 893485d59229e0bb7b34063328fef2bc90909f61 Mon Sep 17 00:00:00 2001 From: Coooder-X <55648333+Coooder-X@users.noreply.github.com> Date: Wed, 3 Feb 2021 11:20:15 +0800 Subject: [PATCH] =?UTF-8?q?fear:=20(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE)?= =?UTF-8?q?=20=E9=A1=B9=E7=9B=AE-jar=E5=8C=85=E7=AE=A1=E7=90=86=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9F=A5=E6=89=BE=20(#1350)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/JarConfigController.java | 6 +++ .../metersphere/service/JarConfigService.java | 21 ++++++++- .../api/test/components/jar/JarConfig.vue | 14 +++--- .../api/test/components/jar/JarSearchBar.vue | 47 +++++++++++++++++++ frontend/src/i18n/en-US.js | 1 + frontend/src/i18n/zh-CN.js | 1 + frontend/src/i18n/zh-TW.js | 1 + 7 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 frontend/src/business/components/api/test/components/jar/JarSearchBar.vue diff --git a/backend/src/main/java/io/metersphere/controller/JarConfigController.java b/backend/src/main/java/io/metersphere/controller/JarConfigController.java index a2e2aa1567..37578dbaed 100644 --- a/backend/src/main/java/io/metersphere/controller/JarConfigController.java +++ b/backend/src/main/java/io/metersphere/controller/JarConfigController.java @@ -2,6 +2,7 @@ package io.metersphere.controller; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; +import io.metersphere.api.dto.definition.ApiTestCaseRequest; import io.metersphere.base.domain.JarConfig; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; @@ -35,6 +36,11 @@ public class JarConfigController { return JarConfigService.list(); } + @PostMapping("list") + public List list(@RequestBody JarConfig jarConfig) { + return JarConfigService.searchList(jarConfig); + } + @GetMapping("/get/{id}") public JarConfig get(@PathVariable String id) { return JarConfigService.get(id); diff --git a/backend/src/main/java/io/metersphere/service/JarConfigService.java b/backend/src/main/java/io/metersphere/service/JarConfigService.java index fe3f499458..d56fedc56d 100644 --- a/backend/src/main/java/io/metersphere/service/JarConfigService.java +++ b/backend/src/main/java/io/metersphere/service/JarConfigService.java @@ -16,8 +16,8 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import java.io.*; -import java.util.List; -import java.util.UUID; +import java.util.*; +import java.util.stream.Collectors; @Service @Transactional(rollbackFor = Exception.class) @@ -42,6 +42,23 @@ public class JarConfigService { return jarConfigMapper.selectByExample(example); } + public List searchList(JarConfig jarConfig) { + JarConfigExample nameExample = new JarConfigExample(); + JarConfigExample jarExample = new JarConfigExample(); + if (StringUtils.isNotBlank(jarConfig.getName())) { + nameExample.createCriteria().andNameLike("%" + jarConfig.getName() + "%"); + jarExample.createCriteria().andFileNameLike("%" + jarConfig.getName() + "%"); + } // 根据jar包的文件名和自定义名称查找 + nameExample.setOrderByClause("update_time desc"); + jarExample.setOrderByClause("update_time desc"); + List jarConfigList = jarConfigMapper.selectByExample(jarExample); + // 合并两个查找结果并去重,按时间降序 + jarConfigList.addAll(jarConfigMapper.selectByExample(nameExample)); + jarConfigList = jarConfigList.stream().distinct().collect(Collectors.toList()); + Collections.sort(jarConfigList, Comparator.comparing(JarConfig::getUpdateTime).reversed()); + return jarConfigList; + } + public JarConfig get(String id) { return jarConfigMapper.selectByPrimaryKey(id); } diff --git a/frontend/src/business/components/api/test/components/jar/JarConfig.vue b/frontend/src/business/components/api/test/components/jar/JarConfig.vue index 3380217048..8539c36d33 100644 --- a/frontend/src/business/components/api/test/components/jar/JarConfig.vue +++ b/frontend/src/business/components/api/test/components/jar/JarConfig.vue @@ -2,6 +2,7 @@
+
@@ -12,9 +13,10 @@ import {listenGoBack, removeGoBackListener} from "../../../../../../common/js/utils"; import MsJarConfigList from "./JarConfigList"; import MsJarConfigFrom from "./JarConfigFrom"; + import MsJarSearchBar from "./JarSearchBar"; export default { name: "MsJarConfig", - components: {MsJarConfigFrom, MsJarConfigList, MsDialogFooter}, + components: {MsJarConfigFrom, MsJarSearchBar, MsJarConfigList, MsDialogFooter}, data() { return { visible: false, @@ -52,11 +54,11 @@ this.getJarConfigs(); }); }, - getJarConfigs() { - this.result = this.$get("/jar/list/all", response => { - this.configs = response.data; - this.currentConfig = {}; - }) + getJarConfigs(condition) { + this.result = this.$post("/jar/list", {name: condition}, response => { + this.configs = response.data; + this.currentConfig = {}; + }); }, rowSelect(config) { this.currentConfig = config; diff --git a/frontend/src/business/components/api/test/components/jar/JarSearchBar.vue b/frontend/src/business/components/api/test/components/jar/JarSearchBar.vue new file mode 100644 index 0000000000..1b2072e1a9 --- /dev/null +++ b/frontend/src/business/components/api/test/components/jar/JarSearchBar.vue @@ -0,0 +1,47 @@ + + + + + diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index 00b2126cd3..e0db7e117b 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -314,6 +314,7 @@ export default { delete_confirm: 'Deleting this project will delete all test resources under this project. Are you sure you want to delete?', delete_tip: 'Deleting this project will delete all test resources under this project. Are you sure you want to delete?', search_by_name: 'Search by name', + search_by_name_jar: 'Search by name/jar', input_name: 'Please enter a workspace name', owning_workspace: 'Owning Workspace', please_choose_workspace: 'Please select Workspace', diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 48dcfdbd14..ea80f1ce5b 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -312,6 +312,7 @@ export default { delete_confirm: '确定要删除这个项目吗?', delete_tip: '删除该项目,会删除该项目下所有测试资源,确定要删除吗?', search_by_name: '根据名称搜索', + search_by_name_jar: '根据 名称 / jar包 搜索', input_name: '请输入项目名称', owning_workspace: '所属工作空间', please_choose_workspace: '请选择工作空间', diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 9c9ecabf37..1d2b574e4b 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -312,6 +312,7 @@ export default { delete_confirm: '確定要刪除這個項目嗎?', delete_tip: '刪除該項目,會刪除該項目下所有測試資源,確定要刪除嗎?', search_by_name: '根據名稱搜索', + search_by_name_jar: '根據名稱/jar包搜索', input_name: '請輸入項目名稱', owning_workspace: '所屬工作空間', please_choose_workspace: '請選擇工作空間',