From a4c6d24e14b3db88e0ed69c86a56e786bb0f7036 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Tue, 25 May 2021 18:24:13 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E6=8E=A5=E5=8F=A3=E7=9B=B8=E5=85=B3=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/sampler/MsHTTPSamplerProxy.java | 10 +- .../api/service/ApiAutomationService.java | 1 - .../api/service/ApiDefinitionService.java | 8 +- .../api/service/ApiScenarioReportService.java | 10 +- .../task/ParallelScenarioExecTask.java | 3 +- .../service/task/SerialScenarioExecTask.java | 3 +- .../commons/constants/OperLogConstants.java | 2 +- .../controller/OrganizationController.java | 5 +- .../controller/UserController.java | 5 +- .../controller/WorkspaceController.java | 7 +- .../log/vo/track/TestCaseReference.java | 1 + .../controller/TestCaseIssuesController.java | 3 + .../track/service/TestCaseIssueService.java | 26 +++++- .../track/service/TestCaseService.java | 92 ++++++++++++++++++- .../scenario/component/ApiComponent.vue | 5 +- .../api/definition/components/ApiConfig.vue | 45 +++++---- .../components/case/ApiCaseItem.vue | 1 + .../api/test/model/ScenarioModel.js | 2 +- .../settings/operatinglog/LogDetail.vue | 2 + .../settings/operatinglog/OperatingLog.vue | 2 + 20 files changed, 172 insertions(+), 61 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java index 87affc6dad..711e12f542 100644 --- a/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java +++ b/backend/src/main/java/io/metersphere/api/dto/definition/request/sampler/MsHTTPSamplerProxy.java @@ -197,6 +197,7 @@ public class MsHTTPSamplerProxy extends MsTestElement { } compatible(config); + HttpConfig httpConfig = null; try { if (config.isEffective(this.getProjectId())) { @@ -204,6 +205,9 @@ public class MsHTTPSamplerProxy extends MsTestElement { if (httpConfig == null && !isURL(this.getUrl())) { MSException.throwException("未匹配到环境,请检查环境配置"); } + if(StringUtils.isEmpty(httpConfig.getProtocol())){ + MSException.throwException(this.getName() +"接口,对应的环境无协议,请完善环境信息"); + } if (StringUtils.isEmpty(this.useEnvironment)) { this.useEnvironment = config.getConfig().get(this.getProjectId()).getApiEnvironmentid(); } @@ -428,11 +432,11 @@ public class MsHTTPSamplerProxy extends MsTestElement { } // 数据兼容处理 - if (config.getConfig() != null && config.getConfig().containsKey(getParentProjectId())) { + if (config.getConfig() != null && StringUtils.isNotEmpty(this.getProjectId()) && config.getConfig().containsKey(this.getProjectId())) { + // 1.8 之后 当前正常数据 + } else if (config.getConfig() != null && config.getConfig().containsKey(getParentProjectId())) { // 1.8 前后 混合数据 this.setProjectId(getParentProjectId()); - } else if (config.getConfig() != null && StringUtils.isNotEmpty(this.getProjectId()) && config.getConfig().containsKey(this.getProjectId())) { - // 1.8 之后 当前正常数据 } else { // 1.8 之前 数据 if (config.getConfig() != null) { 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 ddf2cd45ee..5ba58d30ad 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -883,7 +883,6 @@ public class ApiAutomationService { request.setTriggerMode(ReportTriggerMode.MANUAL.name()); } String reportId = request.getId(); - Map map = new LinkedHashMap<>(); List scenarioIds = new ArrayList<>(); StringBuilder scenarioNames = new StringBuilder(); 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 9d4e4472e4..073e1cc70c 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -569,9 +569,11 @@ public class ApiDefinitionService { Map map = request.getEnvironmentMap(); if (map != null && map.size() > 0) { ApiTestEnvironmentWithBLOBs environment = environmentService.get(map.get(request.getProjectId())); - EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class); - envConfig.put(request.getProjectId(), env); - config.setConfig(envConfig); + if (environment != null) { + EnvironmentConfig env = JSONObject.parseObject(environment.getConfig(), EnvironmentConfig.class); + envConfig.put(request.getProjectId(), env); + config.setConfig(envConfig); + } } diff --git a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java index dc7db86f3f..914eff2d6c 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiScenarioReportService.java @@ -326,8 +326,12 @@ public class ApiScenarioReportService { */ private void updateScenarioStatus(String reportId) { if (StringUtils.isNotEmpty(reportId)) { - List list = new ArrayList<>(); - list.add(reportId); + List list = new LinkedList<>(); + try { + list = JSON.parseObject(reportId, List.class); + } catch (Exception e) { + list.add(reportId); + } ApiScenarioReportExample scenarioReportExample = new ApiScenarioReportExample(); scenarioReportExample.createCriteria().andIdIn(list); List reportList = apiScenarioReportMapper.selectByExample(scenarioReportExample); @@ -336,7 +340,7 @@ public class ApiScenarioReportService { if (CollectionUtils.isNotEmpty(reportList)) { reportList.forEach(report -> { report.setUpdateTime(System.currentTimeMillis()); - String status = "Success"; + String status = "Error"; report.setStatus(status); scenarioReportMapper.updateByPrimaryKeySelective(report); // 把上一条调试的数据内容清空 diff --git a/backend/src/main/java/io/metersphere/api/service/task/ParallelScenarioExecTask.java b/backend/src/main/java/io/metersphere/api/service/task/ParallelScenarioExecTask.java index fe31622bb9..afa7bc22be 100644 --- a/backend/src/main/java/io/metersphere/api/service/task/ParallelScenarioExecTask.java +++ b/backend/src/main/java/io/metersphere/api/service/task/ParallelScenarioExecTask.java @@ -3,7 +3,6 @@ */ package io.metersphere.api.service.task; -import com.alibaba.fastjson.JSON; import io.metersphere.api.dto.automation.RunScenarioRequest; import io.metersphere.api.jmeter.JMeterService; import io.metersphere.commons.exception.MSException; @@ -28,7 +27,7 @@ public class ParallelScenarioExecTask implements Callable { @Override public T call() { try { - jMeterService.runSerial(JSON.toJSONString(id), hashTree, request.getReportId(), request.getRunMode(), request.getConfig()); + jMeterService.runSerial(id, hashTree, request.getReportId(), request.getRunMode(), request.getConfig()); return null; } catch (Exception ex) { LogUtil.error(ex.getMessage()); diff --git a/backend/src/main/java/io/metersphere/api/service/task/SerialScenarioExecTask.java b/backend/src/main/java/io/metersphere/api/service/task/SerialScenarioExecTask.java index c9a8bbff81..a61202d935 100644 --- a/backend/src/main/java/io/metersphere/api/service/task/SerialScenarioExecTask.java +++ b/backend/src/main/java/io/metersphere/api/service/task/SerialScenarioExecTask.java @@ -3,7 +3,6 @@ */ package io.metersphere.api.service.task; -import com.alibaba.fastjson.JSON; import io.metersphere.api.dto.automation.RunScenarioRequest; import io.metersphere.api.jmeter.JMeterService; import io.metersphere.base.domain.ApiScenarioReport; @@ -34,7 +33,7 @@ public class SerialScenarioExecTask implements Callable { @Override public T call() { try { - jMeterService.runSerial(JSON.toJSONString(id), hashTree, request.getReportId(), request.getRunMode(), request.getConfig()); + jMeterService.runSerial(id, hashTree, request.getReportId(), request.getRunMode(), request.getConfig()); // 轮询查看报告状态,最多200次,防止死循环 int index = 1; while (index < 200) { 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 e5336757c2..24dfb42490 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, UN_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, ASSOCIATE_ISSUE, UN_ASSOCIATE_CASE, REVIEW, COPY, EXECUTE, SHARE, LOGIN, CREATE_PRE_TEST, OTHER } diff --git a/backend/src/main/java/io/metersphere/controller/OrganizationController.java b/backend/src/main/java/io/metersphere/controller/OrganizationController.java index 9ee8681d35..97698a73a3 100644 --- a/backend/src/main/java/io/metersphere/controller/OrganizationController.java +++ b/backend/src/main/java/io/metersphere/controller/OrganizationController.java @@ -4,7 +4,6 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.Organization; 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.controller.request.OrganizationRequest; @@ -13,8 +12,6 @@ import io.metersphere.dto.OrganizationResource; import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.service.OrganizationService; import io.metersphere.service.UserService; -import org.apache.shiro.authz.annotation.Logical; -import org.apache.shiro.authz.annotation.RequiresRoles; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -67,7 +64,7 @@ public class OrganizationController { } @PostMapping("/member/update") - @MsAuditLog(module = "organization_member", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#memberDTO.id)", content = "#msClass.getLogDetails(#memberDTO.id)", msClass = OrganizationService.class) + @MsAuditLog(module = "organization_member", type = OperLogConstants.UPDATE, content = "#msClass.getLogDetails(#memberDTO)", msClass = OrganizationService.class) public void updateOrgMember(@RequestBody OrganizationMemberDTO memberDTO) { organizationService.updateOrgMember(memberDTO); } diff --git a/backend/src/main/java/io/metersphere/controller/UserController.java b/backend/src/main/java/io/metersphere/controller/UserController.java index f11d4b1990..edecc2b5b5 100644 --- a/backend/src/main/java/io/metersphere/controller/UserController.java +++ b/backend/src/main/java/io/metersphere/controller/UserController.java @@ -83,7 +83,7 @@ public class UserController { } @PostMapping("/special/update") - @MsAuditLog(module = "system_user", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#user.id)", content = "#msClass.getLogDetails(#user.id)", msClass = UserService.class) + @MsAuditLog(module = "system_user", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#user)", content = "#msClass.getLogDetails(#user)", msClass = UserService.class) public void updateUser(@RequestBody UserRequest user) { userService.updateUserRole(user); } @@ -254,7 +254,7 @@ public class UserController { * 添加组织成员 */ @PostMapping("/org/member/add") - @MsAuditLog(module = "organization_member", type = OperLogConstants.CREATE, title = "添加组织成员") + @MsAuditLog(module = "organization_member", type = OperLogConstants.CREATE, title = "'添加组织成员-'+#request.userIds") public void addOrganizationMember(@RequestBody AddOrgMemberRequest request) { organizationService.checkOrgOwner(request.getOrganizationId()); userService.addOrganizationMember(request); @@ -331,6 +331,7 @@ public class UserController { } @PostMapping("/import/{userId}") + @MsAuditLog(module = "system_user", type = OperLogConstants.IMPORT) public ExcelResponse testCaseImport(MultipartFile file, @PathVariable String userId, HttpServletRequest request) { return userService.userImport(file, userId, request); } diff --git a/backend/src/main/java/io/metersphere/controller/WorkspaceController.java b/backend/src/main/java/io/metersphere/controller/WorkspaceController.java index c5aaa5e364..90626a38c5 100644 --- a/backend/src/main/java/io/metersphere/controller/WorkspaceController.java +++ b/backend/src/main/java/io/metersphere/controller/WorkspaceController.java @@ -4,7 +4,6 @@ import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.Workspace; 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; @@ -15,8 +14,6 @@ import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.service.OrganizationService; import io.metersphere.service.UserService; import io.metersphere.service.WorkspaceService; -import org.apache.shiro.authz.annotation.Logical; -import org.apache.shiro.authz.annotation.RequiresRoles; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -65,7 +62,7 @@ public class WorkspaceController { } @GetMapping("special/delete/{workspaceId}") - @MsAuditLog(module = "system_workspace", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#workspaceId)", msClass = WorkspaceService.class) + @MsAuditLog(module = "system_workspace", type = OperLogConstants.DELETE, beforeEvent = "#msClass.getLogDetails(#workspaceId)", msClass = WorkspaceService.class) public void deleteWorkspaceByAdmin(@PathVariable String workspaceId) { userService.refreshSessionUser("workspace", workspaceId); workspaceService.deleteWorkspace(workspaceId); @@ -104,7 +101,7 @@ public class WorkspaceController { } @PostMapping("/member/update") - @MsAuditLog(module = "workspace_member", type = OperLogConstants.UPDATE, title = "#memberDTO.name") + @MsAuditLog(module = "workspace_member", type = OperLogConstants.UPDATE, beforeEvent = "#msClass.getLogDetails(#memberDTO)", content = "#msClass.getLogDetails(#memberDTO)", msClass = WorkspaceService.class) public void updateOrgMember(@RequestBody WorkspaceMemberDTO memberDTO) { workspaceService.updateWorkspaceMember(memberDTO); } 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 c66ceb010c..32b9f2ea87 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 @@ -27,6 +27,7 @@ public class TestCaseReference { testCaseColumns.put("status", "用例状态"); testCaseColumns.put("stepDescription", "步骤描述"); testCaseColumns.put("expectedResult", "预期结果"); + testCaseColumns.put("demandName", "关联需求"); testCaseColumns.put("comment", "评论"); testCaseColumns.put("ms-dff-col", "tags"); diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java index 808afa85b4..d0a8237fae 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseIssuesController.java @@ -1,5 +1,7 @@ package io.metersphere.track.controller; +import io.metersphere.commons.constants.OperLogConstants; +import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.track.dto.TestCaseDTO; import io.metersphere.track.request.issues.IssuesRelevanceRequest; import io.metersphere.track.service.TestCaseIssueService; @@ -24,6 +26,7 @@ public class TestCaseIssuesController { } @PostMapping("/relate") + @MsAuditLog(module = "track_test_case", type = OperLogConstants.ASSOCIATE_ISSUE, content = "#msClass.getLogDetails(#request)", msClass = TestCaseIssueService.class) public void relate(@RequestBody IssuesRelevanceRequest request) { testCaseIssueService.relate(request); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseIssueService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseIssueService.java index 3222a533c7..639eb8f47a 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseIssueService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseIssueService.java @@ -1,9 +1,10 @@ package io.metersphere.track.service; -import io.metersphere.base.domain.TestCaseIssues; -import io.metersphere.base.domain.TestCaseIssuesExample; +import com.alibaba.fastjson.JSON; +import io.metersphere.base.domain.*; import io.metersphere.base.mapper.IssuesMapper; import io.metersphere.base.mapper.TestCaseIssuesMapper; +import io.metersphere.log.vo.OperatingLogDetails; import io.metersphere.track.dto.TestCaseDTO; import io.metersphere.track.request.issues.IssuesRelevanceRequest; import org.apache.commons.lang3.StringUtils; @@ -13,6 +14,7 @@ import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; +import java.util.LinkedList; import java.util.List; import java.util.UUID; import java.util.stream.Collectors; @@ -56,9 +58,9 @@ public class TestCaseIssueService { } public List getTestCaseIdsByIssuesId(String issuesId) { - return getTestCaseIssuesByIssuesId(issuesId).stream() - .map(TestCaseIssues::getTestCaseId) - .collect(Collectors.toList()); + return getTestCaseIssuesByIssuesId(issuesId).stream() + .map(TestCaseIssues::getTestCaseId) + .collect(Collectors.toList()); } public void relate(IssuesRelevanceRequest request) { @@ -86,4 +88,18 @@ public class TestCaseIssueService { testCaseIssues.setIssuesId(issueId); testCaseIssuesMapper.insert(testCaseIssues); } + + + public String getLogDetails(IssuesRelevanceRequest request) { + TestCaseWithBLOBs bloBs = testCaseService.getTestCase(request.getCaseId()); + if (bloBs != null) { + IssuesExample example = new IssuesExample(); + example.createCriteria().andIdIn(request.getIssueIds()); + List issues = issuesMapper.selectByExample(example); + List names = issues.stream().map(Issues::getTitle).collect(Collectors.toList()); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(request.getIssueIds()), bloBs.getProjectId(), bloBs.getName() + " 关联 " + names, bloBs.getCreateUser(), new LinkedList<>()); + return JSON.toJSONString(details); + } + return null; + } } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 30802a4a09..32d42eb65e 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -8,7 +8,6 @@ import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.ExtTestCaseMapper; -import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.constants.TestCaseConstants; import io.metersphere.commons.constants.TestCaseReviewStatus; import io.metersphere.commons.constants.UserGroupType; @@ -93,7 +92,7 @@ public class TestCaseService { TestCaseNodeService testCaseNodeService; @Resource - UserRoleMapper userRoleMapper; + ApiTestCaseMapper apiTestCaseMapper; @Resource TestCaseIssueService testCaseIssueService; @@ -111,6 +110,14 @@ public class TestCaseService { private GroupMapper groupMapper; @Resource private UserGroupMapper userGroupMapper; + @Resource + private LoadTestMapper loadTestMapper; + @Resource + private ApiScenarioMapper apiScenarioMapper; + @Resource + private TestCaseIssuesMapper testCaseIssuesMapper; + @Resource + private IssuesMapper issuesMapper; private void setNode(TestCaseWithBLOBs testCase) { if (StringUtils.isEmpty(testCase.getNodeId()) || "default-module".equals(testCase.getNodeId())) { @@ -1267,13 +1274,88 @@ public class TestCaseService { TestCaseWithBLOBs bloBs = testCaseMapper.selectByPrimaryKey(id); if (bloBs != null) { List columns = ReflexObjectUtil.getColumns(bloBs, TestCaseReference.testCaseColumns); + // 关联内容用例内容 + TestCaseTestExample example = new TestCaseTestExample(); + example.createCriteria().andTestCaseIdEqualTo(id); + List testCaseTests = testCaseTestMapper.selectByExample(example); + StringBuilder nameBuilder = new StringBuilder(); + if (CollectionUtils.isNotEmpty(testCaseTests)) { + List testCaseIds = testCaseTests.stream() + .filter(user -> user.getTestType().equals("testcase")).map(TestCaseTest::getTestId) + .collect(Collectors.toList()); + + List performanceIds = testCaseTests.stream() + .filter(user -> user.getTestType().equals("performance")).map(TestCaseTest::getTestId) + .collect(Collectors.toList()); + + List automationIds = testCaseTests.stream() + .filter(user -> user.getTestType().equals("automation")).map(TestCaseTest::getTestId) + .collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(testCaseIds)) { + ApiTestCaseExample testCaseExample = new ApiTestCaseExample(); + testCaseExample.createCriteria().andIdIn(testCaseIds); + List testCases = apiTestCaseMapper.selectByExample(testCaseExample); + List caseNames = testCases.stream().map(ApiTestCase::getName).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(caseNames)) { + nameBuilder.append("接口用例:").append("\n").append(caseNames).append("\n"); + } + } + if (CollectionUtils.isNotEmpty(performanceIds)) { + LoadTestExample loadTestExample = new LoadTestExample(); + loadTestExample.createCriteria().andIdIn(performanceIds); + List loadTests = loadTestMapper.selectByExample(loadTestExample); + List caseNames = loadTests.stream().map(LoadTest::getName).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(caseNames)) { + nameBuilder.append("性能用例:").append("\n").append(caseNames).append("\n"); + } + } + if (CollectionUtils.isNotEmpty(automationIds)) { + ApiScenarioExample scenarioExample = new ApiScenarioExample(); + scenarioExample.createCriteria().andIdIn(automationIds); + List scenarios = apiScenarioMapper.selectByExample(scenarioExample); + List caseNames = scenarios.stream().map(ApiScenario::getName).collect(Collectors.toList()); + if (CollectionUtils.isNotEmpty(caseNames)) { + nameBuilder.append("自动化用例:").append("\n").append(caseNames).append("\n"); + } + } + } + DetailColumn column = new DetailColumn("关联测试", "testcase", nameBuilder.toString(), null); + columns.add(column); + + //关联缺陷 + List issuesNames = new LinkedList<>(); + TestCaseIssuesExample testCaseIssuesExample = new TestCaseIssuesExample(); + testCaseIssuesExample.createCriteria().andTestCaseIdEqualTo(bloBs.getId()); + List testCaseIssues = testCaseIssuesMapper.selectByExample(testCaseIssuesExample); + if (CollectionUtils.isNotEmpty(testCaseIssues)) { + List issuesIds = testCaseIssues.stream().map(TestCaseIssues::getIssuesId).collect(Collectors.toList()); + IssuesExample issuesExample = new IssuesExample(); + issuesExample.createCriteria().andIdIn(issuesIds); + List issues = issuesMapper.selectByExample(issuesExample); + if (CollectionUtils.isNotEmpty(issues)) { + issuesNames = issues.stream().map(Issues::getTitle).collect(Collectors.toList()); + } + } + DetailColumn issuesColumn = new DetailColumn("关联缺陷 ", "issues", String.join(",", issuesNames), null); + columns.add(issuesColumn); + //附件 + List originFiles = fileService.getFileMetadataByCaseId(id); + List fileNames = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(originFiles)) { + fileNames = originFiles.stream().map(FileMetadata::getName).collect(Collectors.toList()); + } + DetailColumn fileColumn = new DetailColumn("附件 ", "files", String.join(",", fileNames), null); + columns.add(fileColumn); + // 增加评论内容 List dtos = testCaseCommentService.getCaseComments(id); + List names = new LinkedList<>(); if (CollectionUtils.isNotEmpty(dtos)) { - List names = dtos.stream().map(TestCaseCommentDTO::getDescription).collect(Collectors.toList()); - DetailColumn detailColumn = new DetailColumn("评论", "comment", String.join("\n", names), null); - columns.add(detailColumn); + names = dtos.stream().map(TestCaseCommentDTO::getDescription).collect(Collectors.toList()); } + DetailColumn detailColumn = new DetailColumn("评论", "comment", String.join("\n", names), null); + columns.add(detailColumn); + OperatingLogDetails details = new OperatingLogDetails(JSON.toJSONString(id), bloBs.getProjectId(), bloBs.getName(), bloBs.getCreateUser(), columns); return JSON.toJSONString(details); } diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index a513116fb1..92e1223192 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -77,7 +77,7 @@ + @runRefresh="runRefresh" @errorRefresh="errorRefresh" ref="runTest"/> @@ -371,6 +371,9 @@ /*触发执行操作*/ this.reportId = getUUID(); }, + errorRefresh(){ + this.loading = false; + }, runRefresh(data) { this.request.requestResult = data; this.request.result = undefined; diff --git a/frontend/src/business/components/api/definition/components/ApiConfig.vue b/frontend/src/business/components/api/definition/components/ApiConfig.vue index 3318da3d5d..ab002f3e3d 100644 --- a/frontend/src/business/components/api/definition/components/ApiConfig.vue +++ b/frontend/src/business/components/api/definition/components/ApiConfig.vue @@ -26,29 +26,29 @@