From 9ac645a4df83a61539436b67eb2a7e586613df38 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Fri, 3 Sep 2021 17:28:04 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E8=AF=84=E5=AE=A1=E8=84=91=E5=9B=BE=E9=A1=BA?= =?UTF-8?q?=E5=BA=8F=E8=B7=9F=E5=88=97=E8=A1=A8=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../io/metersphere/base/mapper/ext/ExtBaseMapper.xml | 11 +++++++++-- .../base/mapper/ext/ExtTestPlanTestCaseMapper.xml | 2 +- .../base/mapper/ext/ExtTestReviewCaseMapper.xml | 2 +- .../io/metersphere/commons/utils/ServiceUtils.java | 8 ++++++++ .../metersphere/controller/request/OrderRequest.java | 2 ++ .../track/service/TestPlanTestCaseService.java | 8 ++++++++ .../track/service/TestReviewTestCaseService.java | 8 ++++++++ .../components/track/common/minder/TestPlanMinder.vue | 8 ++++++-- .../track/common/minder/TestReviewMinder.vue | 4 +++- .../comonents/functional/FunctionalTestCaseList.vue | 6 +++++- .../view/comonents/functional/TestPlanFunctional.vue | 8 +++++++- .../review/view/components/TestReviewFunction.vue | 6 ++++++ .../review/view/components/TestReviewTestCaseList.vue | 6 +++++- 13 files changed, 69 insertions(+), 10 deletions(-) diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtBaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtBaseMapper.xml index a3ac8dc6e9..75f24f4eca 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtBaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtBaseMapper.xml @@ -7,7 +7,14 @@ order by - ${order.name} ${order.type} + + + ${order.prefix}.${order.name} ${order.type} + + + ${order.name} ${order.type} + + @@ -56,4 +63,4 @@ - \ No newline at end of file + diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml index 88b5cd3232..bba25942c7 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestPlanTestCaseMapper.xml @@ -451,7 +451,7 @@ pc.plan_id = #{request.planId} and t.node_id = #{request.nodeId} - order by pc.update_time desc; + diff --git a/backend/src/main/java/io/metersphere/commons/utils/ServiceUtils.java b/backend/src/main/java/io/metersphere/commons/utils/ServiceUtils.java index 5fbf52e014..4648affe17 100644 --- a/backend/src/main/java/io/metersphere/commons/utils/ServiceUtils.java +++ b/backend/src/main/java/io/metersphere/commons/utils/ServiceUtils.java @@ -8,6 +8,7 @@ import io.metersphere.controller.request.OrderRequest; import io.metersphere.service.ProjectService; import io.metersphere.service.UserService; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; import java.lang.reflect.Method; import java.util.ArrayList; @@ -20,10 +21,17 @@ import java.util.stream.Collectors; public class ServiceUtils { public static List getDefaultOrder(List orders) { + return getDefaultOrder(null, orders); + } + + public static List getDefaultOrder(String prefix, List orders) { if (orders == null || orders.size() < 1) { OrderRequest orderRequest = new OrderRequest(); orderRequest.setName("update_time"); orderRequest.setType("desc"); + if (StringUtils.isNotBlank(prefix)) { + orderRequest.setPrefix(prefix); + } orders = new ArrayList<>(); orders.add(orderRequest); return orders; diff --git a/backend/src/main/java/io/metersphere/controller/request/OrderRequest.java b/backend/src/main/java/io/metersphere/controller/request/OrderRequest.java index b877fb011c..8fd28aa275 100644 --- a/backend/src/main/java/io/metersphere/controller/request/OrderRequest.java +++ b/backend/src/main/java/io/metersphere/controller/request/OrderRequest.java @@ -8,4 +8,6 @@ import lombok.Setter; public class OrderRequest { private String name; private String type; + // 表前缀 + private String prefix; } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java index c586dd25de..ef6de34057 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java @@ -8,6 +8,7 @@ import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper; import io.metersphere.commons.constants.TestPlanTestCaseStatus; import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.utils.*; +import io.metersphere.controller.request.OrderRequest; import io.metersphere.controller.request.member.QueryMemberRequest; import io.metersphere.log.vo.DetailColumn; import io.metersphere.log.vo.OperatingLogDetails; @@ -298,6 +299,13 @@ public class TestPlanTestCaseService { } public List listForMinder(QueryTestPlanCaseRequest request) { + List orders = ServiceUtils.getDefaultOrder(request.getOrders()); + orders.forEach(order -> { + if (order.getName().equals("create_time")) { + order.setPrefix("pc"); + } + }); + request.setOrders(orders); return extTestPlanTestCaseMapper.listForMinder(request); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java index 9e9380cad4..c88672778b 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java @@ -8,6 +8,7 @@ import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.controller.request.OrderRequest; import io.metersphere.controller.request.member.QueryMemberRequest; import io.metersphere.log.vo.DetailColumn; import io.metersphere.log.vo.OperatingLogDetails; @@ -343,6 +344,13 @@ public class TestReviewTestCaseService { } public List listForMinder(QueryCaseReviewRequest request) { + List orders = ServiceUtils.getDefaultOrder("tcrtc", request.getOrders()); + orders.forEach(order -> { + if (order.getName().equals("update_time")) { + order.setPrefix("tcrtc"); + } + }); + request.setOrders(orders); return extTestReviewCaseMapper.listForMinder(request); } } diff --git a/frontend/src/business/components/track/common/minder/TestPlanMinder.vue b/frontend/src/business/components/track/common/minder/TestPlanMinder.vue index 4f58cabc32..3ffa7012fe 100644 --- a/frontend/src/business/components/track/common/minder/TestPlanMinder.vue +++ b/frontend/src/business/components/track/common/minder/TestPlanMinder.vue @@ -45,7 +45,8 @@ name: "TestPlanMinder", planId: { type: String }, - projectId: String + projectId: String, + condition: Object }, computed: { selectNode() { @@ -71,7 +72,10 @@ name: "TestPlanMinder", handleAfterMount() { listenNodeSelected(() => { let param = { - request: {planId: this.planId}, + request: { + planId: this.planId, + orders: this.condition.orders + }, result: this.result, isDisable: true } diff --git a/frontend/src/business/components/track/common/minder/TestReviewMinder.vue b/frontend/src/business/components/track/common/minder/TestReviewMinder.vue index 10137625ce..96dfdf3cef 100644 --- a/frontend/src/business/components/track/common/minder/TestReviewMinder.vue +++ b/frontend/src/business/components/track/common/minder/TestReviewMinder.vue @@ -44,7 +44,8 @@ name: "TestReviewMinder", reviewId: { type: String }, - projectId: String + projectId: String, + condition: Object }, mounted() { if (this.selectNode && this.selectNode.data) { @@ -76,6 +77,7 @@ name: "TestReviewMinder", let param = { request: { reviewId: this.reviewId, + orders: this.condition.orders }, result: this.result, isDisable: true diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue index 23c2444d96..278af4f340 100644 --- a/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue +++ b/frontend/src/business/components/track/plan/view/comonents/functional/FunctionalTestCaseList.vue @@ -400,9 +400,13 @@ export default { this.updata = !this.updata; }, deep: true - } + }, + condition() { + this.$emit('setCondition', this.condition); + }, }, mounted() { + this.$emit('setCondition', this.condition); hub.$on("openFailureTestCase", row => { this.isReadOnly = true; this.condition.status = 'Failure'; diff --git a/frontend/src/business/components/track/plan/view/comonents/functional/TestPlanFunctional.vue b/frontend/src/business/components/track/plan/view/comonents/functional/TestPlanFunctional.vue index 0d4d45e40f..3fac341ebe 100644 --- a/frontend/src/business/components/track/plan/view/comonents/functional/TestPlanFunctional.vue +++ b/frontend/src/business/components/track/plan/view/comonents/functional/TestPlanFunctional.vue @@ -21,6 +21,7 @@ v-if="activeDom === 'left'" @openTestCaseRelevanceDialog="openTestCaseRelevanceDialog" @refresh="refresh" + @setCondition="setCondition" :plan-id="planId" :clickType="clickType" :select-node-ids="selectNodeIds" @@ -28,6 +29,7 @@ @@ -69,7 +71,8 @@ export default { selectNodeIds: [], treeNodes: [], activeDom: 'left', - selectNode: {} + selectNode: {}, + condition: {} }; }, props: [ @@ -130,6 +133,9 @@ export default { }); } }, + setCondition(data) { + this.condition = data; + }, openTestCaseEdit(path) { if (path.indexOf("/plan/view/edit") >= 0) { let caseId = this.$route.params.caseId; diff --git a/frontend/src/business/components/track/review/view/components/TestReviewFunction.vue b/frontend/src/business/components/track/review/view/components/TestReviewFunction.vue index cf21dfe022..978157cd2a 100644 --- a/frontend/src/business/components/track/review/view/components/TestReviewFunction.vue +++ b/frontend/src/business/components/track/review/view/components/TestReviewFunction.vue @@ -22,12 +22,14 @@ v-if="activeDom === 'left'" @openTestReviewRelevanceDialog="openTestReviewRelevanceDialog" @refresh="refresh" + @setCondition="setCondition" :review-id="reviewId" :clickType="clickType" ref="testPlanTestCaseList"/> @@ -67,6 +69,7 @@ export default { treeNodes: [], isMenuShow: true, activeDom: 'left', + condition: {} } }, props: [ @@ -86,6 +89,9 @@ export default { }, }, methods: { + setCondition(data) { + this.condition = data; + }, refresh() { this.$store.commit('setTestReviewSelectNode', {}); this.$store.commit('setTestReviewSelectNodeIds', []); diff --git a/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue b/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue index 52d818d080..6d49355ee9 100644 --- a/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue +++ b/frontend/src/business/components/track/review/view/components/TestReviewTestCaseList.vue @@ -275,7 +275,10 @@ export default { }, selectNodeIds() { this.search(); - } + }, + condition() { + this.$emit('setCondition', this.condition); + }, }, computed: { selectNodeIds() { @@ -283,6 +286,7 @@ export default { } }, mounted() { + this.$emit('setCondition', this.condition); this.refreshTableAndReview(); this.isTestManagerOrTestUser = true; this.initTableHeader();