From 8a29a86138e3c05e11a919f791c5226368846342 Mon Sep 17 00:00:00 2001 From: wxg0103 <727495428@qq.com> Date: Wed, 30 Mar 2022 16:02:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E5=9C=BA=E6=99=AF=E7=BC=96=E8=BE=91=E5=8F=98=E6=9B=B4?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=8A=A0=E8=BD=BD=E8=BE=83=E6=85=A2=E7=9A=84?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1011594 --user=王孝刚 【接口测试】场景编辑-变更记录加载较慢(50条记录) https://www.tapd.cn/55049933/s/1127738 --- .../base/mapper/ext/ExtOperatingLogMapper.xml | 3 +- .../controller/OperatingLogController.java | 7 ++-- .../components/history/ChangeHistory.vue | 36 +++++++++++++++---- 3 files changed, 35 insertions(+), 11 deletions(-) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtOperatingLogMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtOperatingLogMapper.xml index 2d2145d68f..c40254143c 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtOperatingLogMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtOperatingLogMapper.xml @@ -75,8 +75,9 @@ and t3.source_id = #{request.sourceId, jdbcType=VARCHAR} + and JSON_UNQUOTE(JSON_EXTRACT(t.oper_content, '$.columns[*]')) is not null - order by t.oper_time desc limit 100 + order by t.oper_time desc )tt LEFT JOIN `user` t1 ON tt.oper_user = t1.id LEFT JOIN project t2 ON tt.project_id = t2.id diff --git a/backend/src/main/java/io/metersphere/log/controller/OperatingLogController.java b/backend/src/main/java/io/metersphere/log/controller/OperatingLogController.java index d62116344b..5ddb039882 100644 --- a/backend/src/main/java/io/metersphere/log/controller/OperatingLogController.java +++ b/backend/src/main/java/io/metersphere/log/controller/OperatingLogController.java @@ -32,9 +32,10 @@ public class OperatingLogController { } - @PostMapping("/get/source") - public List findBySourceId(@RequestBody OperatingLogRequest request) { - return operatingLogService.findBySourceId(request); + @PostMapping("/get/source/{goPage}/{pageSize}") + public Pager> findBySourceId(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody OperatingLogRequest request) { + Page page = PageHelper.startPage(goPage, pageSize, true); + return PageUtils.setPageInfo(page, operatingLogService.findBySourceId(request)); } @PostMapping("/save") diff --git a/frontend/src/business/components/history/ChangeHistory.vue b/frontend/src/business/components/history/ChangeHistory.vue index e9ae3427aa..d8a810ef95 100644 --- a/frontend/src/business/components/history/ChangeHistory.vue +++ b/frontend/src/business/components/history/ChangeHistory.vue @@ -35,7 +35,10 @@
- {{ $t('operating_log.info') }} + {{ + $t('operating_log.info') + }} +
{{ detail.newValue ? detail.newValue : "空值" }}
@@ -45,6 +48,8 @@ + @@ -58,9 +63,13 @@ import MsTagsHistoryDetail from "./tags/TagsHistoryDetail"; import MsApiHistoryDetail from "./api/ApiHistoryDetail"; import MsEnvironmentHistoryDetail from "./api/EnvironmentHistoryDetail"; + export default { name: "MsChangeHistory", - components: {MsHistoryDetail, MsTagsHistoryDetail, MsApiHistoryDetail, MsEnvironmentHistoryDetail}, + components: { + MsHistoryDetail, MsTagsHistoryDetail, MsApiHistoryDetail, MsEnvironmentHistoryDetail, + MsTablePagination: () => import("@/business/components/common/pagination/TablePagination"), + }, props: { title: String, }, @@ -72,6 +81,11 @@ export default { linkDatas: ["prerequisite", "steps", "remark", "request", "config", "response", "scenarioDefinition", "tags", "loadConfiguration", "advancedConfiguration"], showChangeField: true, + pageSize: 10, + goPage: 1, + totalCount: 0, + id: String, + module: String } }, methods: { @@ -79,18 +93,24 @@ export default { this.infoVisible = false; }, getDetails(id, modules) { - this.result = this.$post("/operating/log/get/source/", {sourceId: id, modules: modules}, response => { - let data = response.data; + id = this.id; + modules = this.module; + this.result = this.$post("/operating/log/get/source/" + this.goPage + '/' + this.pageSize, { + sourceId: id, + modules: modules + }, response => { + let data = response.data.listObject; + this.totalCount = response.data.itemCount; this.loading = false; if (data) { // 过滤非全局脚本历史变更数据 - if(modules.length > 0 && modules[0] === '项目-环境设置'){ + if (modules.length > 0 && modules[0] === '项目-环境设置') { // 环境设置不显示变更字段 this.showChangeField = false; // 不显示的节点 id let ids = []; - for(let i=0; i (d.diffValue === null || d.diffValue === '')) !== -1){ + for (let i = 0; i < data.length; i++) { + if (data[i].details.columns.findIndex(d => (d.diffValue === null || d.diffValue === '')) !== -1) { ids.push(data[i].id); continue; } @@ -111,6 +131,8 @@ export default { open(id, modules) { this.infoVisible = true; this.loading = true; + this.id = id; + this.module = modules; this.getDetails(id, modules); }, openDetail(row, value) {