From ce8de015853d6bd490376bff79def9b4c1e03258 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Mon, 13 Sep 2021 17:24:26 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E8=84=9A=E6=9C=AC=E4=B8=AD?= =?UTF-8?q?=E5=8F=AF=E6=B7=BB=E5=8A=A0=E8=87=AA=E5=AE=9A=E4=B9=89=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/CustomFunctionService.java | 9 +- .../db/migration/V95__v1.13_release.sql | 22 +++ .../common/Jsr233ProcessorContent.vue | 30 +++- .../project/function/CustomFunction.vue | 3 - .../project/function/CustomFunctionRelate.vue | 137 ++++++++++++++++++ .../project/function/EditFunction.vue | 130 +++++++++++------ .../project/function/custom_function.js | 63 ++++---- 7 files changed, 316 insertions(+), 78 deletions(-) create mode 100644 frontend/src/business/components/settings/project/function/CustomFunctionRelate.vue diff --git a/backend/src/main/java/io/metersphere/service/CustomFunctionService.java b/backend/src/main/java/io/metersphere/service/CustomFunctionService.java index 14d85f8a4d..195dc8635f 100644 --- a/backend/src/main/java/io/metersphere/service/CustomFunctionService.java +++ b/backend/src/main/java/io/metersphere/service/CustomFunctionService.java @@ -78,7 +78,14 @@ public class CustomFunctionService { projectId = SessionUtils.getCurrentProjectId(); } CustomFunctionExample example = new CustomFunctionExample(); - example.createCriteria().andProjectIdEqualTo(projectId); + CustomFunctionExample.Criteria criteria = example.createCriteria(); + criteria.andProjectIdEqualTo(projectId); + if (StringUtils.isNotBlank(request.getType())) { + criteria.andTypeEqualTo(request.getType()); + } + if (StringUtils.isNotBlank(request.getName())) { + criteria.andNameEqualTo(request.getName()); + } return customFunctionMapper.selectByExample(example); } diff --git a/backend/src/main/resources/db/migration/V95__v1.13_release.sql b/backend/src/main/resources/db/migration/V95__v1.13_release.sql index 0072e4c252..57956864dd 100644 --- a/backend/src/main/resources/db/migration/V95__v1.13_release.sql +++ b/backend/src/main/resources/db/migration/V95__v1.13_release.sql @@ -45,3 +45,25 @@ ALTER TABLE test_plan_api_case ADD `order` bigint(20) NOT NULL COMMENT '自定 ALTER TABLE test_plan_api_scenario ADD `order` bigint(20) NOT NULL COMMENT '自定义排序,间隔5000'; ALTER TABLE test_plan_load_case ADD `order` bigint(20) NOT NULL COMMENT '自定义排序,间隔5000'; + +create table if not exists custom_function +( + id varchar(50) not null + primary key, + name varchar(255) null comment '函数名', + tags varchar(1000) null comment '标签', + description varchar(1000) null comment '函数描述', + type varchar(255) null comment '脚本语言类型', + params longtext null comment '参数列表', + script longtext null comment '函数体', + result longtext null comment '执行结果', + create_user varchar(100) null comment '创建人', + create_time bigint(13) null comment '创建时间', + update_time bigint(13) null comment '更新时间', + project_id varchar(50) null comment '所属项目ID' +) + ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 + COLLATE utf8mb4_general_ci; + + diff --git a/frontend/src/business/components/api/automation/scenario/common/Jsr233ProcessorContent.vue b/frontend/src/business/components/api/automation/scenario/common/Jsr233ProcessorContent.vue index 5e2190e26e..3389898756 100644 --- a/frontend/src/business/components/api/automation/scenario/common/Jsr233ProcessorContent.vue +++ b/frontend/src/business/components/api/automation/scenario/common/Jsr233ProcessorContent.vue @@ -14,10 +14,15 @@
{{ template.title }}
+
+ {{ funcLink.title }} +
{{ $t('commons.reference_documentation') }} + + @@ -26,9 +31,10 @@ diff --git a/frontend/src/business/components/settings/project/function/CustomFunction.vue b/frontend/src/business/components/settings/project/function/CustomFunction.vue index a33e956e20..952454347b 100644 --- a/frontend/src/business/components/settings/project/function/CustomFunction.vue +++ b/frontend/src/business/components/settings/project/function/CustomFunction.vue @@ -110,9 +110,6 @@ export default { if (item.tags && item.tags.length > 0) { item.tags = JSON.parse(item.tags); } - if (item.params && item.params.length > 0) { - item.params = JSON.parse(item.params); - } }) }); }, diff --git a/frontend/src/business/components/settings/project/function/CustomFunctionRelate.vue b/frontend/src/business/components/settings/project/function/CustomFunctionRelate.vue new file mode 100644 index 0000000000..56fb7052c4 --- /dev/null +++ b/frontend/src/business/components/settings/project/function/CustomFunctionRelate.vue @@ -0,0 +1,137 @@ + + + + + diff --git a/frontend/src/business/components/settings/project/function/EditFunction.vue b/frontend/src/business/components/settings/project/function/EditFunction.vue index 1800cc9f1b..d1f8075478 100644 --- a/frontend/src/business/components/settings/project/function/EditFunction.vue +++ b/frontend/src/business/components/settings/project/function/EditFunction.vue @@ -28,11 +28,11 @@ - - - - - + + + + + @@ -42,7 +42,7 @@ {{ template.title }} +
+ {{ funcLink.title }} +
{{ $t('commons.reference_documentation') }} @@ -77,6 +80,7 @@ +