diff --git a/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java b/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java index 9baacf3830..1e4fee821c 100644 --- a/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java +++ b/backend/src/main/java/io/metersphere/api/service/ShareInfoService.java @@ -3,9 +3,11 @@ package io.metersphere.api.service; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; +import io.metersphere.api.dto.automation.APIScenarioReportResult; import io.metersphere.api.dto.share.*; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; +import io.metersphere.base.mapper.ext.ExtApiScenarioReportMapper; import io.metersphere.base.mapper.ext.ExtShareInfoMapper; import io.metersphere.commons.constants.ProjectApplicationType; import io.metersphere.commons.constants.ShareType; @@ -61,6 +63,9 @@ public class ShareInfoService { @Lazy @Resource TestPlanMapper testPlanMapper; + @Resource + private ExtApiScenarioReportMapper extApiScenarioReportMapper; + public List findApiDocumentSimpleInfoByRequest(ApiDocumentRequest request) { if (this.isParamLegitimacy(request)) { @@ -547,6 +552,14 @@ public class ShareInfoService { projectId = testPlan.getProjectId(); }; + } + if(shareInfo.getShareType().equals("API_REPORT")){ + type = ProjectApplicationType.API_SHARE_REPORT_TIME.toString(); + APIScenarioReportResult reportResult = extApiScenarioReportMapper.get(shareInfo.getCustomData()); + if (reportResult != null){ + projectId = reportResult.getProjectId(); + }; + } if(StringUtils.isBlank(type)|| Strings.isBlank(projectId)){ millisCheck(System.currentTimeMillis() - shareInfo.getUpdateTime() ,1000 * 60 * 60 * 24,shareInfo.getId()); diff --git a/backend/src/main/java/io/metersphere/commons/constants/ProjectApplicationType.java b/backend/src/main/java/io/metersphere/commons/constants/ProjectApplicationType.java index c6eb214d18..7a4fe50deb 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/ProjectApplicationType.java +++ b/backend/src/main/java/io/metersphere/commons/constants/ProjectApplicationType.java @@ -2,5 +2,6 @@ package io.metersphere.commons.constants; public enum ProjectApplicationType { TRACK_SHARE_REPORT_TIME, - PERFORMANCE_SHARE_REPORT_TIME + PERFORMANCE_SHARE_REPORT_TIME, + API_SHARE_REPORT_TIME } diff --git a/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java b/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java index e1253bae13..91e7ce51cf 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/ShiroUtils.java @@ -61,6 +61,7 @@ public class ShiroUtils { filterChainDefinitionMap.put("/share/**", "anon"); filterChainDefinitionMap.put("/sharePlanReport", "anon"); filterChainDefinitionMap.put("/sharePerformanceReport", "anon"); + filterChainDefinitionMap.put("/shareApiReport", "anon"); filterChainDefinitionMap.put("/system/theme", "anon"); filterChainDefinitionMap.put("/system/save/baseurl/**", "anon"); diff --git a/backend/src/main/java/io/metersphere/controller/IndexController.java b/backend/src/main/java/io/metersphere/controller/IndexController.java index a48ba6af54..d0f91da819 100644 --- a/backend/src/main/java/io/metersphere/controller/IndexController.java +++ b/backend/src/main/java/io/metersphere/controller/IndexController.java @@ -46,4 +46,9 @@ public class IndexController { public String sharePerformanceRedirect() { return "share-performance-report.html"; } + + @GetMapping(value = "/shareApiReport") + public String shareApiRedirect() { + return "share-api-report.html"; + } } diff --git a/backend/src/main/java/io/metersphere/controller/ShareController.java b/backend/src/main/java/io/metersphere/controller/ShareController.java index 57bab68609..90d4d0fca3 100644 --- a/backend/src/main/java/io/metersphere/controller/ShareController.java +++ b/backend/src/main/java/io/metersphere/controller/ShareController.java @@ -157,7 +157,7 @@ public class ShareController { @GetMapping("/api/scenario/report/get/{shareId}/{reportId}") public APIScenarioReportResult get(@PathVariable String shareId, @PathVariable String reportId) { -// shareInfoService.scenarioReportValidate(shareId, reportId); + shareInfoService.validate(shareId, reportId); return apiScenarioReportService.get(reportId); } diff --git a/backend/src/main/resources/db/migration/V109_v1.19_release.sql b/backend/src/main/resources/db/migration/V109_v1.19_release.sql new file mode 100644 index 0000000000..959b21527f --- /dev/null +++ b/backend/src/main/resources/db/migration/V109_v1.19_release.sql @@ -0,0 +1,37 @@ +DROP PROCEDURE IF EXISTS project_api_appl; +DELIMITER // +CREATE PROCEDURE project_api_appl() +BEGIN + #声明结束标识 + DECLARE end_flag int DEFAULT 0; + + DECLARE projectId varchar(64); + + #声明游标 group_curosr + DECLARE project_curosr CURSOR FOR SELECT DISTINCT id FROM project; + +#设置终止标志 +DECLARE CONTINUE HANDLER FOR NOT FOUND SET end_flag=1; + + #打开游标 +OPEN project_curosr; + #获取当前游标指针记录,取出值赋给自定义的变量 + FETCH project_curosr INTO projectId; + #遍历游标 +REPEAT + #利用取到的值进行数据库的操作 + INSERT INTO project_application (project_id, type, type_value) + VALUES (projectId, 'API_SHARE_REPORT_TIME', '24H'); + # 将游标中的值再赋值给变量,供下次循环使用 + FETCH project_curosr INTO projectId; + UNTIL end_flag END REPEAT; + + #关闭游标 +close project_curosr; + +END +// +DELIMITER ; + +CALL project_api_appl(); +DROP PROCEDURE IF EXISTS project_api_appl; \ No newline at end of file diff --git a/frontend/src/business/components/api/automation/report/ApiReportView.vue b/frontend/src/business/components/api/automation/report/ApiReportView.vue index 03533b7c52..a2bf66453d 100644 --- a/frontend/src/business/components/api/automation/report/ApiReportView.vue +++ b/frontend/src/business/components/api/automation/report/ApiReportView.vue @@ -1,5 +1,5 @@ diff --git a/frontend/src/business/components/api/definition/components/complete/EditCompleteSQLApi.vue b/frontend/src/business/components/api/definition/components/complete/EditCompleteSQLApi.vue index e9dc10ee55..5c72cc20e4 100644 --- a/frontend/src/business/components/api/definition/components/complete/EditCompleteSQLApi.vue +++ b/frontend/src/business/components/api/definition/components/complete/EditCompleteSQLApi.vue @@ -156,7 +156,6 @@ export default { }; }, created() { - console.log("看看是不是这页面") this.$get('/api/definition/follow/' + this.basisData.id, response => { this.basisData.follows = response.data; for (let i = 0; i < response.data.length; i++) { diff --git a/frontend/src/business/components/performance/report/PerformanceReportView.vue b/frontend/src/business/components/performance/report/PerformanceReportView.vue index cd587c384a..bf153a60da 100644 --- a/frontend/src/business/components/performance/report/PerformanceReportView.vue +++ b/frontend/src/business/components/performance/report/PerformanceReportView.vue @@ -46,7 +46,7 @@ - {{ $t('分享报告') }} + {{ $t('test_track.plan_view.share_report') }} + diff --git a/frontend/src/business/components/project/menu/file/ResourceManage.vue b/frontend/src/business/components/project/menu/file/ResourceManage.vue index 98e6cba3a4..a693dbbb08 100644 --- a/frontend/src/business/components/project/menu/file/ResourceManage.vue +++ b/frontend/src/business/components/project/menu/file/ResourceManage.vue @@ -204,7 +204,6 @@ export default { this.currentRow = row; }, handleDelete(row) { - console.log(row); this.$confirm(this.$t('project.file_delete_tip', [row.name]), '', { confirmButtonText: this.$t('commons.confirm'), cancelButtonText: this.$t('commons.cancel'), diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index b31cf54cf3..b2c71da0ea 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -2301,6 +2301,7 @@ export default { test_detail: "Test detail", failure_case: "Failure case", export_report: "Export Report", + share_report: "Share Report", no_case_relevance: "No related use cases", automatically_update_status: "Auto update status", allow_associated_repetitive_cases: "Repetitive Case", diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 2b50ee9ce6..737b0dfc5d 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -2306,6 +2306,7 @@ export default { test_detail: "测试详情", failure_case: "失败用例", export_report: "导出报告", + share_report: "分享报告", no_case_relevance: "没有关联用例", automatically_update_status: "自动更新状态", automatically_update_status_tip: "当功能用例关联的接口或性能用例在测试计划执行后,自动更新功能用例的状态", diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index b2c25970e9..6836b34fb9 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -2305,6 +2305,7 @@ export default { test_detail: "測試詳情", failure_case: "失敗用例", export_report: "導出報告", + share_report: "分享報告", no_case_relevance: "沒有關聯用例", automatically_update_status: "自動更新狀態", automatically_update_status_tip: "當功能用例關聯的接口或性能用例在測試計劃執行後,自動更新功能用例的狀態", diff --git a/frontend/src/template/report/api/apiReportUse.js b/frontend/src/template/report/api/apiReportUse.js new file mode 100644 index 0000000000..121ab7c073 --- /dev/null +++ b/frontend/src/template/report/api/apiReportUse.js @@ -0,0 +1,43 @@ +import Vue from 'vue'; +import ElementUI, {Button, Card, Col, Form, FormItem, Input, Main, Popover, Row, Table, TableColumn} from 'element-ui'; +import '@/assets/theme/index.css'; +import '@/common/css/menu-header.css'; +import '@/common/css/main.css'; +import i18n from "@/i18n/i18n"; +import chart from "@/common/js/chart"; +import filters from "@/common/js/filter"; +import icon from "@/common/js/icon"; +import message from "@/common/js/message"; +import ajax from "@/common/js/ajax"; + + +function apiReportUse(id, template) { + Vue.use(ElementUI, { + i18n: (key, value) => i18n.t(key, value) + }); + + Vue.use(Row); + Vue.use(Col); + Vue.use(Form); + Vue.use(FormItem); + Vue.use(Input); + Vue.use(Button); + Vue.use(chart); + Vue.use(Main); + Vue.use(Card); + Vue.use(TableColumn); + Vue.use(Table); + Vue.use(filters); + Vue.use(icon); + Vue.use(message); + Vue.use(ajax); + Vue.use(Popover); + + new Vue({ + el: id, + i18n, + render: h => h(template) + }); +} + +export default apiReportUse; diff --git a/frontend/src/template/report/api/share/ShareApiReportTemplate.vue b/frontend/src/template/report/api/share/ShareApiReportTemplate.vue new file mode 100644 index 0000000000..cafef698b7 --- /dev/null +++ b/frontend/src/template/report/api/share/ShareApiReportTemplate.vue @@ -0,0 +1,36 @@ + + + + + diff --git a/frontend/src/template/report/api/share/share-api-report.html b/frontend/src/template/report/api/share/share-api-report.html new file mode 100644 index 0000000000..9b82802765 --- /dev/null +++ b/frontend/src/template/report/api/share/share-api-report.html @@ -0,0 +1,13 @@ + + + + + + + + Api Report + + +
+ + diff --git a/frontend/src/template/report/api/share/share-api-report.js b/frontend/src/template/report/api/share/share-api-report.js new file mode 100644 index 0000000000..801c379993 --- /dev/null +++ b/frontend/src/template/report/api/share/share-api-report.js @@ -0,0 +1,4 @@ +import ShareApiReportTemplate from "@/template/report/api/share/ShareApiReportTemplate"; +import apiReportUse from "@/template/report/api/apiReportUse"; + +apiReportUse('#shareApiReport', ShareApiReportTemplate); diff --git a/frontend/vue.config.js b/frontend/vue.config.js index cb48719e53..8324dc9b95 100644 --- a/frontend/vue.config.js +++ b/frontend/vue.config.js @@ -44,6 +44,11 @@ module.exports = { template: "src/template/report/performance/share/share-performance-report.html", filename: "share-performance-report.html", }, + shareApiReport: { + entry: "src/template/report/api/share/share-api-report.js", + template: "src/template/report/api/share/share-api-report.html", + filename: "share-api-report.html", + }, enterpriseReport: { entry: "src/template/enterprise/share/share-enterprise-report.js", template: "src/template/enterprise/share/share-enterprise-report.html",