From 4d716172794de43c13868da3e050a9aa78a2c8a6 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Sat, 18 Sep 2021 13:53:31 +0800 Subject: [PATCH] =?UTF-8?q?fix=5F=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE=5F?= =?UTF-8?q?=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86=5F=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E5=A4=B1=E6=95=88--bug=3D1006713=20--user=3D=E7=8E=8B=E5=AD=9D?= =?UTF-8?q?=E5=88=9A=20=E3=80=90=E6=8F=92=E4=BB=B6=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E3=80=91=E6=90=9C=E7=B4=A2=E4=B8=8D=E7=94=9F=E6=95=88=20https:?= =?UTF-8?q?//www.tapd.cn/55049933/s/1048283?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PluginController.java | 4 +- .../io/metersphere/service/PluginService.java | 57 +++++++++++-------- .../settings/plugin/PluginConfig.vue | 10 ++-- 3 files changed, 42 insertions(+), 29 deletions(-) diff --git a/backend/src/main/java/io/metersphere/controller/PluginController.java b/backend/src/main/java/io/metersphere/controller/PluginController.java index 9d1a9a504c..9350204337 100644 --- a/backend/src/main/java/io/metersphere/controller/PluginController.java +++ b/backend/src/main/java/io/metersphere/controller/PluginController.java @@ -27,8 +27,8 @@ public class PluginController { } @GetMapping("/list") - public List list() { - return pluginService.list(); + public List list(String name) { + return pluginService.list(name); } @GetMapping("/get/{id}") diff --git a/backend/src/main/java/io/metersphere/service/PluginService.java b/backend/src/main/java/io/metersphere/service/PluginService.java index 55818626ea..66b3fda976 100644 --- a/backend/src/main/java/io/metersphere/service/PluginService.java +++ b/backend/src/main/java/io/metersphere/service/PluginService.java @@ -150,30 +150,41 @@ public class PluginService { } } - public List list() { - PluginExample example = new PluginExample(); - List plugins = pluginMapper.selectByExample(example); - Map pluginMap = new HashMap<>(); - List lists = new LinkedList<>(); - // 校验插件是否是企业版 - plugins.forEach(item -> { - PluginDTO dto = new PluginDTO(); - BeanUtils.copyBean(dto, item); - if (!pluginMap.containsKey(item.getPluginId())) { - try { - Class clazz = Class.forName(item.getExecEntry()); - Object instance = clazz.newInstance(); - dto.setLicense(this.isXpack(Class.forName(item.getExecEntry()), instance)); - } catch (Exception e) { - LogUtil.error(e.getMessage()); - } - } else { - dto.setLicense(pluginMap.get(item.getPluginId())); + public List list(String name) { + try { + PluginExample example = new PluginExample(); + if (StringUtils.isNotBlank(name)) { + name = "%" + name + "%"; + example.createCriteria().andNameLike(name); } - lists.add(dto); - pluginMap.put(item.getPluginId(), dto.getLicense()); - }); - return lists; + List plugins = pluginMapper.selectByExample(example); + Map pluginMap = new HashMap<>(); + List lists = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(plugins)) { + // 校验插件是否是企业版 + plugins.forEach(item -> { + PluginDTO dto = new PluginDTO(); + BeanUtils.copyBean(dto, item); + if (!pluginMap.containsKey(item.getPluginId())) { + try { + Class clazz = Class.forName(item.getExecEntry()); + Object instance = clazz.newInstance(); + dto.setLicense(this.isXpack(Class.forName(item.getExecEntry()), instance)); + } catch (Exception e) { + LogUtil.error(e.getMessage()); + } + } else { + dto.setLicense(pluginMap.get(item.getPluginId())); + } + lists.add(dto); + pluginMap.put(item.getPluginId(), dto.getLicense()); + }); + return lists; + } + } catch (Exception e) { + LogUtil.error(e); + } + return null; } public Plugin get(String scriptId) { diff --git a/frontend/src/business/components/settings/plugin/PluginConfig.vue b/frontend/src/business/components/settings/plugin/PluginConfig.vue index 5e193ff564..0a14568493 100644 --- a/frontend/src/business/components/settings/plugin/PluginConfig.vue +++ b/frontend/src/business/components/settings/plugin/PluginConfig.vue @@ -6,11 +6,12 @@ @@ -87,14 +88,15 @@ export default { this.initPlugins(); }, methods: { - search() { - - }, importJar() { this.dialogVisible = true; }, initPlugins() { let url = "/plugin/list"; + let name = this.condition.name; + if (name) { + url = "/plugin/list?name=" +name; + } this.tableData = []; this.$get(url, response => { if (response.data) {