From 2f8f24c08aa39968834c3149fc84563519e5c85d Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 18 May 2021 18:43:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA=E4=B8=8B?= =?UTF-8?q?=E6=89=80=E6=9C=89=E6=A8=A1=E5=9D=97=E7=9A=84=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/ApiAutomationController.java | 1 + .../controller/ApiDefinitionController.java | 1 + .../api/service/ApiAutomationService.java | 18 +++ .../api/service/ApiDefinitionService.java | 17 ++- .../api/service/ApiTestCaseService.java | 1 + .../base/domain/TestCaseReport.java | 5 +- .../base/domain/TestCaseReportExample.java | 98 ++++++++++++-- .../base/domain/TestCaseReview.java | 5 +- .../base/domain/TestCaseReviewExample.java | 70 ++++++++++ .../base/domain/TestCaseReviewTestCase.java | 2 + .../domain/TestCaseReviewTestCaseExample.java | 70 ++++++++++ .../base/domain/TestPlanApiCase.java | 2 + .../base/domain/TestPlanApiCaseExample.java | 70 ++++++++++ .../base/domain/TestPlanApiScenario.java | 2 + .../domain/TestPlanApiScenarioExample.java | 70 ++++++++++ .../base/domain/TestPlanLoadCase.java | 5 +- .../base/domain/TestPlanLoadCaseExample.java | 70 ++++++++++ .../base/domain/TestPlanTestCase.java | 5 +- .../base/domain/TestPlanTestCaseExample.java | 70 ++++++++++ .../base/mapper/TestCaseReportMapper.xml | 45 +++++-- .../base/mapper/TestCaseReviewMapper.xml | 28 +++- .../mapper/TestCaseReviewTestCaseMapper.xml | 27 +++- .../base/mapper/TestPlanApiCaseMapper.xml | 26 +++- .../base/mapper/TestPlanApiScenarioMapper.xml | 27 +++- .../base/mapper/TestPlanLoadCaseMapper.xml | 26 +++- .../base/mapper/TestPlanMapper.xml | 124 +++++++++--------- .../base/mapper/TestPlanTestCaseMapper.xml | 32 ++++- .../commons/constants/OperLogConstants.java | 2 +- .../log/utils/ReflexObjectUtil.java | 11 +- .../metersphere/log/vo/StatusReference.java | 27 ++++ .../log/vo/track/TestCaseReference.java | 1 - .../log/vo/track/TestCaseReviewReference.java | 22 ++++ .../log/vo/track/TestPlanReference.java | 41 ++++++ .../track/controller/IssuesController.java | 6 + .../controller/TestCaseCommentController.java | 11 ++ .../controller/TestCaseReportController.java | 7 + .../controller/TestCaseReviewController.java | 8 ++ .../controller/TestPlanApiCaseController.java | 5 + .../track/controller/TestPlanController.java | 9 ++ .../TestPlanLoadCaseController.java | 9 ++ .../controller/TestPlanReportController.java | 3 + .../TestPlanScenarioCaseController.java | 7 + .../TestPlanTestCaseController.java | 10 +- .../TestReviewTestCaseController.java | 7 + .../track/dto/RelevanceScenarioRequest.java | 1 + .../testCaseReport/CreateReportRequest.java | 1 + .../track/service/IssuesService.java | 30 ++++- .../track/service/TestCaseCommentService.java | 26 +++- .../track/service/TestCaseReportService.java | 19 ++- .../track/service/TestCaseReviewService.java | 51 ++++++- .../track/service/TestPlanApiCaseService.java | 53 ++++++-- .../service/TestPlanLoadCaseService.java | 67 +++++++++- .../track/service/TestPlanReportService.java | 15 +++ .../service/TestPlanScenarioCaseService.java | 47 ++++++- .../track/service/TestPlanService.java | 117 +++++++++++------ .../service/TestPlanTestCaseService.java | 63 ++++++++- .../service/TestReviewTestCaseService.java | 112 +++++++++++++++- backend/src/main/java/io/metersphere/xpack | 2 +- .../db/migration/V83__v1.10_release.sql | 32 ++--- .../src/main/resources/generatorConfig.xml | 2 +- .../settings/operatinglog/LogDetail.vue | 2 + .../settings/operatinglog/OperatingLog.vue | 2 + frontend/src/business/components/xpack | 2 +- frontend/src/i18n/en-US.js | 1 + frontend/src/i18n/zh-CN.js | 1 + frontend/src/i18n/zh-TW.js | 1 + 66 files changed, 1520 insertions(+), 230 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/log/vo/StatusReference.java create mode 100644 backend/src/main/java/io/metersphere/log/vo/track/TestCaseReviewReference.java create mode 100644 backend/src/main/java/io/metersphere/log/vo/track/TestPlanReference.java diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java index 4f274f1360..ab00aaf2dc 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java @@ -210,6 +210,7 @@ public class ApiAutomationController { } @PostMapping("/relevance") + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.ASSOCIATE_CASE, content = "#msClass.getLogDetails(#request)", msClass = ApiAutomationService.class) public void testPlanRelevance(@RequestBody ApiCaseRelevanceRequest request) { apiAutomationService.relevance(request); } diff --git a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java index 2606fc1f18..f2e8c4749f 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiDefinitionController.java @@ -273,6 +273,7 @@ public class ApiDefinitionController { } @PostMapping("/relevance") + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.ASSOCIATE_CASE, content = "#msClass.getLogDetails(#request)", msClass = ApiDefinitionService.class) public void testPlanRelevance(@RequestBody ApiCaseRelevanceRequest request) { apiDefinitionService.testPlanRelevance(request); } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java index 10cbcc5ee3..1352e07d35 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -119,6 +119,8 @@ public class ApiAutomationService { private ApiScenarioReportService apiScenarioReportService; @Resource private ProjectMapper projectMapper; + @Resource + private TestPlanMapper testPlanMapper; public ApiScenarioWithBLOBs getDto(String id) { return apiScenarioMapper.selectByPrimaryKey(id); @@ -1374,6 +1376,7 @@ public class ApiAutomationService { } TestPlanApiScenario testPlanApiScenario = new TestPlanApiScenario(); testPlanApiScenario.setId(UUID.randomUUID().toString()); + testPlanApiScenario.setCreateUser(SessionUtils.getUserId()); testPlanApiScenario.setApiScenarioId(id); testPlanApiScenario.setTestPlanId(request.getPlanId()); testPlanApiScenario.setCreateTime(System.currentTimeMillis()); @@ -1901,4 +1904,19 @@ public class ApiAutomationService { } return null; } + + public String getLogDetails(ApiCaseRelevanceRequest request) { + Map> mapping = request.getMapping(); + Set set = mapping.keySet(); + if (CollectionUtils.isNotEmpty(set)) { + ApiScenarioExample example = new ApiScenarioExample(); + example.createCriteria().andIdIn(new ArrayList<>(set)); + List scenarios = apiScenarioMapper.selectByExample(example); + List names = scenarios.stream().map(ApiScenario::getName).collect(Collectors.toList()); + TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(request.getSelectIds()), testPlan.getProjectId(), String.join(",", names), testPlan.getCreator(), new LinkedList<>()); + return JSON.toJSONString(details); + } + return null; + } } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index a079adeb85..e5c6c30ba4 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -99,9 +99,11 @@ public class ApiDefinitionService { @Resource private EsbApiParamService esbApiParamService; @Resource - ApiModuleMapper apiModuleMapper; + private ApiModuleMapper apiModuleMapper; @Resource private SystemParameterService systemParameterService; + @Resource + private TestPlanMapper testPlanMapper; private static Cache cache = Cache.newHardMemoryCache(0, 3600 * 24); @@ -1129,4 +1131,17 @@ public class ApiDefinitionService { return null; } + public String getLogDetails(ApiCaseRelevanceRequest request) { + ApiTestCaseExample example = new ApiTestCaseExample(); + example.createCriteria().andApiDefinitionIdIn(request.getSelectIds()); + List apiTestCases = apiTestCaseMapper.selectByExample(example); + if (CollectionUtils.isNotEmpty(apiTestCases)) { + List names = apiTestCases.stream().map(ApiTestCase::getName).collect(Collectors.toList()); + TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(request.getSelectIds()), testPlan.getProjectId(), String.join(",", names), testPlan.getCreator(), new LinkedList<>()); + return JSON.toJSONString(details); + } + return null; + } + } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java index cac623487e..2f83391fed 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiTestCaseService.java @@ -407,6 +407,7 @@ public class ApiTestCaseService { apiTestCases.forEach(apiTestCase -> { TestPlanApiCase testPlanApiCase = new TestPlanApiCase(); testPlanApiCase.setId(UUID.randomUUID().toString()); + testPlanApiCase.setCreateUser(SessionUtils.getUserId()); testPlanApiCase.setApiCaseId(apiTestCase.getId()); testPlanApiCase.setTestPlanId(request.getPlanId()); testPlanApiCase.setEnvironmentId(request.getEnvironmentId()); diff --git a/backend/src/main/java/io/metersphere/base/domain/TestCaseReport.java b/backend/src/main/java/io/metersphere/base/domain/TestCaseReport.java index 455e3d1626..ef93d14389 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestCaseReport.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestCaseReport.java @@ -1,8 +1,9 @@ package io.metersphere.base.domain; -import java.io.Serializable; import lombok.Data; +import java.io.Serializable; + @Data public class TestCaseReport implements Serializable { private String id; @@ -13,6 +14,8 @@ public class TestCaseReport implements Serializable { private Long endTime; + private String createUser; + private String content; private static final long serialVersionUID = 1L; diff --git a/backend/src/main/java/io/metersphere/base/domain/TestCaseReportExample.java b/backend/src/main/java/io/metersphere/base/domain/TestCaseReportExample.java index 78cac17453..37449182d7 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestCaseReportExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestCaseReportExample.java @@ -175,72 +175,72 @@ public class TestCaseReportExample { } public Criteria andNameIsNull() { - addCriterion("name is null"); + addCriterion("`name` is null"); return (Criteria) this; } public Criteria andNameIsNotNull() { - addCriterion("name is not null"); + addCriterion("`name` is not null"); return (Criteria) this; } public Criteria andNameEqualTo(String value) { - addCriterion("name =", value, "name"); + addCriterion("`name` =", value, "name"); return (Criteria) this; } public Criteria andNameNotEqualTo(String value) { - addCriterion("name <>", value, "name"); + addCriterion("`name` <>", value, "name"); return (Criteria) this; } public Criteria andNameGreaterThan(String value) { - addCriterion("name >", value, "name"); + addCriterion("`name` >", value, "name"); return (Criteria) this; } public Criteria andNameGreaterThanOrEqualTo(String value) { - addCriterion("name >=", value, "name"); + addCriterion("`name` >=", value, "name"); return (Criteria) this; } public Criteria andNameLessThan(String value) { - addCriterion("name <", value, "name"); + addCriterion("`name` <", value, "name"); return (Criteria) this; } public Criteria andNameLessThanOrEqualTo(String value) { - addCriterion("name <=", value, "name"); + addCriterion("`name` <=", value, "name"); return (Criteria) this; } public Criteria andNameLike(String value) { - addCriterion("name like", value, "name"); + addCriterion("`name` like", value, "name"); return (Criteria) this; } public Criteria andNameNotLike(String value) { - addCriterion("name not like", value, "name"); + addCriterion("`name` not like", value, "name"); return (Criteria) this; } public Criteria andNameIn(List values) { - addCriterion("name in", values, "name"); + addCriterion("`name` in", values, "name"); return (Criteria) this; } public Criteria andNameNotIn(List values) { - addCriterion("name not in", values, "name"); + addCriterion("`name` not in", values, "name"); return (Criteria) this; } public Criteria andNameBetween(String value1, String value2) { - addCriterion("name between", value1, value2, "name"); + addCriterion("`name` between", value1, value2, "name"); return (Criteria) this; } public Criteria andNameNotBetween(String value1, String value2) { - addCriterion("name not between", value1, value2, "name"); + addCriterion("`name` not between", value1, value2, "name"); return (Criteria) this; } @@ -363,6 +363,76 @@ public class TestCaseReportExample { addCriterion("end_time not between", value1, value2, "endTime"); return (Criteria) this; } + + public Criteria andCreateUserIsNull() { + addCriterion("create_user is null"); + return (Criteria) this; + } + + public Criteria andCreateUserIsNotNull() { + addCriterion("create_user is not null"); + return (Criteria) this; + } + + public Criteria andCreateUserEqualTo(String value) { + addCriterion("create_user =", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotEqualTo(String value) { + addCriterion("create_user <>", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThan(String value) { + addCriterion("create_user >", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThanOrEqualTo(String value) { + addCriterion("create_user >=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThan(String value) { + addCriterion("create_user <", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThanOrEqualTo(String value) { + addCriterion("create_user <=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLike(String value) { + addCriterion("create_user like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotLike(String value) { + addCriterion("create_user not like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserIn(List values) { + addCriterion("create_user in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotIn(List values) { + addCriterion("create_user not in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserBetween(String value1, String value2) { + addCriterion("create_user between", value1, value2, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotBetween(String value1, String value2) { + addCriterion("create_user not between", value1, value2, "createUser"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/TestCaseReview.java b/backend/src/main/java/io/metersphere/base/domain/TestCaseReview.java index f3a6e98dac..3bad1cb554 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestCaseReview.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestCaseReview.java @@ -1,8 +1,9 @@ package io.metersphere.base.domain; -import java.io.Serializable; import lombok.Data; +import java.io.Serializable; + @Data public class TestCaseReview implements Serializable { private String id; @@ -23,6 +24,8 @@ public class TestCaseReview implements Serializable { private String tags; + private String createUser; + private String description; private static final long serialVersionUID = 1L; diff --git a/backend/src/main/java/io/metersphere/base/domain/TestCaseReviewExample.java b/backend/src/main/java/io/metersphere/base/domain/TestCaseReviewExample.java index 61d810336f..a66db79941 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestCaseReviewExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestCaseReviewExample.java @@ -703,6 +703,76 @@ public class TestCaseReviewExample { addCriterion("tags not between", value1, value2, "tags"); return (Criteria) this; } + + public Criteria andCreateUserIsNull() { + addCriterion("create_user is null"); + return (Criteria) this; + } + + public Criteria andCreateUserIsNotNull() { + addCriterion("create_user is not null"); + return (Criteria) this; + } + + public Criteria andCreateUserEqualTo(String value) { + addCriterion("create_user =", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotEqualTo(String value) { + addCriterion("create_user <>", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThan(String value) { + addCriterion("create_user >", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThanOrEqualTo(String value) { + addCriterion("create_user >=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThan(String value) { + addCriterion("create_user <", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThanOrEqualTo(String value) { + addCriterion("create_user <=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLike(String value) { + addCriterion("create_user like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotLike(String value) { + addCriterion("create_user not like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserIn(List values) { + addCriterion("create_user in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotIn(List values) { + addCriterion("create_user not in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserBetween(String value1, String value2) { + addCriterion("create_user between", value1, value2, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotBetween(String value1, String value2) { + addCriterion("create_user not between", value1, value2, "createUser"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/TestCaseReviewTestCase.java b/backend/src/main/java/io/metersphere/base/domain/TestCaseReviewTestCase.java index 15644070e0..57ee239129 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestCaseReviewTestCase.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestCaseReviewTestCase.java @@ -21,5 +21,7 @@ public class TestCaseReviewTestCase implements Serializable { private Long updateTime; + private String createUser; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/TestCaseReviewTestCaseExample.java b/backend/src/main/java/io/metersphere/base/domain/TestCaseReviewTestCaseExample.java index ac0827ab7e..1942553bf5 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestCaseReviewTestCaseExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestCaseReviewTestCaseExample.java @@ -643,6 +643,76 @@ public class TestCaseReviewTestCaseExample { addCriterion("update_time not between", value1, value2, "updateTime"); return (Criteria) this; } + + public Criteria andCreateUserIsNull() { + addCriterion("create_user is null"); + return (Criteria) this; + } + + public Criteria andCreateUserIsNotNull() { + addCriterion("create_user is not null"); + return (Criteria) this; + } + + public Criteria andCreateUserEqualTo(String value) { + addCriterion("create_user =", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotEqualTo(String value) { + addCriterion("create_user <>", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThan(String value) { + addCriterion("create_user >", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThanOrEqualTo(String value) { + addCriterion("create_user >=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThan(String value) { + addCriterion("create_user <", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThanOrEqualTo(String value) { + addCriterion("create_user <=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLike(String value) { + addCriterion("create_user like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotLike(String value) { + addCriterion("create_user not like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserIn(List values) { + addCriterion("create_user in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotIn(List values) { + addCriterion("create_user not in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserBetween(String value1, String value2) { + addCriterion("create_user between", value1, value2, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotBetween(String value1, String value2) { + addCriterion("create_user not between", value1, value2, "createUser"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanApiCase.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanApiCase.java index 180468a078..82e694d52b 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanApiCase.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanApiCase.java @@ -19,5 +19,7 @@ public class TestPlanApiCase implements Serializable { private Long updateTime; + private String createUser; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanApiCaseExample.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanApiCaseExample.java index 930a20f86d..2c3c3947af 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanApiCaseExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanApiCaseExample.java @@ -573,6 +573,76 @@ public class TestPlanApiCaseExample { addCriterion("update_time not between", value1, value2, "updateTime"); return (Criteria) this; } + + public Criteria andCreateUserIsNull() { + addCriterion("create_user is null"); + return (Criteria) this; + } + + public Criteria andCreateUserIsNotNull() { + addCriterion("create_user is not null"); + return (Criteria) this; + } + + public Criteria andCreateUserEqualTo(String value) { + addCriterion("create_user =", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotEqualTo(String value) { + addCriterion("create_user <>", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThan(String value) { + addCriterion("create_user >", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThanOrEqualTo(String value) { + addCriterion("create_user >=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThan(String value) { + addCriterion("create_user <", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThanOrEqualTo(String value) { + addCriterion("create_user <=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLike(String value) { + addCriterion("create_user like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotLike(String value) { + addCriterion("create_user not like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserIn(List values) { + addCriterion("create_user in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotIn(List values) { + addCriterion("create_user not in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserBetween(String value1, String value2) { + addCriterion("create_user between", value1, value2, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotBetween(String value1, String value2) { + addCriterion("create_user not between", value1, value2, "createUser"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanApiScenario.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanApiScenario.java index 652185c880..90154e7079 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanApiScenario.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanApiScenario.java @@ -23,6 +23,8 @@ public class TestPlanApiScenario implements Serializable { private String reportId; + private String createUser; + private String environment; private static final long serialVersionUID = 1L; diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanApiScenarioExample.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanApiScenarioExample.java index 40d9e139f9..00411cb307 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanApiScenarioExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanApiScenarioExample.java @@ -713,6 +713,76 @@ public class TestPlanApiScenarioExample { addCriterion("report_id not between", value1, value2, "reportId"); return (Criteria) this; } + + public Criteria andCreateUserIsNull() { + addCriterion("create_user is null"); + return (Criteria) this; + } + + public Criteria andCreateUserIsNotNull() { + addCriterion("create_user is not null"); + return (Criteria) this; + } + + public Criteria andCreateUserEqualTo(String value) { + addCriterion("create_user =", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotEqualTo(String value) { + addCriterion("create_user <>", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThan(String value) { + addCriterion("create_user >", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThanOrEqualTo(String value) { + addCriterion("create_user >=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThan(String value) { + addCriterion("create_user <", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThanOrEqualTo(String value) { + addCriterion("create_user <=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLike(String value) { + addCriterion("create_user like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotLike(String value) { + addCriterion("create_user not like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserIn(List values) { + addCriterion("create_user in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotIn(List values) { + addCriterion("create_user not in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserBetween(String value1, String value2) { + addCriterion("create_user between", value1, value2, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotBetween(String value1, String value2) { + addCriterion("create_user not between", value1, value2, "createUser"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanLoadCase.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanLoadCase.java index ebe2afc8dc..070ff29856 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanLoadCase.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanLoadCase.java @@ -1,8 +1,9 @@ package io.metersphere.base.domain; -import java.io.Serializable; import lombok.Data; +import java.io.Serializable; + @Data public class TestPlanLoadCase implements Serializable { private String id; @@ -19,5 +20,7 @@ public class TestPlanLoadCase implements Serializable { private Long updateTime; + private String createUser; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanLoadCaseExample.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanLoadCaseExample.java index 7d946f4b7f..c77ea4d32c 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanLoadCaseExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanLoadCaseExample.java @@ -573,6 +573,76 @@ public class TestPlanLoadCaseExample { addCriterion("update_time not between", value1, value2, "updateTime"); return (Criteria) this; } + + public Criteria andCreateUserIsNull() { + addCriterion("create_user is null"); + return (Criteria) this; + } + + public Criteria andCreateUserIsNotNull() { + addCriterion("create_user is not null"); + return (Criteria) this; + } + + public Criteria andCreateUserEqualTo(String value) { + addCriterion("create_user =", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotEqualTo(String value) { + addCriterion("create_user <>", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThan(String value) { + addCriterion("create_user >", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThanOrEqualTo(String value) { + addCriterion("create_user >=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThan(String value) { + addCriterion("create_user <", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThanOrEqualTo(String value) { + addCriterion("create_user <=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLike(String value) { + addCriterion("create_user like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotLike(String value) { + addCriterion("create_user not like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserIn(List values) { + addCriterion("create_user in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotIn(List values) { + addCriterion("create_user not in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserBetween(String value1, String value2) { + addCriterion("create_user between", value1, value2, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotBetween(String value1, String value2) { + addCriterion("create_user not between", value1, value2, "createUser"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCase.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCase.java index 09307e26a6..cfe4a317d9 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCase.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCase.java @@ -1,8 +1,9 @@ package io.metersphere.base.domain; -import java.io.Serializable; import lombok.Data; +import java.io.Serializable; + @Data public class TestPlanTestCase implements Serializable { private String id; @@ -23,5 +24,7 @@ public class TestPlanTestCase implements Serializable { private String reportId; + private String createUser; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCaseExample.java b/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCaseExample.java index 42d4977edc..33e26b16ce 100644 --- a/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCaseExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/TestPlanTestCaseExample.java @@ -713,6 +713,76 @@ public class TestPlanTestCaseExample { addCriterion("report_id not between", value1, value2, "reportId"); return (Criteria) this; } + + public Criteria andCreateUserIsNull() { + addCriterion("create_user is null"); + return (Criteria) this; + } + + public Criteria andCreateUserIsNotNull() { + addCriterion("create_user is not null"); + return (Criteria) this; + } + + public Criteria andCreateUserEqualTo(String value) { + addCriterion("create_user =", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotEqualTo(String value) { + addCriterion("create_user <>", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThan(String value) { + addCriterion("create_user >", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserGreaterThanOrEqualTo(String value) { + addCriterion("create_user >=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThan(String value) { + addCriterion("create_user <", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLessThanOrEqualTo(String value) { + addCriterion("create_user <=", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserLike(String value) { + addCriterion("create_user like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotLike(String value) { + addCriterion("create_user not like", value, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserIn(List values) { + addCriterion("create_user in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotIn(List values) { + addCriterion("create_user not in", values, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserBetween(String value1, String value2) { + addCriterion("create_user between", value1, value2, "createUser"); + return (Criteria) this; + } + + public Criteria andCreateUserNotBetween(String value1, String value2) { + addCriterion("create_user not between", value1, value2, "createUser"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestCaseReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestCaseReportMapper.xml index 59a10f9bc0..2c134097ff 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestCaseReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestCaseReportMapper.xml @@ -6,6 +6,7 @@ + @@ -69,7 +70,7 @@ - id, name, start_time, end_time + id, `name`, start_time, end_time, create_user content @@ -123,10 +124,12 @@ - insert into test_case_report (id, name, start_time, - end_time, content) + insert into test_case_report (id, `name`, start_time, + end_time, create_user, content + ) values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{startTime,jdbcType=BIGINT}, - #{endTime,jdbcType=BIGINT}, #{content,jdbcType=LONGVARCHAR}) + #{endTime,jdbcType=BIGINT}, #{createUser,jdbcType=VARCHAR}, #{content,jdbcType=LONGVARCHAR} + ) insert into test_case_report @@ -135,7 +138,7 @@ id, - name, + `name`, start_time, @@ -143,6 +146,9 @@ end_time, + + create_user, + content, @@ -160,6 +166,9 @@ #{endTime,jdbcType=BIGINT}, + + #{createUser,jdbcType=VARCHAR}, + #{content,jdbcType=LONGVARCHAR}, @@ -178,7 +187,7 @@ id = #{record.id,jdbcType=VARCHAR}, - name = #{record.name,jdbcType=VARCHAR}, + `name` = #{record.name,jdbcType=VARCHAR}, start_time = #{record.startTime,jdbcType=BIGINT}, @@ -186,6 +195,9 @@ end_time = #{record.endTime,jdbcType=BIGINT}, + + create_user = #{record.createUser,jdbcType=VARCHAR}, + content = #{record.content,jdbcType=LONGVARCHAR}, @@ -197,9 +209,10 @@ update test_case_report set id = #{record.id,jdbcType=VARCHAR}, - name = #{record.name,jdbcType=VARCHAR}, + `name` = #{record.name,jdbcType=VARCHAR}, start_time = #{record.startTime,jdbcType=BIGINT}, end_time = #{record.endTime,jdbcType=BIGINT}, + create_user = #{record.createUser,jdbcType=VARCHAR}, content = #{record.content,jdbcType=LONGVARCHAR} @@ -208,9 +221,10 @@ update test_case_report set id = #{record.id,jdbcType=VARCHAR}, - name = #{record.name,jdbcType=VARCHAR}, + `name` = #{record.name,jdbcType=VARCHAR}, start_time = #{record.startTime,jdbcType=BIGINT}, - end_time = #{record.endTime,jdbcType=BIGINT} + end_time = #{record.endTime,jdbcType=BIGINT}, + create_user = #{record.createUser,jdbcType=VARCHAR} @@ -219,7 +233,7 @@ update test_case_report - name = #{name,jdbcType=VARCHAR}, + `name` = #{name,jdbcType=VARCHAR}, start_time = #{startTime,jdbcType=BIGINT}, @@ -227,6 +241,9 @@ end_time = #{endTime,jdbcType=BIGINT}, + + create_user = #{createUser,jdbcType=VARCHAR}, + content = #{content,jdbcType=LONGVARCHAR}, @@ -235,17 +252,19 @@ update test_case_report - set name = #{name,jdbcType=VARCHAR}, + set `name` = #{name,jdbcType=VARCHAR}, start_time = #{startTime,jdbcType=BIGINT}, end_time = #{endTime,jdbcType=BIGINT}, + create_user = #{createUser,jdbcType=VARCHAR}, content = #{content,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} update test_case_report - set name = #{name,jdbcType=VARCHAR}, + set `name` = #{name,jdbcType=VARCHAR}, start_time = #{startTime,jdbcType=BIGINT}, - end_time = #{endTime,jdbcType=BIGINT} + end_time = #{endTime,jdbcType=BIGINT}, + create_user = #{createUser,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestCaseReviewMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestCaseReviewMapper.xml index aad38c2b1c..972f84d6d9 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestCaseReviewMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestCaseReviewMapper.xml @@ -11,6 +11,7 @@ + @@ -74,7 +75,8 @@ - id, `name`, creator, `status`, create_time, update_time, end_time, project_id, tags + id, `name`, creator, `status`, create_time, update_time, end_time, project_id, tags, + create_user description @@ -131,11 +133,11 @@ insert into test_case_review (id, `name`, creator, `status`, create_time, update_time, end_time, project_id, tags, - description) + create_user, description) values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{creator,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{endTime,jdbcType=BIGINT}, #{projectId,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR}, - #{description,jdbcType=LONGVARCHAR}) + #{createUser,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR}) insert into test_case_review @@ -167,6 +169,9 @@ tags, + + create_user, + description, @@ -199,6 +204,9 @@ #{tags,jdbcType=VARCHAR}, + + #{createUser,jdbcType=VARCHAR}, + #{description,jdbcType=LONGVARCHAR}, @@ -240,6 +248,9 @@ tags = #{record.tags,jdbcType=VARCHAR}, + + create_user = #{record.createUser,jdbcType=VARCHAR}, + description = #{record.description,jdbcType=LONGVARCHAR}, @@ -259,6 +270,7 @@ end_time = #{record.endTime,jdbcType=BIGINT}, project_id = #{record.projectId,jdbcType=VARCHAR}, tags = #{record.tags,jdbcType=VARCHAR}, + create_user = #{record.createUser,jdbcType=VARCHAR}, description = #{record.description,jdbcType=LONGVARCHAR} @@ -274,7 +286,8 @@ update_time = #{record.updateTime,jdbcType=BIGINT}, end_time = #{record.endTime,jdbcType=BIGINT}, project_id = #{record.projectId,jdbcType=VARCHAR}, - tags = #{record.tags,jdbcType=VARCHAR} + tags = #{record.tags,jdbcType=VARCHAR}, + create_user = #{record.createUser,jdbcType=VARCHAR} @@ -306,6 +319,9 @@ tags = #{tags,jdbcType=VARCHAR}, + + create_user = #{createUser,jdbcType=VARCHAR}, + description = #{description,jdbcType=LONGVARCHAR}, @@ -322,6 +338,7 @@ end_time = #{endTime,jdbcType=BIGINT}, project_id = #{projectId,jdbcType=VARCHAR}, tags = #{tags,jdbcType=VARCHAR}, + create_user = #{createUser,jdbcType=VARCHAR}, description = #{description,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -334,7 +351,8 @@ update_time = #{updateTime,jdbcType=BIGINT}, end_time = #{endTime,jdbcType=BIGINT}, project_id = #{projectId,jdbcType=VARCHAR}, - tags = #{tags,jdbcType=VARCHAR} + tags = #{tags,jdbcType=VARCHAR}, + create_user = #{createUser,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestCaseReviewTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestCaseReviewTestCaseMapper.xml index e04fd76189..71ec423e60 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestCaseReviewTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestCaseReviewTestCaseMapper.xml @@ -10,6 +10,7 @@ + @@ -70,7 +71,7 @@ - id, review_id, case_id, `status`, `result`, reviewer, create_time, update_time + id, review_id, case_id, `status`, `result`, reviewer, create_time, update_time, create_user @@ -198,6 +207,9 @@ update_time = #{record.updateTime,jdbcType=BIGINT}, + + create_user = #{record.createUser,jdbcType=VARCHAR}, + @@ -212,7 +224,8 @@ `result` = #{record.result,jdbcType=VARCHAR}, reviewer = #{record.reviewer,jdbcType=VARCHAR}, create_time = #{record.createTime,jdbcType=BIGINT}, - update_time = #{record.updateTime,jdbcType=BIGINT} + update_time = #{record.updateTime,jdbcType=BIGINT}, + create_user = #{record.createUser,jdbcType=VARCHAR} @@ -241,6 +254,9 @@ update_time = #{updateTime,jdbcType=BIGINT}, + + create_user = #{createUser,jdbcType=VARCHAR}, + where id = #{id,jdbcType=VARCHAR} @@ -252,7 +268,8 @@ `result` = #{result,jdbcType=VARCHAR}, reviewer = #{reviewer,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=BIGINT}, - update_time = #{updateTime,jdbcType=BIGINT} + update_time = #{updateTime,jdbcType=BIGINT}, + create_user = #{createUser,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestPlanApiCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestPlanApiCaseMapper.xml index f16a82c637..119a39f576 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestPlanApiCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestPlanApiCaseMapper.xml @@ -9,6 +9,7 @@ + @@ -69,7 +70,8 @@ - id, test_plan_id, api_case_id, `status`, environment_id, create_time, update_time + id, test_plan_id, api_case_id, `status`, environment_id, create_time, update_time, + create_user @@ -188,6 +196,9 @@ update_time = #{record.updateTime,jdbcType=BIGINT}, + + create_user = #{record.createUser,jdbcType=VARCHAR}, + @@ -201,7 +212,8 @@ `status` = #{record.status,jdbcType=VARCHAR}, environment_id = #{record.environmentId,jdbcType=VARCHAR}, create_time = #{record.createTime,jdbcType=BIGINT}, - update_time = #{record.updateTime,jdbcType=BIGINT} + update_time = #{record.updateTime,jdbcType=BIGINT}, + create_user = #{record.createUser,jdbcType=VARCHAR} @@ -227,6 +239,9 @@ update_time = #{updateTime,jdbcType=BIGINT}, + + create_user = #{createUser,jdbcType=VARCHAR}, + where id = #{id,jdbcType=VARCHAR} @@ -237,7 +252,8 @@ `status` = #{status,jdbcType=VARCHAR}, environment_id = #{environmentId,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=BIGINT}, - update_time = #{updateTime,jdbcType=BIGINT} + update_time = #{updateTime,jdbcType=BIGINT}, + create_user = #{createUser,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestPlanApiScenarioMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestPlanApiScenarioMapper.xml index 9e6a517c29..1df118840a 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestPlanApiScenarioMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestPlanApiScenarioMapper.xml @@ -11,6 +11,7 @@ + @@ -75,7 +76,7 @@ id, test_plan_id, api_scenario_id, `status`, create_time, update_time, pass_rate, - last_result, report_id + last_result, report_id, create_user environment @@ -132,11 +133,11 @@ insert into test_plan_api_scenario (id, test_plan_id, api_scenario_id, `status`, create_time, update_time, pass_rate, last_result, report_id, - environment) + create_user, environment) values (#{id,jdbcType=VARCHAR}, #{testPlanId,jdbcType=VARCHAR}, #{apiScenarioId,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{passRate,jdbcType=VARCHAR}, #{lastResult,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, - #{environment,jdbcType=LONGVARCHAR}) + #{createUser,jdbcType=VARCHAR}, #{environment,jdbcType=LONGVARCHAR}) insert into test_plan_api_scenario @@ -168,6 +169,9 @@ report_id, + + create_user, + environment, @@ -200,6 +204,9 @@ #{reportId,jdbcType=VARCHAR}, + + #{createUser,jdbcType=VARCHAR}, + #{environment,jdbcType=LONGVARCHAR}, @@ -241,6 +248,9 @@ report_id = #{record.reportId,jdbcType=VARCHAR}, + + create_user = #{record.createUser,jdbcType=VARCHAR}, + environment = #{record.environment,jdbcType=LONGVARCHAR}, @@ -260,6 +270,7 @@ pass_rate = #{record.passRate,jdbcType=VARCHAR}, last_result = #{record.lastResult,jdbcType=VARCHAR}, report_id = #{record.reportId,jdbcType=VARCHAR}, + create_user = #{record.createUser,jdbcType=VARCHAR}, environment = #{record.environment,jdbcType=LONGVARCHAR} @@ -275,7 +286,8 @@ update_time = #{record.updateTime,jdbcType=BIGINT}, pass_rate = #{record.passRate,jdbcType=VARCHAR}, last_result = #{record.lastResult,jdbcType=VARCHAR}, - report_id = #{record.reportId,jdbcType=VARCHAR} + report_id = #{record.reportId,jdbcType=VARCHAR}, + create_user = #{record.createUser,jdbcType=VARCHAR} @@ -307,6 +319,9 @@ report_id = #{reportId,jdbcType=VARCHAR}, + + create_user = #{createUser,jdbcType=VARCHAR}, + environment = #{environment,jdbcType=LONGVARCHAR}, @@ -323,6 +338,7 @@ pass_rate = #{passRate,jdbcType=VARCHAR}, last_result = #{lastResult,jdbcType=VARCHAR}, report_id = #{reportId,jdbcType=VARCHAR}, + create_user = #{createUser,jdbcType=VARCHAR}, environment = #{environment,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -335,7 +351,8 @@ update_time = #{updateTime,jdbcType=BIGINT}, pass_rate = #{passRate,jdbcType=VARCHAR}, last_result = #{lastResult,jdbcType=VARCHAR}, - report_id = #{reportId,jdbcType=VARCHAR} + report_id = #{reportId,jdbcType=VARCHAR}, + create_user = #{createUser,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestPlanLoadCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestPlanLoadCaseMapper.xml index 4fb8225c0f..6b4975ef5f 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestPlanLoadCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestPlanLoadCaseMapper.xml @@ -9,6 +9,7 @@ + @@ -69,7 +70,8 @@ - id, test_plan_id, load_case_id, load_report_id, `status`, create_time, update_time + id, test_plan_id, load_case_id, load_report_id, `status`, create_time, update_time, + create_user @@ -188,6 +196,9 @@ update_time = #{record.updateTime,jdbcType=BIGINT}, + + create_user = #{record.createUser,jdbcType=VARCHAR}, + @@ -201,7 +212,8 @@ load_report_id = #{record.loadReportId,jdbcType=VARCHAR}, `status` = #{record.status,jdbcType=VARCHAR}, create_time = #{record.createTime,jdbcType=BIGINT}, - update_time = #{record.updateTime,jdbcType=BIGINT} + update_time = #{record.updateTime,jdbcType=BIGINT}, + create_user = #{record.createUser,jdbcType=VARCHAR} @@ -227,6 +239,9 @@ update_time = #{updateTime,jdbcType=BIGINT}, + + create_user = #{createUser,jdbcType=VARCHAR}, + where id = #{id,jdbcType=VARCHAR} @@ -237,7 +252,8 @@ load_report_id = #{loadReportId,jdbcType=VARCHAR}, `status` = #{status,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=BIGINT}, - update_time = #{updateTime,jdbcType=BIGINT} + update_time = #{updateTime,jdbcType=BIGINT}, + create_user = #{createUser,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestPlanMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestPlanMapper.xml index 6103aa3e95..c3dd721c50 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestPlanMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestPlanMapper.xml @@ -20,7 +20,7 @@ - + @@ -140,20 +140,20 @@ - insert into test_plan (id, workspace_id, report_id, - `name`, description, `status`, - stage, principal, test_case_match_rule, - executor_match_rule, create_time, update_time, - actual_end_time, planned_start_time, planned_end_time, - actual_start_time, creator, project_id, - execution_times, tags) - values (#{id,jdbcType=VARCHAR}, #{workspaceId,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, - #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, - #{stage,jdbcType=VARCHAR}, #{principal,jdbcType=VARCHAR}, #{testCaseMatchRule,jdbcType=VARCHAR}, - #{executorMatchRule,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, - #{actualEndTime,jdbcType=BIGINT}, #{plannedStartTime,jdbcType=BIGINT}, #{plannedEndTime,jdbcType=BIGINT}, - #{actualStartTime,jdbcType=BIGINT}, #{creator,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, - #{executionTimes,jdbcType=INTEGER}, #{tags,jdbcType=LONGVARCHAR}) + insert into test_plan (id, workspace_id, report_id, + `name`, description, `status`, + stage, principal, test_case_match_rule, + executor_match_rule, create_time, update_time, + actual_end_time, planned_start_time, planned_end_time, + actual_start_time, creator, project_id, + execution_times, tags) + values (#{id,jdbcType=VARCHAR}, #{workspaceId,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, + #{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, + #{stage,jdbcType=VARCHAR}, #{principal,jdbcType=VARCHAR}, #{testCaseMatchRule,jdbcType=VARCHAR}, + #{executorMatchRule,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, + #{actualEndTime,jdbcType=BIGINT}, #{plannedStartTime,jdbcType=BIGINT}, #{plannedEndTime,jdbcType=BIGINT}, + #{actualStartTime,jdbcType=BIGINT}, #{creator,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, + #{executionTimes,jdbcType=INTEGER}, #{tags,jdbcType=LONGVARCHAR}) insert into test_plan @@ -357,8 +357,8 @@ - update test_plan - set id = #{record.id,jdbcType=VARCHAR}, + update test_plan + set id = #{record.id,jdbcType=VARCHAR}, workspace_id = #{record.workspaceId,jdbcType=VARCHAR}, report_id = #{record.reportId,jdbcType=VARCHAR}, `name` = #{record.name,jdbcType=VARCHAR}, @@ -378,13 +378,13 @@ project_id = #{record.projectId,jdbcType=VARCHAR}, execution_times = #{record.executionTimes,jdbcType=INTEGER}, tags = #{record.tags,jdbcType=LONGVARCHAR} - + - update test_plan - set id = #{record.id,jdbcType=VARCHAR}, + update test_plan + set id = #{record.id,jdbcType=VARCHAR}, workspace_id = #{record.workspaceId,jdbcType=VARCHAR}, report_id = #{record.reportId,jdbcType=VARCHAR}, `name` = #{record.name,jdbcType=VARCHAR}, @@ -403,7 +403,7 @@ creator = #{record.creator,jdbcType=VARCHAR}, project_id = #{record.projectId,jdbcType=VARCHAR}, execution_times = #{record.executionTimes,jdbcType=INTEGER} - + @@ -471,48 +471,48 @@ where id = #{id,jdbcType=VARCHAR} - update test_plan - set workspace_id = #{workspaceId,jdbcType=VARCHAR}, - report_id = #{reportId,jdbcType=VARCHAR}, - `name` = #{name,jdbcType=VARCHAR}, - description = #{description,jdbcType=VARCHAR}, - `status` = #{status,jdbcType=VARCHAR}, - stage = #{stage,jdbcType=VARCHAR}, - principal = #{principal,jdbcType=VARCHAR}, - test_case_match_rule = #{testCaseMatchRule,jdbcType=VARCHAR}, - executor_match_rule = #{executorMatchRule,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=BIGINT}, - update_time = #{updateTime,jdbcType=BIGINT}, - actual_end_time = #{actualEndTime,jdbcType=BIGINT}, - planned_start_time = #{plannedStartTime,jdbcType=BIGINT}, - planned_end_time = #{plannedEndTime,jdbcType=BIGINT}, - actual_start_time = #{actualStartTime,jdbcType=BIGINT}, - creator = #{creator,jdbcType=VARCHAR}, - project_id = #{projectId,jdbcType=VARCHAR}, - execution_times = #{executionTimes,jdbcType=INTEGER}, - tags = #{tags,jdbcType=LONGVARCHAR} - where id = #{id,jdbcType=VARCHAR} + update test_plan + set workspace_id = #{workspaceId,jdbcType=VARCHAR}, + report_id = #{reportId,jdbcType=VARCHAR}, + `name` = #{name,jdbcType=VARCHAR}, + description = #{description,jdbcType=VARCHAR}, + `status` = #{status,jdbcType=VARCHAR}, + stage = #{stage,jdbcType=VARCHAR}, + principal = #{principal,jdbcType=VARCHAR}, + test_case_match_rule = #{testCaseMatchRule,jdbcType=VARCHAR}, + executor_match_rule = #{executorMatchRule,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=BIGINT}, + actual_end_time = #{actualEndTime,jdbcType=BIGINT}, + planned_start_time = #{plannedStartTime,jdbcType=BIGINT}, + planned_end_time = #{plannedEndTime,jdbcType=BIGINT}, + actual_start_time = #{actualStartTime,jdbcType=BIGINT}, + creator = #{creator,jdbcType=VARCHAR}, + project_id = #{projectId,jdbcType=VARCHAR}, + execution_times = #{executionTimes,jdbcType=INTEGER}, + tags = #{tags,jdbcType=LONGVARCHAR} + where id = #{id,jdbcType=VARCHAR} - update test_plan - set workspace_id = #{workspaceId,jdbcType=VARCHAR}, - report_id = #{reportId,jdbcType=VARCHAR}, - `name` = #{name,jdbcType=VARCHAR}, - description = #{description,jdbcType=VARCHAR}, - `status` = #{status,jdbcType=VARCHAR}, - stage = #{stage,jdbcType=VARCHAR}, - principal = #{principal,jdbcType=VARCHAR}, - test_case_match_rule = #{testCaseMatchRule,jdbcType=VARCHAR}, - executor_match_rule = #{executorMatchRule,jdbcType=VARCHAR}, - create_time = #{createTime,jdbcType=BIGINT}, - update_time = #{updateTime,jdbcType=BIGINT}, - actual_end_time = #{actualEndTime,jdbcType=BIGINT}, - planned_start_time = #{plannedStartTime,jdbcType=BIGINT}, - planned_end_time = #{plannedEndTime,jdbcType=BIGINT}, - actual_start_time = #{actualStartTime,jdbcType=BIGINT}, - creator = #{creator,jdbcType=VARCHAR}, - project_id = #{projectId,jdbcType=VARCHAR}, - execution_times = #{executionTimes,jdbcType=INTEGER} - where id = #{id,jdbcType=VARCHAR} + update test_plan + set workspace_id = #{workspaceId,jdbcType=VARCHAR}, + report_id = #{reportId,jdbcType=VARCHAR}, + `name` = #{name,jdbcType=VARCHAR}, + description = #{description,jdbcType=VARCHAR}, + `status` = #{status,jdbcType=VARCHAR}, + stage = #{stage,jdbcType=VARCHAR}, + principal = #{principal,jdbcType=VARCHAR}, + test_case_match_rule = #{testCaseMatchRule,jdbcType=VARCHAR}, + executor_match_rule = #{executorMatchRule,jdbcType=VARCHAR}, + create_time = #{createTime,jdbcType=BIGINT}, + update_time = #{updateTime,jdbcType=BIGINT}, + actual_end_time = #{actualEndTime,jdbcType=BIGINT}, + planned_start_time = #{plannedStartTime,jdbcType=BIGINT}, + planned_end_time = #{plannedEndTime,jdbcType=BIGINT}, + actual_start_time = #{actualStartTime,jdbcType=BIGINT}, + creator = #{creator,jdbcType=VARCHAR}, + project_id = #{projectId,jdbcType=VARCHAR}, + execution_times = #{executionTimes,jdbcType=INTEGER} + where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/TestPlanTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/TestPlanTestCaseMapper.xml index 7964d2f188..29978648a0 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/TestPlanTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/TestPlanTestCaseMapper.xml @@ -11,6 +11,7 @@ + @@ -76,7 +77,8 @@ - id, plan_id, case_id, executor, `status`, remark, create_time, update_time, report_id + id, plan_id, case_id, executor, `status`, remark, create_time, update_time, report_id, + create_user results, issues, actual_result @@ -133,13 +135,13 @@ insert into test_plan_test_case (id, plan_id, case_id, executor, `status`, remark, create_time, update_time, report_id, - results, issues, actual_result - ) + create_user, results, issues, + actual_result) values (#{id,jdbcType=VARCHAR}, #{planId,jdbcType=VARCHAR}, #{caseId,jdbcType=VARCHAR}, #{executor,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{reportId,jdbcType=VARCHAR}, - #{results,jdbcType=LONGVARCHAR}, #{issues,jdbcType=LONGVARCHAR}, #{actualResult,jdbcType=LONGVARCHAR} - ) + #{createUser,jdbcType=VARCHAR}, #{results,jdbcType=LONGVARCHAR}, #{issues,jdbcType=LONGVARCHAR}, + #{actualResult,jdbcType=LONGVARCHAR}) insert into test_plan_test_case @@ -171,6 +173,9 @@ report_id, + + create_user, + results, @@ -209,6 +214,9 @@ #{reportId,jdbcType=VARCHAR}, + + #{createUser,jdbcType=VARCHAR}, + #{results,jdbcType=LONGVARCHAR}, @@ -256,6 +264,9 @@ report_id = #{record.reportId,jdbcType=VARCHAR}, + + create_user = #{record.createUser,jdbcType=VARCHAR}, + results = #{record.results,jdbcType=LONGVARCHAR}, @@ -281,6 +292,7 @@ create_time = #{record.createTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT}, report_id = #{record.reportId,jdbcType=VARCHAR}, + create_user = #{record.createUser,jdbcType=VARCHAR}, results = #{record.results,jdbcType=LONGVARCHAR}, issues = #{record.issues,jdbcType=LONGVARCHAR}, actual_result = #{record.actualResult,jdbcType=LONGVARCHAR} @@ -298,7 +310,8 @@ remark = #{record.remark,jdbcType=VARCHAR}, create_time = #{record.createTime,jdbcType=BIGINT}, update_time = #{record.updateTime,jdbcType=BIGINT}, - report_id = #{record.reportId,jdbcType=VARCHAR} + report_id = #{record.reportId,jdbcType=VARCHAR}, + create_user = #{record.createUser,jdbcType=VARCHAR} @@ -330,6 +343,9 @@ report_id = #{reportId,jdbcType=VARCHAR}, + + create_user = #{createUser,jdbcType=VARCHAR}, + results = #{results,jdbcType=LONGVARCHAR}, @@ -352,6 +368,7 @@ create_time = #{createTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT}, report_id = #{reportId,jdbcType=VARCHAR}, + create_user = #{createUser,jdbcType=VARCHAR}, results = #{results,jdbcType=LONGVARCHAR}, issues = #{issues,jdbcType=LONGVARCHAR}, actual_result = #{actualResult,jdbcType=LONGVARCHAR} @@ -366,7 +383,8 @@ remark = #{remark,jdbcType=VARCHAR}, create_time = #{createTime,jdbcType=BIGINT}, update_time = #{updateTime,jdbcType=BIGINT}, - report_id = #{reportId,jdbcType=VARCHAR} + report_id = #{reportId,jdbcType=VARCHAR}, + create_user = #{createUser,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/commons/constants/OperLogConstants.java b/backend/src/main/java/io/metersphere/commons/constants/OperLogConstants.java index 7bc995bc54..e5336757c2 100644 --- a/backend/src/main/java/io/metersphere/commons/constants/OperLogConstants.java +++ b/backend/src/main/java/io/metersphere/commons/constants/OperLogConstants.java @@ -1,5 +1,5 @@ package io.metersphere.commons.constants; public enum OperLogConstants { - CREATE, DELETE, GC, RESTORE, DEBUG, UPDATE, BATCH_DEL, BATCH_UPDATE, BATCH_ADD, BATCH_RESTORE, BATCH_GC, IMPORT, EXPORT, ASSOCIATE_CASE, REVIEW, COPY, EXECUTE, SHARE, LOGIN, CREATE_PRE_TEST, OTHER + CREATE, DELETE, GC, RESTORE, DEBUG, UPDATE, BATCH_DEL, BATCH_UPDATE, BATCH_ADD, BATCH_RESTORE, BATCH_GC, IMPORT, EXPORT, ASSOCIATE_CASE, UN_ASSOCIATE_CASE, REVIEW, COPY, EXECUTE, SHARE, LOGIN, CREATE_PRE_TEST, OTHER } diff --git a/backend/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java b/backend/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java index 83f5b345b5..6883616b10 100644 --- a/backend/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java +++ b/backend/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java @@ -12,6 +12,7 @@ import io.metersphere.log.utils.dff.JsonDiff; import io.metersphere.log.utils.dff.Operation; import io.metersphere.log.vo.DetailColumn; import io.metersphere.log.vo.OperatingLogDetails; +import io.metersphere.log.vo.StatusReference; import org.apache.commons.lang3.StringUtils; import java.lang.reflect.Field; @@ -49,12 +50,18 @@ public class ReflexObjectUtil { try { if (columns.containsKey(f.getName())) { Object val = f.get(obj); + if (val != null && StatusReference.statusMap.containsKey(val.toString())) { + val = StatusReference.statusMap.get(val.toString()); + } DetailColumn column = new DetailColumn(columns.get(f.getName()), f.getName(), val, ""); if (dffColumns.contains(f.getName())) { column.setDepthDff(true); if (val != null) { JSONObject object = JSONObject.parseObject(val.toString()); - String pretty = JSON.toJSONString(object, SerializerFeature.PrettyFormat, SerializerFeature.WriteMapNullValue, SerializerFeature.WriteDateUseDateFormat); + String pretty = JSON.toJSONString(object, + SerializerFeature.PrettyFormat, + SerializerFeature.WriteMapNullValue, + SerializerFeature.WriteDateUseDateFormat); column.setOriginalValue(pretty); } } @@ -65,8 +72,6 @@ public class ReflexObjectUtil { } } } - - List keys = columns.keySet().stream().collect(Collectors.toList()); ReflexObjectUtil.order(keys, columnList); return columnList; diff --git a/backend/src/main/java/io/metersphere/log/vo/StatusReference.java b/backend/src/main/java/io/metersphere/log/vo/StatusReference.java new file mode 100644 index 0000000000..c4c30a8eca --- /dev/null +++ b/backend/src/main/java/io/metersphere/log/vo/StatusReference.java @@ -0,0 +1,27 @@ +package io.metersphere.log.vo; + +import java.util.LinkedHashMap; +import java.util.Map; + +public class StatusReference { + public static Map statusMap = new LinkedHashMap<>(); + + static { + statusMap.clear(); + statusMap.put("Prepare", "未开始"); + statusMap.put("Underway", "进行中"); + statusMap.put("Completed", "已完成"); + statusMap.put("Finished", "已结束"); + statusMap.put("Saved", "已保存"); + statusMap.put("Starting", "已开始"); + statusMap.put("Running", "运行中"); + statusMap.put("Error", "异常"); + statusMap.put("Pass", "通过"); + statusMap.put("UnPass", "未通过"); + statusMap.put("smoke", "冒烟测试"); + statusMap.put("system", "系统测试"); + statusMap.put("regression", "回归测试"); + + } + +} diff --git a/backend/src/main/java/io/metersphere/log/vo/track/TestCaseReference.java b/backend/src/main/java/io/metersphere/log/vo/track/TestCaseReference.java index 6809de9a57..0e9a7b2254 100644 --- a/backend/src/main/java/io/metersphere/log/vo/track/TestCaseReference.java +++ b/backend/src/main/java/io/metersphere/log/vo/track/TestCaseReference.java @@ -12,7 +12,6 @@ public class TestCaseReference { testCaseColumns.put("createUser", "创建人"); testCaseColumns.put("nodePath", "用例模块"); testCaseColumns.put("type", "用例类型"); - testCaseColumns.put("maintainer", "责任人"); testCaseColumns.put("principal", "责任人"); testCaseColumns.put("priority", "用例等级"); testCaseColumns.put("method", "请求类型"); diff --git a/backend/src/main/java/io/metersphere/log/vo/track/TestCaseReviewReference.java b/backend/src/main/java/io/metersphere/log/vo/track/TestCaseReviewReference.java new file mode 100644 index 0000000000..a624b672af --- /dev/null +++ b/backend/src/main/java/io/metersphere/log/vo/track/TestCaseReviewReference.java @@ -0,0 +1,22 @@ +package io.metersphere.log.vo.track; + +import java.util.LinkedHashMap; +import java.util.Map; + +public class TestCaseReviewReference { + public static Map testCaseReviewColumns = new LinkedHashMap<>(); + public static Map commentReviewColumns = new LinkedHashMap<>(); + + static { + testCaseReviewColumns.clear(); + commentReviewColumns.clear(); + testCaseReviewColumns.put("name", "用例名称"); + testCaseReviewColumns.put("createUser", "创建人"); + testCaseReviewColumns.put("status", "状态"); + testCaseReviewColumns.put("tags", "标签"); + testCaseReviewColumns.put("description", "描述"); + + commentReviewColumns.put("author","评论人"); + commentReviewColumns.put("description","评论内容"); + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/log/vo/track/TestPlanReference.java b/backend/src/main/java/io/metersphere/log/vo/track/TestPlanReference.java new file mode 100644 index 0000000000..c5fdac4522 --- /dev/null +++ b/backend/src/main/java/io/metersphere/log/vo/track/TestPlanReference.java @@ -0,0 +1,41 @@ +package io.metersphere.log.vo.track; + +import java.util.LinkedHashMap; +import java.util.Map; + +public class TestPlanReference { + + public static Map testPlanColumns = new LinkedHashMap<>(); + public static Map reportColumns = new LinkedHashMap<>(); + public static Map issuesColumns = new LinkedHashMap<>(); + + static { + testPlanColumns.clear(); + reportColumns.clear(); + issuesColumns.clear(); + testPlanColumns.put("name", "用例名称"); + testPlanColumns.put("creator", "创建人"); + testPlanColumns.put("principal", "责任人"); + testPlanColumns.put("status", "状态"); + testPlanColumns.put("stage", "测试阶段"); + testPlanColumns.put("tags", "标签"); + testPlanColumns.put("plannedStartTime", "计划开始时间"); + testPlanColumns.put("plannedEndTime", "计划结束时间"); + testPlanColumns.put("description", "描述"); + + reportColumns.put("name", "名称"); + reportColumns.put("startTime", "开始时间"); + reportColumns.put("endTime", "结束时间"); + + // 缺陷管理 + issuesColumns.put("title","缺陷标题"); + issuesColumns.put("status","缺陷状态"); + issuesColumns.put("platform","平台"); + issuesColumns.put("creator","创建人"); + issuesColumns.put("reporter","处理人"); + issuesColumns.put("custom_fields","自定义字段"); + // 深度处理字段 + issuesColumns.put("ms-dff-col", "custom_fields"); + + } +} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/track/controller/IssuesController.java b/backend/src/main/java/io/metersphere/track/controller/IssuesController.java index 54db197ede..63bad01904 100644 --- a/backend/src/main/java/io/metersphere/track/controller/IssuesController.java +++ b/backend/src/main/java/io/metersphere/track/controller/IssuesController.java @@ -5,8 +5,10 @@ import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.Issues; import io.metersphere.base.domain.IssuesDao; import io.metersphere.base.domain.IssuesWithBLOBs; +import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; +import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.track.issue.domain.PlatformUser; import io.metersphere.track.issue.domain.ZentaoBuild; import io.metersphere.track.request.testcase.IssuesRequest; @@ -31,11 +33,13 @@ public class IssuesController { } @PostMapping("/add") + @MsAuditLog(module = "track_bug", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#issuesRequest)", msClass = IssuesService.class) public void addIssues(@RequestBody IssuesUpdateRequest issuesRequest) { issuesService.addIssues(issuesRequest); } @PostMapping("/update") + @MsAuditLog(module = "track_bug", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#issuesRequest.id)", content = "#msClass.getLogDetails(#issuesRequest.id)", msClass = IssuesService.class) public void updateIssues(@RequestBody IssuesUpdateRequest issuesRequest) { issuesService.updateIssues(issuesRequest); } @@ -56,11 +60,13 @@ public class IssuesController { } @PostMapping("/delete") + @MsAuditLog(module = "track_bug", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#request.id)", msClass = IssuesService.class) public void deleteIssue(@RequestBody IssuesRequest request) { issuesService.deleteIssue(request); } @GetMapping("/delete/{id}") + @MsAuditLog(module = "track_bug", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = IssuesService.class) public void delete(@PathVariable String id) { issuesService.delete(id); } diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseCommentController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseCommentController.java index 5456ee976c..32d361585b 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseCommentController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseCommentController.java @@ -1,12 +1,18 @@ package io.metersphere.track.controller; +import io.metersphere.commons.constants.OperLogConstants; +import io.metersphere.commons.constants.RoleConstants; +import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.track.dto.TestCaseCommentDTO; import io.metersphere.track.request.testreview.SaveCommentRequest; import io.metersphere.track.service.TestCaseCommentService; +import org.apache.shiro.authz.annotation.Logical; +import org.apache.shiro.authz.annotation.RequiresRoles; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; +import java.util.UUID; @RequestMapping("/test/case/comment") @RestController @@ -16,7 +22,9 @@ public class TestCaseCommentController { private TestCaseCommentService testCaseCommentService; @PostMapping("/save") + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseCommentService.class) public void saveComment(@RequestBody SaveCommentRequest request) { + request.setId(UUID.randomUUID().toString()); testCaseCommentService.saveComment(request); } @@ -26,11 +34,14 @@ public class TestCaseCommentController { } @GetMapping("/delete/{commentId}") + @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#commentId)", msClass = TestCaseCommentService.class) public void deleteComment(@PathVariable String commentId) { testCaseCommentService.delete(commentId); } @PostMapping("/edit") + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#request.id)", content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseCommentService.class) public void editComment(@RequestBody SaveCommentRequest request) { testCaseCommentService.edit(request); } diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseReportController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseReportController.java index b90379c19f..919b1f3f01 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseReportController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseReportController.java @@ -1,7 +1,9 @@ package io.metersphere.track.controller; import io.metersphere.base.domain.TestCaseReport; +import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.RoleConstants; +import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.track.request.testCaseReport.CreateReportRequest; import io.metersphere.track.service.TestCaseReportService; import org.apache.shiro.authz.annotation.Logical; @@ -10,6 +12,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; +import java.util.UUID; @RequestMapping("/case/report") @RestController @@ -30,18 +33,22 @@ public class TestCaseReportController { @PostMapping("/add") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.CREATE, content = "#msClass.getLogDetails(#request.id)", msClass = TestCaseReportService.class) public String addByTemplateId(@RequestBody CreateReportRequest request) { + request.setId(UUID.randomUUID().toString()); return testCaseReportService.addTestCaseReportByTemplateId(request); } @PostMapping("/edit") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#TestCaseReport.id)", content = "#msClass.getLogDetails(#TestCaseReport.id)", msClass = TestCaseReportService.class) public void edit(@RequestBody TestCaseReport TestCaseReport) { testCaseReportService.editTestCaseReport(TestCaseReport); } @PostMapping("/delete/{id}") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestCaseReportService.class) public int delete(@PathVariable String id) { return testCaseReportService.deleteTestCaseReport(id); } diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java index a2e3b0daea..ee86a0bb77 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseReviewController.java @@ -5,10 +5,12 @@ import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.Project; import io.metersphere.base.domain.TestCaseReview; import io.metersphere.base.domain.User; +import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.service.CheckPermissionService; import io.metersphere.track.dto.TestCaseReviewDTO; import io.metersphere.track.dto.TestReviewDTOWithMetric; @@ -24,6 +26,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; +import java.util.UUID; @RequestMapping("/test/case/review") @RestController @@ -45,7 +48,9 @@ public class TestCaseReviewController { @PostMapping("/save") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.CREATE, title = "#reviewRequest.name", content = "#msClass.getLogDetails(#reviewRequest.id)", msClass = TestCaseReviewService.class) public String saveCaseReview(@RequestBody SaveTestCaseReviewRequest reviewRequest) { + reviewRequest.setId(UUID.randomUUID().toString()); return testCaseReviewService.saveTestCaseReview(reviewRequest); } @@ -68,12 +73,14 @@ public class TestCaseReviewController { @PostMapping("/edit") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#testCaseReview.id)", title = "#testCaseReview.name", content = "#msClass.getLogDetails(#testCaseReview.id)", msClass = TestCaseReviewService.class) public String editCaseReview(@RequestBody SaveTestCaseReviewRequest testCaseReview) { return testCaseReviewService.editCaseReview(testCaseReview); } @GetMapping("/delete/{reviewId}") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#reviewId)", msClass = TestCaseReviewService.class) public void deleteCaseReview(@PathVariable String reviewId) { checkPermissionService.checkTestReviewOwner(reviewId); testCaseReviewService.deleteCaseReview(reviewId); @@ -85,6 +92,7 @@ public class TestCaseReviewController { } @PostMapping("/relevance") + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.ASSOCIATE_CASE, content = "#msClass.getLogDetails(#request)", msClass = TestCaseReviewService.class) public void testReviewRelevance(@RequestBody ReviewRelevanceRequest request) { testCaseReviewService.testReviewRelevance(request); } diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanApiCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanApiCaseController.java index 4784c5d1c3..587277abe1 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanApiCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanApiCaseController.java @@ -5,9 +5,11 @@ import com.github.pagehelper.PageHelper; import io.metersphere.api.dto.definition.ApiTestCaseDTO; import io.metersphere.api.dto.definition.ApiTestCaseRequest; import io.metersphere.api.dto.definition.TestPlanApiCaseDTO; +import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; +import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest; import io.metersphere.track.service.TestPlanApiCaseService; import org.apache.shiro.authz.annotation.Logical; @@ -43,18 +45,21 @@ public class TestPlanApiCaseController { @GetMapping("/delete/{id}") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestPlanApiCaseService.class) public int deleteTestCase(@PathVariable String id) { return testPlanApiCaseService.delete(id); } @PostMapping("/batch/delete") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanApiCaseService.class) public void deleteApiCaseBath(@RequestBody TestPlanApiCaseBatchRequest request) { testPlanApiCaseService.deleteApiCaseBath(request); } @PostMapping("/batch/update/env") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.batchLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanApiCaseService.class) public void batchUpdateEnv(@RequestBody TestPlanApiCaseBatchRequest request) { testPlanApiCaseService.batchUpdateEnv(request); } diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java index 1d9dd6845a..565873e5ee 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java @@ -4,10 +4,12 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.Project; import io.metersphere.base.domain.TestPlan; +import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.service.CheckPermissionService; import io.metersphere.track.dto.TestCaseReportMetricDTO; import io.metersphere.track.dto.TestPlanDTO; @@ -25,6 +27,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; +import java.util.UUID; @RequestMapping("/test/plan") @RestController @@ -84,19 +87,23 @@ public class TestPlanController { @PostMapping("/add") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.CREATE, title = "#testPlan.name", content = "#msClass.getLogDetails(#testPlan.id)", msClass = TestPlanService.class) public String addTestPlan(@RequestBody AddTestPlanRequest testPlan) { + testPlan.setId(UUID.randomUUID().toString()); return testPlanService.addTestPlan(testPlan); } @PostMapping("/edit") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#testPlanDTO.id)", content = "#msClass.getLogDetails(#testPlanDTO.id)", msClass = TestPlanService.class) public String editTestPlan(@RequestBody TestPlanDTO testPlanDTO) { return testPlanService.editTestPlan(testPlanDTO, true); } @PostMapping("/edit/status/{planId}") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#planId)", content = "#msClass.getLogDetails(#planId)", msClass = TestPlanService.class) public void editTestPlanStatus(@PathVariable String planId) { checkPermissionService.checkTestPlanOwner(planId); testPlanService.editTestPlanStatus(planId); @@ -104,12 +111,14 @@ public class TestPlanController { @PostMapping("/delete/{testPlanId}") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#testPlanId)", msClass = TestPlanService.class) public int deleteTestPlan(@PathVariable String testPlanId) { checkPermissionService.checkTestPlanOwner(testPlanId); return testPlanService.deleteTestPlan(testPlanId); } @PostMapping("/relevance") + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.ASSOCIATE_CASE, content = "#msClass.getLogDetails(#request)", msClass = TestPlanService.class) public void testPlanRelevance(@RequestBody PlanCaseRelevanceRequest request) { testPlanService.testPlanRelevance(request); } diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanLoadCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanLoadCaseController.java index 2d20a42597..295426a970 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanLoadCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanLoadCaseController.java @@ -4,8 +4,10 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.LoadTest; import io.metersphere.base.domain.TestPlanLoadCase; +import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; +import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.performance.request.RunTestPlanRequest; import io.metersphere.track.dto.TestPlanLoadCaseDTO; import io.metersphere.track.request.testplan.LoadCaseReportBatchRequest; @@ -32,6 +34,7 @@ public class TestPlanLoadCaseController { } @PostMapping("/relevance") + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.ASSOCIATE_CASE, content = "#msClass.getLogDetails(#request.caseIds,#request.testPlanId)", msClass = TestPlanLoadCaseService.class) public void relevanceCase(@RequestBody LoadCaseRequest request) { testPlanLoadCaseService.relevanceCase(request); } @@ -48,16 +51,19 @@ public class TestPlanLoadCaseController { } @GetMapping("/delete/{id}") + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestPlanLoadCaseService.class) public void delete(@PathVariable String id) { testPlanLoadCaseService.delete(id); } @PostMapping("/run") + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.testPlanLoadId)", msClass = TestPlanLoadCaseService.class) public String run(@RequestBody RunTestPlanRequest request) { return testPlanLoadCaseService.run(request); } @PostMapping("/run/batch") + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.EXECUTE, content = "#msClass.getRunLogDetails(#request.requests)", msClass = TestPlanLoadCaseService.class) public void runBatch(@RequestBody RunBatchTestPlanRequest request) { testPlanLoadCaseService.runBatch(request); } @@ -68,16 +74,19 @@ public class TestPlanLoadCaseController { } @PostMapping("/batch/delete") + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanLoadCaseService.class) public void batchDelete(@RequestBody LoadCaseReportBatchRequest request) { testPlanLoadCaseService.batchDelete(request); } @PostMapping("/update") + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#testPlanLoadCase.id)", msClass = TestPlanLoadCaseService.class) public void update(@RequestBody TestPlanLoadCase testPlanLoadCase) { testPlanLoadCaseService.update(testPlanLoadCase); } @PostMapping("/update/api") + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#testPlanLoadCase.id)", msClass = TestPlanLoadCaseService.class) public void updateByApi(@RequestBody TestPlanLoadCase testPlanLoadCase) { testPlanLoadCaseService.updateByApi(testPlanLoadCase); } diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanReportController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanReportController.java index aa72e6f0cd..b0888e6b93 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanReportController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanReportController.java @@ -3,10 +3,12 @@ package io.metersphere.track.controller; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.TestPlanReport; +import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.ReportTriggerMode; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.track.dto.TestPlanReportDTO; import io.metersphere.track.request.report.QueryTestPlanReportRequest; import io.metersphere.track.request.report.TestPlanReportSaveRequest; @@ -48,6 +50,7 @@ public class TestPlanReportController { } @PostMapping("/delete") + @MsAuditLog(module = "track_report", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#testPlanReportIdList)", msClass = TestPlanReportService.class) public void delete(@RequestBody List testPlanReportIdList) { testPlanReportService.delete(testPlanReportIdList); } diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanScenarioCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanScenarioCaseController.java index bc8d64616b..a1f497bdd5 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanScenarioCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanScenarioCaseController.java @@ -4,10 +4,12 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.api.dto.automation.*; import io.metersphere.commons.constants.ApiRunMode; +import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.track.dto.RelevanceScenarioRequest; import io.metersphere.track.request.testcase.TestPlanScenarioCaseBatchRequest; import io.metersphere.track.service.TestPlanScenarioCaseService; @@ -45,23 +47,27 @@ public class TestPlanScenarioCaseController { @GetMapping("/delete/{id}") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestPlanScenarioCaseService.class) public int deleteTestCase(@PathVariable String id) { return testPlanScenarioCaseService.delete(id); } @PostMapping("/batch/delete") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanScenarioCaseService.class) public void deleteApiCaseBath(@RequestBody TestPlanScenarioCaseBatchRequest request) { testPlanScenarioCaseService.deleteApiCaseBath(request); } @PostMapping(value = "/run") + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.planCaseIds)", msClass = TestPlanScenarioCaseService.class) public String run(@RequestBody RunTestPlanScenarioRequest request) { request.setExecuteType(ExecuteType.Completed.name()); return testPlanScenarioCaseService.run(request); } @PostMapping(value = "/jenkins/run") + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.EXECUTE, content = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanScenarioCaseService.class) public String runByRun(@RequestBody RunTestPlanScenarioRequest request) { request.setExecuteType(ExecuteType.Saved.name()); request.setTriggerMode(ApiRunMode.API.name()); @@ -71,6 +77,7 @@ public class TestPlanScenarioCaseController { @PostMapping("/batch/update/env") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.batchLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanScenarioCaseService.class) public void batchUpdateEnv(@RequestBody RelevanceScenarioRequest request) { testPlanScenarioCaseService.batchUpdateEnv(request); } diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java index 2f18a62c8f..4f57a3b22f 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanTestCaseController.java @@ -3,9 +3,11 @@ package io.metersphere.track.controller; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.TestPlanTestCaseWithBLOBs; +import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; +import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.track.dto.TestPlanCaseDTO; import io.metersphere.track.request.testcase.TestPlanCaseBatchRequest; import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest; @@ -31,7 +33,8 @@ public class TestPlanTestCaseController { Page page = PageHelper.startPage(goPage, pageSize, true); return PageUtils.setPageInfo(page, testPlanTestCaseService.list(request)); } - /*jenkins测试计划下全部用例*/ + + /*jenkins测试计划下全部用例*/ @GetMapping("/list/{planId}") public List getTestPlanCaseByPlanId(@PathVariable String planId) { QueryTestPlanCaseRequest request = new QueryTestPlanCaseRequest(); @@ -104,30 +107,35 @@ public class TestPlanTestCaseController { @PostMapping("/edit") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#testPlanTestCase.id)", msClass = TestPlanTestCaseService.class) public void editTestCase(@RequestBody TestPlanTestCaseWithBLOBs testPlanTestCase) { testPlanTestCaseService.editTestCase(testPlanTestCase); } @PostMapping("/minder/edit") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.ASSOCIATE_CASE, content = "#msClass.getCaseLogDetails(#testPlanTestCases)", msClass = TestPlanTestCaseService.class) public void editTestCaseForMinder(@RequestBody List testPlanTestCases) { testPlanTestCaseService.editTestCaseForMinder(testPlanTestCases); } @PostMapping("/batch/edit") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.batchLogDetails(#request.ids)", content = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanTestCaseService.class) public void editTestCaseBath(@RequestBody TestPlanCaseBatchRequest request) { testPlanTestCaseService.editTestCaseBath(request); } @PostMapping("/batch/delete") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#request.ids)", msClass = TestPlanTestCaseService.class) public void deleteTestCaseBath(@RequestBody TestPlanCaseBatchRequest request) { testPlanTestCaseService.deleteTestCaseBath(request); } @PostMapping("/delete/{id}") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_plan", type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#id)", msClass = TestPlanTestCaseService.class) public int deleteTestCase(@PathVariable String id) { return testPlanTestCaseService.deleteTestCase(id); } diff --git a/backend/src/main/java/io/metersphere/track/controller/TestReviewTestCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestReviewTestCaseController.java index 8c22d65b08..239f3b7f93 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestReviewTestCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestReviewTestCaseController.java @@ -3,9 +3,11 @@ package io.metersphere.track.controller; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.TestCaseReviewTestCase; +import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; +import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.track.dto.TestReviewCaseDTO; import io.metersphere.track.request.testplancase.TestReviewCaseBatchRequest; import io.metersphere.track.request.testreview.DeleteRelevanceRequest; @@ -33,24 +35,28 @@ public class TestReviewTestCaseController { @PostMapping("/delete") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#request)", msClass = TestReviewTestCaseService.class) public int deleteTestCase(@RequestBody DeleteRelevanceRequest request) { return testReviewTestCaseService.deleteTestCase(request); } @PostMapping("/batch/delete") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.UN_ASSOCIATE_CASE, beforeEvent = "#msClass.getLogDetails(#request)", msClass = TestReviewTestCaseService.class) public void deleteTestCaseBatch(@RequestBody TestReviewCaseBatchRequest request) { testReviewTestCaseService.deleteTestCaseBatch(request); } @PostMapping("/batch/edit/status") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.BATCH_UPDATE, beforeEvent = "#msClass.batchLogDetails(#request)", content = "#msClass.getLogDetails(#request)", msClass = TestReviewTestCaseService.class) public void editTestCaseBatch(@RequestBody TestReviewCaseBatchRequest request) { testReviewTestCaseService.editTestCaseBatchStatus(request); } @PostMapping("/minder/edit") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.ASSOCIATE_CASE, content = "#msClass.getLogDetails(#testCases)", msClass = TestReviewTestCaseService.class) public void editTestCaseForMinder(@RequestBody List testCases) { testReviewTestCaseService.editTestCaseForMinder(testCases); } @@ -62,6 +68,7 @@ public class TestReviewTestCaseController { @PostMapping("/edit") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) + @MsAuditLog(module = "track_test_case_review", type = OperLogConstants.REVIEW, content = "#msClass.getLogDetails(#testCaseReviewTestCase)", msClass = TestReviewTestCaseService.class) public void editTestCase(@RequestBody TestCaseReviewTestCase testCaseReviewTestCase) { testReviewTestCaseService.editTestCase(testCaseReviewTestCase); } diff --git a/backend/src/main/java/io/metersphere/track/dto/RelevanceScenarioRequest.java b/backend/src/main/java/io/metersphere/track/dto/RelevanceScenarioRequest.java index 5504fb33aa..226fb99a23 100644 --- a/backend/src/main/java/io/metersphere/track/dto/RelevanceScenarioRequest.java +++ b/backend/src/main/java/io/metersphere/track/dto/RelevanceScenarioRequest.java @@ -10,6 +10,7 @@ import java.util.Map; @Setter public class RelevanceScenarioRequest { + private List ids; /** * 环境和项目对应关系 */ diff --git a/backend/src/main/java/io/metersphere/track/request/testCaseReport/CreateReportRequest.java b/backend/src/main/java/io/metersphere/track/request/testCaseReport/CreateReportRequest.java index 1515933807..aa1d1115d2 100644 --- a/backend/src/main/java/io/metersphere/track/request/testCaseReport/CreateReportRequest.java +++ b/backend/src/main/java/io/metersphere/track/request/testCaseReport/CreateReportRequest.java @@ -6,6 +6,7 @@ import lombok.Setter; @Getter @Setter public class CreateReportRequest { + private String id; String planId; String templateId; } diff --git a/backend/src/main/java/io/metersphere/track/service/IssuesService.java b/backend/src/main/java/io/metersphere/track/service/IssuesService.java index 0dc0350010..8821b1b039 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -17,6 +17,10 @@ import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.request.IntegrationRequest; import io.metersphere.i18n.Translator; +import io.metersphere.log.utils.ReflexObjectUtil; +import io.metersphere.log.vo.DetailColumn; +import io.metersphere.log.vo.OperatingLogDetails; +import io.metersphere.log.vo.track.TestPlanReference; import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.service.NoticeSendService; import io.metersphere.service.IntegrationService; @@ -34,7 +38,10 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; -import java.util.*; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import java.util.stream.Collectors; @Service @@ -130,6 +137,7 @@ public class IssuesService { Project project = getProjectByCaseId(caseId); return getIssuesByProject(issueRequest, project); } + public List getIssuesByProject(IssuesRequest issueRequest, Project project) { List list = new ArrayList<>(); List platforms = getPlatforms(project); @@ -395,4 +403,24 @@ public class IssuesService { ServiceIntegration integration = integrationService.get(request); return integration.getConfiguration(); } + + public String getLogDetails(String id) { + IssuesWithBLOBs issuesWithBLOBs = issuesMapper.selectByPrimaryKey(id); + if (issuesWithBLOBs != null) { + List columns = ReflexObjectUtil.getColumns(issuesWithBLOBs, TestPlanReference.issuesColumns); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(issuesWithBLOBs.getId()), issuesWithBLOBs.getProjectId(), issuesWithBLOBs.getTitle(), issuesWithBLOBs.getCreator(), columns); + return JSON.toJSONString(details); + } + return null; + } + + public String getLogDetails(IssuesUpdateRequest issuesRequest) { + if (issuesRequest != null) { + issuesRequest.setCreator(SessionUtils.getUserId()); + List columns = ReflexObjectUtil.getColumns(issuesRequest, TestPlanReference.issuesColumns); + OperatingLogDetails details = new OperatingLogDetails(null, issuesRequest.getProjectId(), issuesRequest.getTitle(), issuesRequest.getCreator(), columns); + return JSON.toJSONString(details); + } + return null; + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseCommentService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseCommentService.java index 1410744fc1..f8d88c22bd 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseCommentService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseCommentService.java @@ -1,11 +1,10 @@ package io.metersphere.track.service; -import io.metersphere.base.domain.TestCaseComment; -import io.metersphere.base.domain.TestCaseCommentExample; -import io.metersphere.base.domain.TestCaseWithBLOBs; -import io.metersphere.base.domain.User; +import com.alibaba.fastjson.JSON; +import io.metersphere.base.domain.*; import io.metersphere.base.mapper.TestCaseCommentMapper; import io.metersphere.base.mapper.TestCaseMapper; +import io.metersphere.base.mapper.TestCaseReviewMapper; import io.metersphere.base.mapper.UserMapper; import io.metersphere.base.mapper.ext.ExtTestCaseCommentMapper; import io.metersphere.commons.constants.NoticeConstants; @@ -13,6 +12,10 @@ import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.dto.BaseSystemConfigDTO; import io.metersphere.i18n.Translator; +import io.metersphere.log.utils.ReflexObjectUtil; +import io.metersphere.log.vo.DetailColumn; +import io.metersphere.log.vo.OperatingLogDetails; +import io.metersphere.log.vo.track.TestCaseReviewReference; import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.service.NoticeSendService; import io.metersphere.service.SystemParameterService; @@ -29,7 +32,8 @@ import java.util.*; @Service @Transactional(rollbackFor = Exception.class) public class TestCaseCommentService { - + @Resource + TestCaseReviewMapper testCaseReviewMapper; @Resource private TestCaseCommentMapper testCaseCommentMapper; @Resource @@ -45,7 +49,7 @@ public class TestCaseCommentService { public void saveComment(SaveCommentRequest request) { TestCaseComment testCaseComment = new TestCaseComment(); - testCaseComment.setId(UUID.randomUUID().toString()); + testCaseComment.setId(request.getId()); testCaseComment.setAuthor(SessionUtils.getUser().getId()); testCaseComment.setCaseId(request.getCaseId()); testCaseComment.setCreateTime(System.currentTimeMillis()); @@ -119,4 +123,14 @@ public class TestCaseCommentService { } } + public String getLogDetails(String id) { + TestCaseComment caseComment = testCaseCommentMapper.selectByPrimaryKey(id); + if (caseComment != null) { + TestCase review = testCaseMapper.selectByPrimaryKey(caseComment.getCaseId()); + List columns = ReflexObjectUtil.getColumns(caseComment, TestCaseReviewReference.commentReviewColumns); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(caseComment.getId()), review.getProjectId(), caseComment.getDescription(), caseComment.getAuthor(), columns); + return JSON.toJSONString(details); + } + return null; + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseReportService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseReportService.java index d2e97a3592..8ba269872e 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseReportService.java @@ -1,5 +1,6 @@ package io.metersphere.track.service; +import com.alibaba.fastjson.JSON; import io.metersphere.base.domain.TestCaseReport; import io.metersphere.base.domain.TestCaseReportExample; import io.metersphere.base.domain.TestCaseReportTemplate; @@ -9,6 +10,11 @@ import io.metersphere.base.mapper.TestCaseReportTemplateMapper; import io.metersphere.base.mapper.TestPlanMapper; import io.metersphere.base.mapper.ext.ExtTestPlanMapper; import io.metersphere.commons.utils.BeanUtils; +import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.log.utils.ReflexObjectUtil; +import io.metersphere.log.vo.DetailColumn; +import io.metersphere.log.vo.OperatingLogDetails; +import io.metersphere.log.vo.track.TestPlanReference; import io.metersphere.track.request.testCaseReport.CreateReportRequest; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -65,10 +71,21 @@ public class TestCaseReportService { BeanUtils.copyBean(report, template); TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId()); report.setName(testPlan.getName()); - report.setId(UUID.randomUUID().toString()); + report.setId(request.getId()); + report.setCreateUser(SessionUtils.getUserId()); testCaseReportMapper.insert(report); testPlan.setReportId(report.getId()); testPlanMapper.updateByPrimaryKeySelective(testPlan); return report.getId(); } + + public String getLogDetails(String id) { + TestCaseReport report = testCaseReportMapper.selectByPrimaryKey(id); + if (report != null) { + List columns = ReflexObjectUtil.getColumns(report, TestPlanReference.reportColumns); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(report.getId()), null, report.getName(), report.getCreateUser(), columns); + return JSON.toJSONString(details); + } + return null; + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java index 3582052a02..0f8cf927b3 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseReviewService.java @@ -1,12 +1,16 @@ package io.metersphere.track.service; +import com.alibaba.fastjson.JSON; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.ExtProjectMapper; import io.metersphere.base.mapper.ext.ExtTestCaseMapper; import io.metersphere.base.mapper.ext.ExtTestCaseReviewMapper; import io.metersphere.base.mapper.ext.ExtTestReviewCaseMapper; -import io.metersphere.commons.constants.*; +import io.metersphere.commons.constants.NoticeConstants; +import io.metersphere.commons.constants.TestCaseReviewStatus; +import io.metersphere.commons.constants.TestPlanStatus; +import io.metersphere.commons.constants.TestReviewCaseStatus; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.utils.LogUtil; @@ -15,6 +19,10 @@ import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.request.member.QueryMemberRequest; import io.metersphere.dto.BaseSystemConfigDTO; import io.metersphere.i18n.Translator; +import io.metersphere.log.utils.ReflexObjectUtil; +import io.metersphere.log.vo.DetailColumn; +import io.metersphere.log.vo.OperatingLogDetails; +import io.metersphere.log.vo.track.TestCaseReviewReference; import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.service.NoticeSendService; import io.metersphere.service.SystemParameterService; @@ -27,13 +35,13 @@ import io.metersphere.track.request.testreview.QueryTestReviewRequest; import io.metersphere.track.request.testreview.ReviewRelevanceRequest; import io.metersphere.track.request.testreview.SaveTestCaseReviewRequest; import org.apache.commons.beanutils.BeanUtils; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.text.SimpleDateFormat; @@ -90,7 +98,7 @@ public class TestCaseReviewService { public String saveTestCaseReview(SaveTestCaseReviewRequest reviewRequest) { checkCaseReviewExist(reviewRequest); - String reviewId = UUID.randomUUID().toString(); + String reviewId = reviewRequest.getId(); List userIds = reviewRequest.getUserIds();//执行人 userIds.forEach(userId -> { @@ -101,6 +109,7 @@ public class TestCaseReviewService { }); reviewRequest.setId(reviewId); + reviewRequest.setCreateUser(SessionUtils.getUserId()); reviewRequest.setCreateTime(System.currentTimeMillis()); reviewRequest.setUpdateTime(System.currentTimeMillis()); reviewRequest.setCreator(SessionUtils.getUser().getId());//创建人 @@ -352,6 +361,7 @@ public class TestCaseReviewService { TestCaseReviewTestCase caseReview = new TestCaseReviewTestCase(); caseReview.setId(UUID.randomUUID().toString()); caseReview.setReviewer(SessionUtils.getUser().getId()); + caseReview.setCreateUser(SessionUtils.getUserId()); caseReview.setCaseId(caseId); caseReview.setCreateTime(System.currentTimeMillis()); caseReview.setUpdateTime(System.currentTimeMillis()); @@ -609,5 +619,40 @@ public class TestCaseReviewService { return context; } + public String getLogDetails(String id) { + TestCaseReview review = testCaseReviewMapper.selectByPrimaryKey(id); + if (review != null) { + List columns = ReflexObjectUtil.getColumns(review, TestCaseReviewReference.testCaseReviewColumns); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), review.getProjectId(), review.getName(), review.getCreateUser(), columns); + return JSON.toJSONString(details); + } + return null; + } + + public String getLogDetails(ReviewRelevanceRequest request) { + List testCaseIds = request.getTestCaseIds(); + List names = new ArrayList<>(); + if (testCaseIds.get(0).equals("all")) { + List testCases = extTestCaseMapper.getTestCaseByNotInReview(request.getRequest()); + if (!testCases.isEmpty()) { + names = testCases.stream().map(TestCase::getName).collect(Collectors.toList()); + testCaseIds = testCases.stream().map(testCase -> testCase.getId()).collect(Collectors.toList()); + } + } else { + TestCaseExample example = new TestCaseExample(); + example.createCriteria().andIdIn(testCaseIds); + List cases = testCaseMapper.selectByExample(example); + if (CollectionUtils.isNotEmpty(cases)) { + names = cases.stream().map(TestCase::getName).collect(Collectors.toList()); + } + } + TestCaseReview caseReview = testCaseReviewMapper.selectByPrimaryKey(request.getReviewId()); + if (caseReview != null) { + List columns = new LinkedList<>(); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(testCaseIds), caseReview.getProjectId(), String.join(",", names) + " 关联到 " + "【" + caseReview.getName() + "】", caseReview.getCreateUser(), columns); + return JSON.toJSONString(details); + } + return null; + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java index 55699e55cc..27f0afff5e 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanApiCaseService.java @@ -1,21 +1,23 @@ package io.metersphere.track.service; +import com.alibaba.fastjson.JSON; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.api.dto.definition.ApiTestCaseDTO; import io.metersphere.api.dto.definition.ApiTestCaseRequest; import io.metersphere.api.dto.definition.TestPlanApiCaseDTO; import io.metersphere.api.service.ApiDefinitionExecResultService; -import io.metersphere.api.service.ApiDefinitionService; import io.metersphere.api.service.ApiTestCaseService; -import io.metersphere.base.domain.TestPlanApiCase; -import io.metersphere.base.domain.TestPlanApiCaseExample; +import io.metersphere.base.domain.*; +import io.metersphere.base.mapper.ApiTestCaseMapper; import io.metersphere.base.mapper.TestPlanApiCaseMapper; +import io.metersphere.base.mapper.TestPlanMapper; import io.metersphere.base.mapper.ext.ExtTestPlanApiCaseMapper; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.log.vo.OperatingLogDetails; import io.metersphere.track.request.testcase.TestPlanApiCaseBatchRequest; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -23,10 +25,8 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; +import java.util.stream.Collectors; @Service @Transactional(rollbackFor = Exception.class) @@ -38,11 +38,13 @@ public class TestPlanApiCaseService { ApiTestCaseService apiTestCaseService; @Resource ExtTestPlanApiCaseMapper extTestPlanApiCaseMapper; - @Resource - ApiDefinitionService apiDefinitionService; @Lazy @Resource ApiDefinitionExecResultService apiDefinitionExecResultService; + @Resource + private TestPlanMapper testPlanMapper; + @Resource + ApiTestCaseMapper apiTestCaseMapper; public TestPlanApiCase getInfo(String caseId, String testPlanId) { TestPlanApiCaseExample example = new TestPlanApiCaseExample(); @@ -103,7 +105,7 @@ public class TestPlanApiCaseService { public void deleteApiCaseBath(TestPlanApiCaseBatchRequest request) { List deleteIds = request.getIds(); - if(request.getCondition()!=null && request.getCondition().isSelectAll()){ + if (request.getCondition() != null && request.getCondition().isSelectAll()) { deleteIds = this.selectIds(request.getCondition()); if (request.getCondition() != null && request.getCondition().getUnSelectIds() != null) { deleteIds.removeAll(request.getCondition().getUnSelectIds()); @@ -131,7 +133,7 @@ public class TestPlanApiCaseService { return testPlanApiCaseMapper.selectByPrimaryKey(id); } - public void setExecResult(String id, String status,Long time) { + public void setExecResult(String id, String status, Long time) { TestPlanApiCase apiCase = new TestPlanApiCase(); apiCase.setId(id); apiCase.setStatus(status); @@ -154,6 +156,7 @@ public class TestPlanApiCaseService { // 批量修改用例环境 Map rows = request.getSelectRows(); Set ids = rows.keySet(); + request.setIds(new ArrayList<>(ids)); Map env = request.getProjectEnvMap(); if (env != null && !env.isEmpty()) { ids.forEach(id -> { @@ -188,4 +191,32 @@ public class TestPlanApiCaseService { List returnList = extTestPlanApiCaseMapper.list(selectReq); return returnList; } + + public String getLogDetails(String id) { + TestPlanApiCase testPlanApiCase = testPlanApiCaseMapper.selectByPrimaryKey(id); + if (testPlanApiCase != null) { + ApiTestCaseWithBLOBs testCase = apiTestCaseService.get(testPlanApiCase.getApiCaseId()); + TestPlan testPlan = testPlanMapper.selectByPrimaryKey(testPlanApiCase.getTestPlanId()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testCase.getProjectId(), testCase.getName(), testPlanApiCase.getCreateUser(), new LinkedList<>()); + return JSON.toJSONString(details); + } + return null; + } + + public String getLogDetails(List ids) { + TestPlanApiCaseExample example = new TestPlanApiCaseExample(); + example.createCriteria().andIdIn(ids); + List nodes = testPlanApiCaseMapper.selectByExample(example); + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(nodes)) { + ApiTestCaseExample testCaseExample = new ApiTestCaseExample(); + testCaseExample.createCriteria().andIdIn(nodes.stream().map(TestPlanApiCase::getApiCaseId).collect(Collectors.toList())); + List testCases = apiTestCaseMapper.selectByExample(testCaseExample); + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(testCases)) { + List names = testCases.stream().map(ApiTestCase::getName).collect(Collectors.toList()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), testCases.get(0).getProjectId(), String.join(",", names), nodes.get(0).getCreateUser(), new LinkedList<>()); + return JSON.toJSONString(details); + } + } + return null; + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java index 70a41a89c1..fd681f499f 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanLoadCaseService.java @@ -1,5 +1,6 @@ package io.metersphere.track.service; +import com.alibaba.fastjson.JSON; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.LoadTestMapper; import io.metersphere.base.mapper.LoadTestReportMapper; @@ -9,7 +10,9 @@ import io.metersphere.base.mapper.ext.ExtTestPlanLoadCaseMapper; import io.metersphere.commons.constants.RunModeConstants; import io.metersphere.commons.constants.TestPlanStatus; import io.metersphere.commons.exception.MSException; +import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.request.OrderRequest; +import io.metersphere.log.vo.OperatingLogDetails; import io.metersphere.performance.request.RunTestPlanRequest; import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.track.dto.TestPlanLoadCaseDTO; @@ -19,16 +22,17 @@ import io.metersphere.track.request.testplan.LoadCaseRequest; import io.metersphere.track.request.testplan.RunBatchTestPlanRequest; import io.metersphere.track.service.utils.ParallelExecTask; import io.metersphere.track.service.utils.SerialExecTask; +import org.apache.commons.collections.CollectionUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; import org.apache.ibatis.session.SqlSessionFactory; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.UUID; import java.util.concurrent.ExecutorService; @@ -97,6 +101,7 @@ public class TestPlanLoadCaseService { caseIds.forEach(id -> { TestPlanLoadCase t = new TestPlanLoadCase(); t.setId(UUID.randomUUID().toString()); + t.setCreateUser(SessionUtils.getUserId()); t.setTestPlanId(planId); t.setLoadCaseId(id); t.setCreateTime(System.currentTimeMillis()); @@ -261,4 +266,64 @@ public class TestPlanLoadCaseService { List list = extTestPlanLoadCaseMapper.selectByIdIn(tableReq); return list; } + + public String getLogDetails(String id) { + TestPlanLoadCase bloBs = testPlanLoadCaseMapper.selectByPrimaryKey(id); + if (bloBs != null) { + TestPlan testPlan = testPlanMapper.selectByPrimaryKey(bloBs.getTestPlanId()); + LoadTest test = loadTestMapper.selectByPrimaryKey(bloBs.getLoadCaseId()); + if (test != null && testPlan != null) { + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testPlan.getProjectId(), test.getName(), bloBs.getCreateUser(), new LinkedList<>()); + return JSON.toJSONString(details); + } + } + return null; + } + + public String getLogDetails(List ids) { + TestPlanLoadCaseExample caseExample = new TestPlanLoadCaseExample(); + caseExample.createCriteria().andIdIn(ids); + List cases = testPlanLoadCaseMapper.selectByExample(caseExample); + if (CollectionUtils.isNotEmpty(cases)) { + LoadTestExample example = new LoadTestExample(); + example.createCriteria().andIdIn(cases.stream().map(TestPlanLoadCase::getLoadCaseId).collect(Collectors.toList())); + List loadTests = loadTestMapper.selectByExample(example); + List names = loadTests.stream().map(LoadTest::getName).collect(Collectors.toList()); + TestPlan testPlan = testPlanMapper.selectByPrimaryKey(cases.get(0).getTestPlanId()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), testPlan.getProjectId(), String.join(",", names), testPlan.getCreator(), new LinkedList<>()); + return JSON.toJSONString(details); + } + return null; + } + + public String getLogDetails(List ids, String planId) { + TestPlanLoadCaseExample caseExample = new TestPlanLoadCaseExample(); + caseExample.createCriteria().andLoadCaseIdIn(ids).andTestPlanIdEqualTo(planId); + List cases = testPlanLoadCaseMapper.selectByExample(caseExample); + if (CollectionUtils.isNotEmpty(cases)) { + LoadTestExample example = new LoadTestExample(); + example.createCriteria().andIdIn(cases.stream().map(TestPlanLoadCase::getLoadCaseId).collect(Collectors.toList())); + List loadTests = loadTestMapper.selectByExample(example); + if (CollectionUtils.isNotEmpty(loadTests)) { + List names = loadTests.stream().map(LoadTest::getName).collect(Collectors.toList()); + TestPlan testPlan = testPlanMapper.selectByPrimaryKey(cases.get(0).getTestPlanId()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), testPlan.getProjectId(), String.join(",", names), testPlan.getCreator(), new LinkedList<>()); + return JSON.toJSONString(details); + } + } + return null; + } + + public String getRunLogDetails(List requests) { + LoadTestExample example = new LoadTestExample(); + example.createCriteria().andIdIn(requests.stream().map(RunTestPlanRequest::getId).collect(Collectors.toList())); + List loadTests = loadTestMapper.selectByExample(example); + if (CollectionUtils.isNotEmpty(loadTests)) { + List ids = loadTests.stream().map(LoadTest::getId).collect(Collectors.toList()); + List names = loadTests.stream().map(LoadTest::getName).collect(Collectors.toList()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), loadTests.get(0).getProjectId(), String.join(",", names), null, new LinkedList<>()); + return JSON.toJSONString(details); + } + return null; + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java index 81cd84ae51..d10461d0d8 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanReportService.java @@ -1,5 +1,6 @@ package io.metersphere.track.service; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import io.metersphere.base.domain.*; @@ -11,6 +12,7 @@ import io.metersphere.commons.constants.*; import io.metersphere.commons.utils.*; import io.metersphere.dto.BaseSystemConfigDTO; import io.metersphere.i18n.Translator; +import io.metersphere.log.vo.OperatingLogDetails; import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.service.NoticeSendService; import io.metersphere.service.SystemParameterService; @@ -21,6 +23,7 @@ import io.metersphere.track.request.report.QueryTestPlanReportRequest; import io.metersphere.track.request.report.TestPlanReportSaveRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testplan.LoadCaseRequest; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -553,4 +556,16 @@ public class TestPlanReportService { } return ids; } + + public String getLogDetails(List ids) { + TestPlanReportExample example = new TestPlanReportExample(); + example.createCriteria().andIdIn(ids); + List nodes = testPlanReportMapper.selectByExample(example); + if (CollectionUtils.isNotEmpty(nodes)) { + List names = nodes.stream().map(TestPlanReport::getName).collect(Collectors.toList()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), null, String.join(",", names), null, new LinkedList<>()); + return JSON.toJSONString(details); + } + return null; + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java index 2e7eca2359..5872c7e6fc 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanScenarioCaseService.java @@ -4,17 +4,19 @@ import com.alibaba.fastjson.JSON; import io.metersphere.api.dto.automation.*; import io.metersphere.api.service.ApiAutomationService; import io.metersphere.api.service.ApiScenarioReportService; -import io.metersphere.base.domain.TestPlanApiScenario; -import io.metersphere.base.domain.TestPlanApiScenarioExample; +import io.metersphere.base.domain.*; +import io.metersphere.base.mapper.ApiScenarioMapper; import io.metersphere.base.mapper.TestPlanApiScenarioMapper; +import io.metersphere.base.mapper.TestPlanMapper; import io.metersphere.base.mapper.ext.ExtTestPlanScenarioCaseMapper; import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.utils.ServiceUtils; +import io.metersphere.log.vo.OperatingLogDetails; import io.metersphere.track.dto.RelevanceScenarioRequest; import io.metersphere.track.request.testcase.TestPlanScenarioCaseBatchRequest; +import org.apache.commons.collections.CollectionUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; import javax.annotation.Resource; @@ -33,6 +35,10 @@ public class TestPlanScenarioCaseService { ExtTestPlanScenarioCaseMapper extTestPlanScenarioCaseMapper; @Resource ApiScenarioReportService apiScenarioReportService; + @Resource + ApiScenarioMapper apiScenarioMapper; + @Resource + private TestPlanMapper testPlanMapper; public List list(TestPlanScenarioRequest request) { request.setProjectId(null); @@ -72,7 +78,7 @@ public class TestPlanScenarioCaseService { public void deleteApiCaseBath(TestPlanScenarioCaseBatchRequest request) { List ids = request.getIds(); - if(request.getCondition()!=null && request.getCondition().isSelectAll()){ + if (request.getCondition() != null && request.getCondition().isSelectAll()) { ids = this.selectIds(request.getCondition()); if (request.getCondition() != null && request.getCondition().getUnSelectIds() != null) { ids.removeAll(request.getCondition().getUnSelectIds()); @@ -164,7 +170,10 @@ public class TestPlanScenarioCaseService { Map envMap = request.getEnvMap(); Map> mapping = request.getMapping(); Set set = mapping.keySet(); - if (set.isEmpty()) { return; } + if (set.isEmpty()) { + return; + } + request.setIds(new ArrayList<>(set)); set.forEach(id -> { Map newEnvMap = new HashMap<>(16); if (envMap != null && !envMap.isEmpty()) { @@ -199,4 +208,32 @@ public class TestPlanScenarioCaseService { tableRequest.setIds(ids); return extTestPlanScenarioCaseMapper.list(tableRequest); } + + public String getLogDetails(String id) { + TestPlanApiScenario scenario = testPlanApiScenarioMapper.selectByPrimaryKey(id); + if (scenario != null) { + ApiScenarioWithBLOBs testCase = apiScenarioMapper.selectByPrimaryKey(scenario.getApiScenarioId()); + TestPlan testPlan = testPlanMapper.selectByPrimaryKey(scenario.getTestPlanId()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testPlan.getProjectId(), testCase.getName(), scenario.getCreateUser(), new LinkedList<>()); + return JSON.toJSONString(details); + } + return null; + } + + public String getLogDetails(List ids) { + TestPlanApiScenarioExample example = new TestPlanApiScenarioExample(); + example.createCriteria().andIdIn(ids); + List nodes = testPlanApiScenarioMapper.selectByExample(example); + if (CollectionUtils.isNotEmpty(nodes)) { + ApiScenarioExample scenarioExample = new ApiScenarioExample(); + scenarioExample.createCriteria().andIdIn(nodes.stream().map(TestPlanApiScenario::getApiScenarioId).collect(Collectors.toList())); + List scenarios = apiScenarioMapper.selectByExample(scenarioExample); + if (org.apache.commons.collections.CollectionUtils.isNotEmpty(scenarios)) { + List names = scenarios.stream().map(ApiScenario::getName).collect(Collectors.toList()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), scenarios.get(0).getProjectId(), String.join(",", names), nodes.get(0).getCreateUser(), new LinkedList<>()); + return JSON.toJSONString(details); + } + } + return null; + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java index 988a424674..f14c721ff6 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanService.java @@ -24,6 +24,10 @@ import io.metersphere.commons.user.SessionUser; import io.metersphere.commons.utils.*; import io.metersphere.dto.BaseSystemConfigDTO; import io.metersphere.i18n.Translator; +import io.metersphere.log.utils.ReflexObjectUtil; +import io.metersphere.log.vo.DetailColumn; +import io.metersphere.log.vo.OperatingLogDetails; +import io.metersphere.log.vo.track.TestPlanReference; import io.metersphere.notice.sender.NoticeModel; import io.metersphere.notice.service.NoticeSendService; import io.metersphere.performance.request.RunTestPlanRequest; @@ -118,9 +122,9 @@ public class TestPlanService { @Resource private TestPlanLoadCaseMapper testPlanLoadCaseMapper; @Resource - private ApiTestCaseMapper apiTestCaseMapper; + private ApiTestCaseMapper apiTestCaseMapper; @Resource - private ApiDefinitionMapper apiDefinitionMapper; + private ApiDefinitionMapper apiDefinitionMapper; @Resource private TestPlanApiCaseMapper testPlanApiCaseMapper; @Resource @@ -141,9 +145,6 @@ public class TestPlanService { if (getTestPlanByName(testPlan.getName()).size() > 0) { MSException.throwException(Translator.get("plan_name_already_exists")); } - - String testPlanId = UUID.randomUUID().toString(); - testPlan.setId(testPlanId); testPlan.setStatus(TestPlanStatus.Prepare.name()); testPlan.setCreateTime(System.currentTimeMillis()); testPlan.setUpdateTime(System.currentTimeMillis()); @@ -212,10 +213,9 @@ public class TestPlanService { userIds.add(testPlan.getPrincipal()); AddTestPlanRequest testPlans = new AddTestPlanRequest(); int i; - if(testPlan.getName() == null) {// 若是点击该测试计划,则仅更新了updateTime,其它字段全为null,使用updateByPrimaryKeySelective + if (testPlan.getName() == null) {// 若是点击该测试计划,则仅更新了updateTime,其它字段全为null,使用updateByPrimaryKeySelective i = testPlanMapper.updateByPrimaryKeySelective(testPlan); - } - else { // 有修改字段的调用,为保证将某些时间置null的情况,使用updateByPrimaryKey + } else { // 有修改字段的调用,为保证将某些时间置null的情况,使用updateByPrimaryKey extScheduleMapper.updateNameByResourceID(testPlan.getId(), testPlan.getName());// 同步更新该测试的定时任务的name i = testPlanMapper.updateByPrimaryKeyWithBLOBs(testPlan); // 更新 } @@ -408,14 +408,14 @@ public class TestPlanService { // Prepare, Pass, Failure, Blocking, Skip, Underway TestPlanDTO testPlanDTO = new TestPlanDTO(); testPlanDTO.setId(testPlanId); - if(statusList.size() == 0) { // 原先status不是prepare, 但删除所有关联用例的情况 + if (statusList.size() == 0) { // 原先status不是prepare, 但删除所有关联用例的情况 testPlanDTO.setStatus(TestPlanStatus.Prepare.name()); editTestPlan(testPlanDTO, false); return; } int passNum = 0, prepareNum = 0, failNum = 0; - for(String res : statusList) { - if(StringUtils.equals(res, TestPlanTestCaseStatus.Pass.name()) + for (String res : statusList) { + if (StringUtils.equals(res, TestPlanTestCaseStatus.Pass.name()) || StringUtils.equals(res, "success") || StringUtils.equals(res, ScenarioStatus.Success.name())) { passNum++; @@ -425,13 +425,13 @@ public class TestPlanService { failNum++; } } - if(passNum == statusList.size()) { // 全部通过 + if (passNum == statusList.size()) { // 全部通过 testPlanDTO.setStatus(TestPlanStatus.Completed.name()); this.editTestPlan(testPlanDTO, false); - } else if(prepareNum == 0 && passNum + failNum == statusList.size()) { // 已结束 + } else if (prepareNum == 0 && passNum + failNum == statusList.size()) { // 已结束 testPlanDTO.setStatus(TestPlanStatus.Finished.name()); editTestPlan(testPlanDTO, false); - } else if(prepareNum != 0) { // 进行中 + } else if (prepareNum != 0) { // 进行中 testPlanDTO.setStatus(TestPlanStatus.Underway.name()); editTestPlan(testPlanDTO, false); } @@ -473,6 +473,7 @@ public class TestPlanService { TestCaseWithBLOBs testCase = testCaseMap.get(caseId); TestPlanTestCaseWithBLOBs testPlanTestCase = new TestPlanTestCaseWithBLOBs(); testPlanTestCase.setId(UUID.randomUUID().toString()); + testPlanTestCase.setCreateUser(SessionUtils.getUserId()); testPlanTestCase.setExecutor(SessionUtils.getUser().getId()); testPlanTestCase.setCaseId(caseId); testPlanTestCase.setCreateTime(System.currentTimeMillis()); @@ -486,31 +487,31 @@ public class TestPlanService { sqlSession.flushStatements(); //同步添加关联的接口和测试用例 - if(request.getChecked()){ + if (request.getChecked()) { if (!testCaseIds.isEmpty()) { testCaseIds.forEach(caseId -> { - List list=new ArrayList<>(); - TestCaseTestExample examp=new TestCaseTestExample(); + List list = new ArrayList<>(); + TestCaseTestExample examp = new TestCaseTestExample(); examp.createCriteria().andTestCaseIdEqualTo(caseId); - if(testCaseTestMapper.countByExample(examp)>0){ - list=testCaseTestMapper.selectByExample(examp); + if (testCaseTestMapper.countByExample(examp) > 0) { + list = testCaseTestMapper.selectByExample(examp); } - list.forEach(l->{ - if(StringUtils.equals(l.getTestType(),TestCaseStatus.performance.name())){ + list.forEach(l -> { + if (StringUtils.equals(l.getTestType(), TestCaseStatus.performance.name())) { TestPlanLoadCase t = new TestPlanLoadCase(); t.setId(UUID.randomUUID().toString()); t.setTestPlanId(request.getPlanId()); t.setLoadCaseId(l.getTestId()); t.setCreateTime(System.currentTimeMillis()); t.setUpdateTime(System.currentTimeMillis()); - TestPlanLoadCaseExample testPlanLoadCaseExample=new TestPlanLoadCaseExample(); + TestPlanLoadCaseExample testPlanLoadCaseExample = new TestPlanLoadCaseExample(); testPlanLoadCaseExample.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andLoadCaseIdEqualTo(t.getLoadCaseId()); - if (testPlanLoadCaseMapper.countByExample(testPlanLoadCaseExample) <=0) { + if (testPlanLoadCaseMapper.countByExample(testPlanLoadCaseExample) <= 0) { testPlanLoadCaseMapper.insert(t); } } - if(StringUtils.equals(l.getTestType(),TestCaseStatus.testcase.name())){ + if (StringUtils.equals(l.getTestType(), TestCaseStatus.testcase.name())) { TestPlanApiCase t = new TestPlanApiCase(); ApiTestCaseWithBLOBs apitest = apiTestCaseMapper.selectByPrimaryKey(l.getTestId()); if (null != apitest) { @@ -530,9 +531,9 @@ public class TestPlanService { } - if(StringUtils.equals(l.getTestType(),TestCaseStatus.automation.name())){ - TestPlanApiScenario t=new TestPlanApiScenario(); - ApiScenarioWithBLOBs testPlanApiScenario=apiScenarioMapper.selectByPrimaryKey(l.getTestId()); + if (StringUtils.equals(l.getTestType(), TestCaseStatus.automation.name())) { + TestPlanApiScenario t = new TestPlanApiScenario(); + ApiScenarioWithBLOBs testPlanApiScenario = apiScenarioMapper.selectByPrimaryKey(l.getTestId()); t.setId(UUID.randomUUID().toString()); t.setTestPlanId(request.getPlanId()); t.setApiScenarioId(l.getTestId()); @@ -542,9 +543,9 @@ public class TestPlanService { t.setStatus(testPlanApiScenario.getStatus()); t.setCreateTime(System.currentTimeMillis()); t.setUpdateTime(System.currentTimeMillis()); - TestPlanApiScenarioExample example=new TestPlanApiScenarioExample(); + TestPlanApiScenarioExample example = new TestPlanApiScenarioExample(); example.createCriteria().andTestPlanIdEqualTo(request.getPlanId()).andApiScenarioIdEqualTo(t.getApiScenarioId()); - if(testPlanApiScenarioMapper.countByExample(example)<=0){ + if (testPlanApiScenarioMapper.countByExample(example) <= 0) { testPlanApiScenarioMapper.insert(t); } @@ -936,10 +937,10 @@ public class TestPlanService { scenarios.add(scenario); // 创建场景报告 //不同的运行模式,第二个参数入参不同 - APIScenarioReportResult report = apiAutomationService.createScenarioReport(group.getName(), + APIScenarioReportResult report = apiAutomationService.createScenarioReport(group.getName(), planScenarioID + ":" + request.getTestPlanReportId(), item.getName(), request.getTriggerMode() == null ? ReportTriggerMode.MANUAL.name() : request.getTriggerMode(), - request.getExecuteType(), item.getProjectId(), request.getReportUserID(),null); + request.getExecuteType(), item.getProjectId(), request.getReportUserID(), null); apiScenarioReportMapper.insert(report); group.setHashTree(scenarios); testPlan.getHashTree().add(group); @@ -997,9 +998,9 @@ public class TestPlanService { String performanceCaseIdArray = ""; String planReportId = UUID.randomUUID().toString(); //创建测试报告,然后返回的ID重新赋值为resourceID,作为后续的参数 - TestPlanReportSaveRequest saveRequest = new TestPlanReportSaveRequest(planReportId,testPlanID,userId,triggerMode, - apiTestCaseIdMap.size()>0,planScenarioIdMap.size()>0,performanceIdMap.size()>0, - JSONArray.toJSONString(new ArrayList<>(apiTestCaseIdMap.keySet())),JSONArray.toJSONString(new ArrayList<>(planScenarioIdMap.keySet())),JSONArray.toJSONString(new ArrayList<>(performanceIdMap.values()))); + TestPlanReportSaveRequest saveRequest = new TestPlanReportSaveRequest(planReportId, testPlanID, userId, triggerMode, + apiTestCaseIdMap.size() > 0, planScenarioIdMap.size() > 0, performanceIdMap.size() > 0, + JSONArray.toJSONString(new ArrayList<>(apiTestCaseIdMap.keySet())), JSONArray.toJSONString(new ArrayList<>(planScenarioIdMap.keySet())), JSONArray.toJSONString(new ArrayList<>(performanceIdMap.values()))); TestPlanReport testPlanReport = testPlanReportService.genTestPlanReport(saveRequest); @@ -1032,13 +1033,13 @@ public class TestPlanService { } catch (Exception e) { e.printStackTrace(); } - if(StringUtils.isEmpty(reportId)){ + if (StringUtils.isEmpty(reportId)) { performaceIsExcuting = false; } } - if(performaceIsExcuting){ - performanceCaseIdArray= JSONArray.toJSONString(new ArrayList<>(performanceIdMap.values())); + if (performaceIsExcuting) { + performanceCaseIdArray = JSONArray.toJSONString(new ArrayList<>(performanceIdMap.values())); } if (!performaneReportIDList.isEmpty()) { @@ -1056,7 +1057,7 @@ public class TestPlanService { apiTestCaseService.run(blobs, UUID.randomUUID().toString(), planReportId, testPlanID, ApiRunMode.SCHEDULE_API_PLAN.name()); apiCaseIsExcuting = true; } - if(apiCaseIsExcuting){ + if (apiCaseIsExcuting) { apiCaseIdArray = JSONArray.toJSONString(new ArrayList<>(apiTestCaseIdMap.keySet())); } @@ -1077,19 +1078,53 @@ public class TestPlanService { scenarioRequest.setRunMode(ApiRunMode.SCHEDULE_SCENARIO_PLAN.name()); scenarioRequest.setTestPlanReportId(planReportId); String scenarioReportID = this.runScenarioCase(scenarioRequest); - if(StringUtils.isNotEmpty(scenarioReportID)){ + if (StringUtils.isNotEmpty(scenarioReportID)) { scenarioIsExcuting = true; - scenarioCaseIdArray= JSONArray.toJSONString(new ArrayList<>(planScenarioIdMap.keySet())); + scenarioCaseIdArray = JSONArray.toJSONString(new ArrayList<>(planScenarioIdMap.keySet())); } } //如果report参数和预期不对(某些原因执行失败),则更新report - if(saveRequest.isApiCaseIsExecuting() != apiCaseIsExcuting ||saveRequest.isScenarioIsExecuting()!=scenarioIsExcuting ||saveRequest.isPerformanceIsExecuting() != performaceIsExcuting){ + if (saveRequest.isApiCaseIsExecuting() != apiCaseIsExcuting || saveRequest.isScenarioIsExecuting() != scenarioIsExcuting || saveRequest.isPerformanceIsExecuting() != performaceIsExcuting) { testPlanReport.setIsApiCaseExecuting(apiCaseIsExcuting); testPlanReport.setIsScenarioExecuting(scenarioIsExcuting); testPlanReport.setIsPerformanceExecuting(performaceIsExcuting); testPlanReportService.update(testPlanReport); } } + + public String getLogDetails(String id) { + TestPlan plan = testPlanMapper.selectByPrimaryKey(id); + if (plan != null) { + List columns = ReflexObjectUtil.getColumns(plan, TestPlanReference.testPlanColumns); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), plan.getProjectId(), plan.getName(), plan.getCreator(), columns); + return JSON.toJSONString(details); + } + return null; + } + + public String getLogDetails(PlanCaseRelevanceRequest request) { + List testCaseIds = request.getTestCaseIds(); + List names = null; + if (testCaseIds.get(0).equals("all")) { + List testCases = extTestCaseMapper.getTestCaseByNotInReview(request.getRequest()); + if (!testCases.isEmpty()) { + names = testCases.stream().map(TestCase::getName).collect(Collectors.toList()); + testCaseIds = testCases.stream().map(testCase -> testCase.getId()).collect(Collectors.toList()); + } + } else { + TestCaseExample example = new TestCaseExample(); + example.createCriteria().andIdIn(testCaseIds); + List cases = testCaseMapper.selectByExample(example); + names = cases.stream().map(TestCase::getName).collect(Collectors.toList()); + } + TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId()); + if (testPlan != null) { + List columns = new LinkedList<>(); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(testCaseIds), testPlan.getProjectId(), String.join(",", names) + " 关联到 " + "【" + testPlan.getName() + "】", testPlan.getCreator(), columns); + return JSON.toJSONString(details); + } + return null; + } } 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 f85bc19f36..13c3cac738 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanTestCaseService.java @@ -1,5 +1,6 @@ package io.metersphere.track.service; +import com.alibaba.fastjson.JSON; import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; @@ -10,6 +11,8 @@ import io.metersphere.commons.utils.BeanUtils; import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.request.member.QueryMemberRequest; +import io.metersphere.log.vo.DetailColumn; +import io.metersphere.log.vo.OperatingLogDetails; import io.metersphere.service.UserService; import io.metersphere.track.dto.TestCaseTestDTO; import io.metersphere.track.dto.TestPlanCaseDTO; @@ -17,12 +20,14 @@ import io.metersphere.track.request.testcase.TestPlanCaseBatchRequest; import io.metersphere.track.request.testplancase.QueryTestPlanCaseRequest; import io.metersphere.track.request.testplancase.TestPlanFuncCaseBatchRequest; import io.metersphere.track.request.testplancase.TestPlanFuncCaseConditions; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -50,6 +55,10 @@ public class TestPlanTestCaseService { private ApiTestCaseMapper apiTestCaseMapper; @Resource private ApiScenarioMapper apiScenarioMapper; + @Resource + private TestCaseMapper testCaseMapper; + @Resource + private TestPlanMapper testPlanMapper; public List list(QueryTestPlanCaseRequest request) { request.setOrders(ServiceUtils.getDefaultOrder(request.getOrders())); @@ -63,6 +72,7 @@ public class TestPlanTestCaseService { }); return list; } + public List listByPlanId(QueryTestPlanCaseRequest request) { List list = extTestPlanTestCaseMapper.listByPlanId(request); return list; @@ -93,9 +103,9 @@ public class TestPlanTestCaseService { public void editTestCaseBath(TestPlanCaseBatchRequest request) { List ids = request.getIds(); - if(request.getCondition()!=null && request.getCondition().isSelectAll()){ + if (request.getCondition() != null && request.getCondition().isSelectAll()) { ids = extTestPlanTestCaseMapper.selectIds(request.getCondition()); - if(request.getCondition().getUnSelectIds()!=null){ + if (request.getCondition().getUnSelectIds() != null) { ids.removeAll(request.getCondition().getUnSelectIds()); } } @@ -213,13 +223,58 @@ public class TestPlanTestCaseService { public List idList(TestPlanFuncCaseBatchRequest request) { List returnIdList = new ArrayList<>(); TestPlanFuncCaseConditions conditions = request.getCondition(); - if(conditions!= null && conditions.isSelectAll()){ + if (conditions != null && conditions.isSelectAll()) { conditions.setOrders(ServiceUtils.getDefaultOrder(conditions.getOrders())); returnIdList = extTestPlanTestCaseMapper.selectIds(conditions); - if(conditions.getUnSelectIds()!=null){ + if (conditions.getUnSelectIds() != null) { returnIdList.removeAll(conditions.getUnSelectIds()); } } return returnIdList; } + + public String getLogDetails(String id) { + TestPlanTestCaseWithBLOBs planTestCaseWithBLOBs = testPlanTestCaseMapper.selectByPrimaryKey(id); + if (planTestCaseWithBLOBs != null) { + TestCase testCase = testCaseMapper.selectByPrimaryKey(planTestCaseWithBLOBs.getCaseId()); + TestPlan testPlan = testPlanMapper.selectByPrimaryKey(planTestCaseWithBLOBs.getPlanId()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), testCase.getProjectId(), testCase.getName(), planTestCaseWithBLOBs.getCreateUser(), new LinkedList<>()); + return JSON.toJSONString(details); + } + return null; + } + + public String getLogDetails(List ids) { + TestPlanTestCaseExample example = new TestPlanTestCaseExample(); + example.createCriteria().andIdIn(ids); + List nodes = testPlanTestCaseMapper.selectByExample(example); + if (CollectionUtils.isNotEmpty(nodes)) { + TestCaseExample testCaseExample = new TestCaseExample(); + testCaseExample.createCriteria().andIdIn(nodes.stream().map(TestPlanTestCase::getCaseId).collect(Collectors.toList())); + List testCases = testCaseMapper.selectByExample(testCaseExample); + if (CollectionUtils.isNotEmpty(testCases)) { + List names = testCases.stream().map(TestCase::getName).collect(Collectors.toList()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), testCases.get(0).getProjectId(), String.join(",", names), nodes.get(0).getCreateUser(), new LinkedList<>()); + return JSON.toJSONString(details); + } + } + return null; + } + + public String getCaseLogDetails(List testCases) { + // 更新状态 + if (CollectionUtils.isNotEmpty(testCases)) { + List columns = new LinkedList<>(); + TestCaseExample example = new TestCaseExample(); + List ids = testCases.stream().map(TestPlanTestCaseWithBLOBs::getCaseId).collect(Collectors.toList()); + example.createCriteria().andIdIn(ids); + List cases = testCaseMapper.selectByExample(example); + if (cases != null && cases.size() > 0) { + List names = cases.stream().map(TestCase::getName).collect(Collectors.toList()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), cases.get(0).getProjectId(), String.join(",", names), cases.get(0).getCreateUser(), columns); + return JSON.toJSONString(details); + } + } + return null; + } } 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 756a02a4f5..f82120eb2c 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestReviewTestCaseService.java @@ -1,5 +1,6 @@ package io.metersphere.track.service; +import com.alibaba.fastjson.JSON; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.ExtTestPlanTestCaseMapper; @@ -8,19 +9,23 @@ import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.ServiceUtils; import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.request.member.QueryMemberRequest; +import io.metersphere.log.vo.DetailColumn; +import io.metersphere.log.vo.OperatingLogDetails; +import io.metersphere.log.vo.StatusReference; import io.metersphere.service.UserService; import io.metersphere.track.dto.TestCaseTestDTO; import io.metersphere.track.dto.TestReviewCaseDTO; import io.metersphere.track.request.testplancase.TestReviewCaseBatchRequest; import io.metersphere.track.request.testreview.DeleteRelevanceRequest; import io.metersphere.track.request.testreview.QueryCaseReviewRequest; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -115,9 +120,9 @@ public class TestReviewTestCaseService { public void deleteTestCaseBatch(TestReviewCaseBatchRequest request) { checkReviewer(request.getReviewId()); List ids = request.getIds(); - if(request.getCondition()!=null && request.getCondition().isSelectAll()){ + if (request.getCondition() != null && request.getCondition().isSelectAll()) { ids = this.selectIds(request.getCondition()); - if(request.getCondition().getUnSelectIds()!=null){ + if (request.getCondition().getUnSelectIds() != null) { ids.removeAll(request.getCondition().getUnSelectIds()); } } @@ -149,7 +154,7 @@ public class TestReviewTestCaseService { } public TestReviewCaseDTO get(String reviewId) { - TestReviewCaseDTO testReviewCaseDTO=extTestReviewCaseMapper.get(reviewId); + TestReviewCaseDTO testReviewCaseDTO = extTestReviewCaseMapper.get(reviewId); List testCaseTestDTOS = extTestPlanTestCaseMapper.listTestCaseTest(testReviewCaseDTO.getCaseId()); testCaseTestDTOS.forEach(dto -> { setTestName(dto); @@ -187,9 +192,9 @@ public class TestReviewTestCaseService { public void editTestCaseBatchStatus(TestReviewCaseBatchRequest request) { List ids = request.getIds(); - if(request.getCondition()!=null && request.getCondition().isSelectAll()){ + if (request.getCondition() != null && request.getCondition().isSelectAll()) { ids = extTestReviewCaseMapper.selectTestCaseIds(request.getCondition()); - if(request.getCondition().getUnSelectIds()!=null){ + if (request.getCondition().getUnSelectIds() != null) { ids.removeAll(request.getCondition().getUnSelectIds()); } } @@ -239,4 +244,99 @@ public class TestReviewTestCaseService { testCaseList.forEach(testCaseMapper::updateByPrimaryKeySelective); } } + + public String getLogDetails(DeleteRelevanceRequest request) { + TestCaseReview caseReview = testCaseReviewMapper.selectByPrimaryKey(request.getReviewId()); + TestCaseReviewTestCase testCaseReviewTestCase = testCaseReviewTestCaseMapper.selectByPrimaryKey(request.getId()); + StringBuilder titleBuilder = new StringBuilder(); + if (testCaseReviewTestCase != null) { + TestCaseWithBLOBs bloBs = testCaseMapper.selectByPrimaryKey(testCaseReviewTestCase.getCaseId()); + if (bloBs != null) { + titleBuilder.append(bloBs.getName()).append(" 从 "); + } + } + if (caseReview != null) { + titleBuilder.append(caseReview.getName()); + } + if (StringUtils.isNotEmpty(titleBuilder.toString())) { + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(request.getId()), caseReview.getProjectId(), titleBuilder.toString(), caseReview.getCreateUser(), new LinkedList<>()); + return JSON.toJSONString(details); + } + return null; + } + + public String getLogDetails(TestReviewCaseBatchRequest request) { + TestCaseReview caseReview = testCaseReviewMapper.selectByPrimaryKey(request.getReviewId()); + TestCaseReviewTestCaseExample example = new TestCaseReviewTestCaseExample(); + example.createCriteria().andIdIn(request.getIds()); + List testCaseReviewTestCases = testCaseReviewTestCaseMapper.selectByExample(example); + StringBuilder titleBuilder = new StringBuilder(); + if (CollectionUtils.isNotEmpty(testCaseReviewTestCases)) { + testCaseReviewTestCases.forEach(item -> { + TestCaseWithBLOBs bloBs = testCaseMapper.selectByPrimaryKey(item.getCaseId()); + if (bloBs != null) { + titleBuilder.append(bloBs.getName()).append(","); + } + }); + titleBuilder.append(" 从 "); + } + if (caseReview != null) { + titleBuilder.append(caseReview.getName()); + } + if (StringUtils.isNotEmpty(titleBuilder.toString())) { + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(request.getId()), caseReview.getProjectId(), titleBuilder.toString(), caseReview.getCreateUser(), new LinkedList<>()); + return JSON.toJSONString(details); + } + return null; + } + + public String batchLogDetails(TestReviewCaseBatchRequest request) { + List ids = request.getIds(); + if (request.getCondition() != null && request.getCondition().isSelectAll()) { + ids = extTestReviewCaseMapper.selectTestCaseIds(request.getCondition()); + if (request.getCondition().getUnSelectIds() != null) { + ids.removeAll(request.getCondition().getUnSelectIds()); + } + } + + // 更新状态 + if (StringUtils.isNotBlank(request.getStatus())) { + TestCaseExample example = new TestCaseExample(); + example.createCriteria().andIdIn(ids); + List cases = testCaseMapper.selectByExample(example); + + List columns = new LinkedList<>(); + List names = cases.stream().map(TestCase::getName).collect(Collectors.toList()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), cases.get(0).getProjectId(), String.join(",", names) + "评审结果更改为:" + "【" + StatusReference.statusMap.get(request.getStatus()) + "】", cases.get(0).getCreateUser(), columns); + return JSON.toJSONString(details); + } + return null; + } + + public String getLogDetails(List testCases) { + // 更新状态 + if (CollectionUtils.isNotEmpty(testCases)) { + List columns = new LinkedList<>(); + TestCaseExample example = new TestCaseExample(); + List ids = testCases.stream().map(TestCaseReviewTestCase::getCaseId).collect(Collectors.toList()); + example.createCriteria().andIdIn(ids); + List cases = testCaseMapper.selectByExample(example); + if (CollectionUtils.isNotEmpty(cases)) { + List names = cases.stream().map(TestCase::getName).collect(Collectors.toList()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(ids), cases.get(0).getProjectId(), String.join(",", names), cases.get(0).getCreateUser(), columns); + return JSON.toJSONString(details); + } + } + return null; + } + + public String getLogDetails(TestCaseReviewTestCase request) { + TestCaseReview caseReview = testCaseReviewMapper.selectByPrimaryKey(request.getReviewId()); + TestCaseWithBLOBs caseWithBLOBs = testCaseMapper.selectByPrimaryKey(request.getCaseId()); + if (caseWithBLOBs != null) { + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(request.getId()), caseReview.getProjectId(), caseWithBLOBs.getName(), caseReview.getCreateUser(), new LinkedList<>()); + return JSON.toJSONString(details); + } + return null; + } } diff --git a/backend/src/main/java/io/metersphere/xpack b/backend/src/main/java/io/metersphere/xpack index 9a95a444a4..e435fe1d01 160000 --- a/backend/src/main/java/io/metersphere/xpack +++ b/backend/src/main/java/io/metersphere/xpack @@ -1 +1 @@ -Subproject commit 9a95a444a4f0a477427f94bd107571430d85e766 +Subproject commit e435fe1d01a2495481efa58daf3875be07b2ac9b diff --git a/backend/src/main/resources/db/migration/V83__v1.10_release.sql b/backend/src/main/resources/db/migration/V83__v1.10_release.sql index a4c85b21cf..4b4322e0b0 100644 --- a/backend/src/main/resources/db/migration/V83__v1.10_release.sql +++ b/backend/src/main/resources/db/migration/V83__v1.10_release.sql @@ -39,22 +39,6 @@ CREATE TABLE `operating_log` ( PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; --- add all table create_user -ALTER TABLE api_definition - ADD create_user VARCHAR(100) NULL; -ALTER TABLE api_module - ADD create_user VARCHAR(100) NULL; -ALTER TABLE api_scenario - ADD create_user VARCHAR(100) NULL; -ALTER TABLE api_scenario_module - ADD create_user VARCHAR(100) NULL; -ALTER TABLE api_scenario_report - ADD create_user VARCHAR(100) NULL; -ALTER TABLE test_case_node - ADD create_user VARCHAR(100) NULL; -ALTER TABLE test_case - ADD create_user VARCHAR(100) NULL; - -- system_parameter UPDATE system_parameter SET param_key = 'base.prometheus.host' @@ -69,3 +53,19 @@ alter table load_test_report alter table load_test_report add test_duration BIGINT(13) null; + +-- add all table create_user +ALTER TABLE api_definition ADD create_user VARCHAR(100) NULL; +ALTER TABLE api_module ADD create_user VARCHAR(100) NULL; +ALTER TABLE api_scenario ADD create_user VARCHAR(100) NULL; +ALTER TABLE api_scenario_module ADD create_user VARCHAR(100) NULL; +ALTER TABLE api_scenario_report ADD create_user VARCHAR(100) NULL; +ALTER TABLE test_case_node ADD create_user VARCHAR(100) NULL; +ALTER TABLE test_case ADD create_user VARCHAR(100) NULL; +ALTER TABLE test_case_review ADD create_user VARCHAR(100) NULL; +ALTER TABLE test_plan_test_case ADD create_user VARCHAR(100) NULL; +ALTER TABLE test_case_review_test_case ADD create_user VARCHAR(100) NULL; +ALTER TABLE test_plan_api_case ADD create_user VARCHAR(100) NULL; +ALTER TABLE test_plan_api_scenario ADD create_user VARCHAR(100) NULL; +ALTER TABLE test_plan_load_case ADD create_user VARCHAR(100) NULL; +ALTER TABLE test_case_report ADD create_user VARCHAR(100) NULL; diff --git a/backend/src/main/resources/generatorConfig.xml b/backend/src/main/resources/generatorConfig.xml index 7ba2e2a09f..b7ecf47e38 100644 --- a/backend/src/main/resources/generatorConfig.xml +++ b/backend/src/main/resources/generatorConfig.xml @@ -77,7 +77,7 @@
--> -
+
diff --git a/frontend/src/business/components/settings/operatinglog/LogDetail.vue b/frontend/src/business/components/settings/operatinglog/LogDetail.vue index 3a16151a36..7032a54122 100644 --- a/frontend/src/business/components/settings/operatinglog/LogDetail.vue +++ b/frontend/src/business/components/settings/operatinglog/LogDetail.vue @@ -67,6 +67,7 @@ {id: 'BATCH_DEL', label: this.$t('api_test.definition.request.batch_delete')}, {id: 'BATCH_UPDATE', label: this.$t('api_test.definition.request.batch_edit')}, {id: 'BATCH_ADD', label: this.$t('commons.batch_add')}, + {id: 'UN_ASSOCIATE_CASE', label: this.$t('test_track.case.unlink')}, {id: 'BATCH_RESTORE', label: "批量恢复"}, {id: 'BATCH_GC', label: "批量回收"} ], @@ -91,6 +92,7 @@ ['BATCH_ADD', this.$t('commons.batch_add')], ['BATCH_RESTORE', "批量恢复"], ['BATCH_GC', "批量回收"], + ['UN_ASSOCIATE_CASE', this.$t('test_track.case.unlink')], ]) } }, diff --git a/frontend/src/business/components/settings/operatinglog/OperatingLog.vue b/frontend/src/business/components/settings/operatinglog/OperatingLog.vue index a2f64470d1..ba81fd18f7 100644 --- a/frontend/src/business/components/settings/operatinglog/OperatingLog.vue +++ b/frontend/src/business/components/settings/operatinglog/OperatingLog.vue @@ -115,6 +115,7 @@ {id: 'IMPORT', label: this.$t('api_test.api_import.label')}, {id: 'EXPORT', label: this.$t('commons.export')}, {id: 'ASSOCIATE_CASE', label: this.$t('test_track.review_view.relevance_case')}, + {id: 'UN_ASSOCIATE_CASE', label: this.$t('test_track.case.unlink')}, {id: 'REVIEW', label: this.$t('test_track.review_view.start_review')}, {id: 'COPY', label: this.$t('commons.copy')}, {id: 'EXECUTE', label: this.$t('api_test.automation.execute')}, @@ -137,6 +138,7 @@ ['IMPORT', this.$t('api_test.api_import.label')], ['EXPORT', this.$t('commons.export')], ['ASSOCIATE_CASE', this.$t('test_track.review_view.relevance_case')], + ['UN_ASSOCIATE_CASE', this.$t('test_track.case.unlink')], ['REVIEW', this.$t('test_track.review_view.start_review')], ['COPY', this.$t('commons.copy')], ['EXECUTE', this.$t('api_test.automation.execute')], diff --git a/frontend/src/business/components/xpack b/frontend/src/business/components/xpack index 097d3a5a00..e50f046382 160000 --- a/frontend/src/business/components/xpack +++ b/frontend/src/business/components/xpack @@ -1 +1 @@ -Subproject commit 097d3a5a00beaa660d34525765d93b35e63f52c0 +Subproject commit e50f0463826ac4d7837ea3a237333827774a1b19 diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index aed776cc23..0ff6affd66 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -1328,6 +1328,7 @@ export default { batch_move_case: 'Batch move', batch_delete_case: 'Batch delete', batch_unlink: 'Batch Unlink', + unlink: 'Unlink', project_name: "Project", status: 'Review Status', status_prepare: 'Not reviewed', diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 1e3816e30e..ab6e6ed0b3 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -1333,6 +1333,7 @@ export default { batch_move_case: '批量移动', batch_delete_case: '批量删除', batch_unlink: '批量取消关联', + unlink: '取消关联', project_name: '所属项目', status: '评审结果', status_prepare: '未开始', diff --git a/frontend/src/i18n/zh-TW.js b/frontend/src/i18n/zh-TW.js index 3458d58fdf..3eddada5d3 100644 --- a/frontend/src/i18n/zh-TW.js +++ b/frontend/src/i18n/zh-TW.js @@ -1333,6 +1333,7 @@ export default { batch_move_case: '批量移動', batch_delete_case: '批量刪除', batch_unlink: '批量取消關聯', + unlink: '取消關聯', project_name: '所屬項目', status: '評審結果', status_prepare: '未開始',