From d07153a182c6490822450289a72cf237944f0b3d Mon Sep 17 00:00:00 2001 From: song-tianyang Date: Fri, 25 Jun 2021 18:12:28 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=A1=88=E4=BE=8B=E8=AF=84=E5=AE=A1?= =?UTF-8?q?=EF=BC=8C=E5=9C=BA=E6=99=AF):=20=E8=AF=84=E5=AE=A1=E8=AF=84?= =?UTF-8?q?=E8=AE=BA=E5=8F=AF=E4=BB=A5=E5=A2=9E=E5=8A=A0=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E3=80=81=E8=A1=A8=E5=A4=B4=E6=93=8D=E4=BD=9C=E5=88=97=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4=E5=B9=B6=E5=AD=98?= =?UTF-8?q?=E5=82=A8=E4=B8=8A=E4=B8=80=E6=AC=A1=E7=9A=84=E6=8E=92=E5=BA=8F?= =?UTF-8?q?=E6=96=B9=E5=BC=8F=E3=80=81=E5=9C=BA=E6=99=AF=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=89=B9=E9=87=8F=E5=A4=8D=E5=88=B6=E6=8C=89=E9=92=AE=E3=80=81?= =?UTF-8?q?=E8=B4=9F=E8=B4=A3=E4=BA=BA=E5=B0=86=E5=90=8D=E7=A7=B0=E5=92=8C?= =?UTF-8?q?ID=E4=BD=8D=E7=BD=AE=E4=BA=92=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 评审评论可以增加图片、表头操作列增加创建时间并存储上一次的排序方式、场景增加批量复制按钮、负责人将名称和ID位置互换 --- .../controller/ApiAutomationController.java | 11 +- .../api/service/ApiAutomationService.java | 61 ++++++++++ .../base/mapper/ext/ExtApiScenarioMapper.xml | 1 - backend/src/main/resources/permission.json | 5 + .../automation/scenario/ApiScenarioList.vue | 58 +++++++++- .../components/list/ApiCaseSimpleList.vue | 35 +++++- .../definition/components/list/ApiList.vue | 36 +++++- .../common/components/table/MsTable.vue | 1 + .../report/PerformanceTestReportList.vue | 27 ++++- .../performance/test/PerformanceTestList.vue | 27 ++++- .../template/CustomFiledComponent.vue | 2 +- .../track/case/components/TestCaseList.vue | 37 +++++- .../components/track/issue/IssueList.vue | 36 +++++- .../track/plan/components/TestPlanList.vue | 34 +++++- .../report/components/TestPlanReportList.vue | 28 ++++- .../track/review/commom/ReviewComment.vue | 109 ++++++++++++++---- .../track/review/commom/ReviewCommentItem.vue | 82 ++++++++++++- .../review/components/TestCaseReviewList.vue | 27 ++++- .../components/TestReviewTestCaseEdit.vue | 6 +- .../src/common/js/default-table-header.js | 8 +- frontend/src/common/js/tableUtils.js | 15 +++ frontend/src/i18n/en-US.js | 3 + frontend/src/i18n/zh-CN.js | 3 + frontend/src/i18n/zh-TW.js | 3 + 24 files changed, 603 insertions(+), 52 deletions(-) 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 7496257938..25df856dd9 100644 --- a/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java +++ b/backend/src/main/java/io/metersphere/api/controller/ApiAutomationController.java @@ -10,20 +10,16 @@ import io.metersphere.api.service.ApiAutomationService; import io.metersphere.base.domain.ApiScenario; import io.metersphere.base.domain.ApiScenarioWithBLOBs; import io.metersphere.base.domain.Schedule; -import io.metersphere.base.domain.UserGroup; import io.metersphere.commons.constants.ApiRunMode; import io.metersphere.commons.constants.OperLogConstants; import io.metersphere.commons.constants.PermissionConstants; import io.metersphere.commons.constants.TriggerMode; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; -import io.metersphere.commons.utils.SessionUtils; import io.metersphere.controller.request.ScheduleRequest; import io.metersphere.log.annotation.MsAuditLog; import io.metersphere.track.request.testcase.ApiCaseRelevanceRequest; import io.metersphere.track.request.testplan.FileOperationRequest; -import org.apache.commons.lang3.StringUtils; -import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; @@ -32,9 +28,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; -import java.util.HashMap; import java.util.List; -import java.util.stream.Collectors; @RestController @RequestMapping(value = "/api/automation") @@ -251,6 +245,11 @@ public class ApiAutomationController { public List batchGenPerformanceTestJmx(@RequestBody ApiScenarioBatchRequest request) { return apiAutomationService.batchGenPerformanceTestJmx(request); } + @PostMapping("/batchCopy") + public void batchCopy(@RequestBody ApiScenarioBatchRequest request) { + apiAutomationService.batchCopy(request); + } + @PostMapping("/file/download") public ResponseEntity download(@RequestBody FileOperationRequest fileOperationRequest) { 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 4cb2129ef9..6f45ec6cf1 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -315,6 +315,20 @@ public class ApiAutomationService { } } + private boolean isCustomNumExist(ApiScenarioWithBLOBs blobs) { + ApiScenarioExample example = new ApiScenarioExample(); + example.createCriteria() + .andCustomNumEqualTo(blobs.getCustomNum()) + .andProjectIdEqualTo(blobs.getProjectId()) + .andIdNotEqualTo(blobs.getId()); + List list = apiScenarioMapper.selectByExample(example); + if (CollectionUtils.isNotEmpty(list)) { + return true; + }else { + return false; + } + } + private int getNextNum(String projectId) { ApiScenario apiScenario = extApiScenarioMapper.getNextNum(projectId); if (apiScenario == null) { @@ -2149,4 +2163,51 @@ public class ApiAutomationService { return returnList; } } + + public void batchCopy(ApiScenarioBatchRequest batchRequest) { + + ServiceUtils.getSelectAllIds(batchRequest, batchRequest.getCondition(), + (query) -> extApiScenarioMapper.selectIdsByQuery((ApiScenarioRequest) query)); + List apiScenarioList = extApiScenarioMapper.selectIds(batchRequest.getIds()); + for (ApiScenarioWithBLOBs apiModel:apiScenarioList) { + ApiScenarioWithBLOBs newModel = apiModel; + newModel.setId(UUID.randomUUID().toString()); + newModel.setName("copy_"+apiModel.getName()); + newModel.setCreateTime(System.currentTimeMillis()); + newModel.setNum(getNextNum(newModel.getProjectId())); + + ApiScenarioExample example = new ApiScenarioExample(); + example.createCriteria().andNameEqualTo(newModel.getName()). + andProjectIdEqualTo(newModel.getProjectId()).andStatusNotEqualTo("Trash").andIdNotEqualTo(newModel.getId()); + if (apiScenarioMapper.countByExample(example) > 0) { + continue; + }else { + boolean insertFlag = true; + if (StringUtils.isNotBlank(newModel.getCustomNum())) { + insertFlag = false; + String projectId = newModel.getProjectId(); + Project project = projectMapper.selectByPrimaryKey(projectId); + if (project != null) { + Boolean customNum = project.getScenarioCustomNum(); + // 未开启自定义ID + if (!customNum) { + insertFlag = true; + newModel.setCustomNum(null); + } else { + boolean isCustomNumExist = true; + try { + isCustomNumExist = this.isCustomNumExist(newModel); + }catch (Exception e){} + insertFlag = !isCustomNumExist; + } + } + } + + if(insertFlag){ + apiScenarioMapper.insert(newModel); + } + } + } +// uploadFiles(request, bodyFiles, scenarioFiles); + } } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml index 349e74fcfc..e4508263e0 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.xml @@ -374,7 +374,6 @@ from api_scenario left join project on api_scenario.project_id = project.id -