diff --git a/backend/src/main/java/io/metersphere/api/controller/APITestController.java b/backend/src/main/java/io/metersphere/api/controller/APITestController.java index bf555b0493..7811553000 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APITestController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APITestController.java @@ -94,6 +94,10 @@ public class APITestController { public String runDebug(@RequestPart("request") SaveAPITestRequest request, @RequestPart(value = "file") MultipartFile file, @RequestPart(value = "files") List bodyFiles) { return apiTestService.runDebug(request, file, bodyFiles); } + @PostMapping(value = "/checkName") + public void checkName(@RequestBody SaveAPITestRequest request) { + apiTestService.checkName(request); + } @PostMapping(value = "/import", consumes = {"multipart/form-data"}) @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) diff --git a/backend/src/main/java/io/metersphere/api/service/APITestService.java b/backend/src/main/java/io/metersphere/api/service/APITestService.java index f1fc146c74..ea5690ecae 100644 --- a/backend/src/main/java/io/metersphere/api/service/APITestService.java +++ b/backend/src/main/java/io/metersphere/api/service/APITestService.java @@ -245,6 +245,13 @@ public class APITestService { MSException.throwException(Translator.get("load_test_already_exists")); } } + public void checkName(SaveAPITestRequest request) { + ApiTestExample example = new ApiTestExample(); + example.createCriteria().andNameEqualTo(request.getName()).andProjectIdEqualTo(request.getProjectId()); + if (apiTestMapper.countByExample(example) > 0) { + MSException.throwException(Translator.get("load_test_already_exists")); + } + } private ApiTest updateTest(SaveAPITestRequest request) { checkNameExist(request); diff --git a/backend/src/main/java/io/metersphere/excel/utils/EasyExcelExporter.java b/backend/src/main/java/io/metersphere/excel/utils/EasyExcelExporter.java index be802d3bfb..5a6b39fd20 100644 --- a/backend/src/main/java/io/metersphere/excel/utils/EasyExcelExporter.java +++ b/backend/src/main/java/io/metersphere/excel/utils/EasyExcelExporter.java @@ -1,8 +1,11 @@ package io.metersphere.excel.utils; import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.write.metadata.style.WriteCellStyle; +import com.alibaba.excel.write.style.HorizontalCellStyleStrategy; import io.metersphere.commons.utils.LogUtil; import io.metersphere.exception.ExcelException; +import org.apache.poi.ss.usermodel.IndexedColors; import javax.servlet.http.HttpServletResponse; import java.io.IOException; @@ -29,9 +32,12 @@ public class EasyExcelExporter { public void export(HttpServletResponse response, List data, String fileName, String sheetName) { response.setContentType("application/vnd.ms-excel"); response.setCharacterEncoding("utf-8"); + WriteCellStyle contentWriteCellStyle = new WriteCellStyle(); + contentWriteCellStyle.setWrapped(true); try { + HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(null, contentWriteCellStyle); response.setHeader("Content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8") + ".xlsx"); - EasyExcel.write(response.getOutputStream(), this.clazz).sheet(sheetName).doWrite(data); + EasyExcel.write(response.getOutputStream(), this.clazz).registerWriteHandler(horizontalCellStyleStrategy).sheet(sheetName).doWrite(data); } catch (UnsupportedEncodingException e) { LogUtil.error(e.getMessage(), e); throw new ExcelException("Utf-8 encoding is not supported"); 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 718fdcd05a..76e55cf953 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -224,6 +224,10 @@ public class IssuesService { String account = object.getString("account"); String password = object.getString("password"); String url = object.getString("url"); + String issuetype = object.getString("issuetype"); + if (StringUtils.isBlank(issuetype)) { + MSException.throwException("Jira 问题类型为空"); + } String auth = EncryptUtils.base64Encoding(account + ":" + password); String testCaseId = issuesRequest.getTestCaseId(); @@ -252,8 +256,7 @@ public class IssuesService { " \"summary\":\"" + issuesRequest.getTitle() + "\",\n" + " \"description\": " + JSON.toJSONString(desc) + ",\n" + " \"issuetype\":{\n" + - " \"id\":\"10009\",\n" + - " \"name\":\"Defect\"\n" + + " \"name\":\"" + issuetype + "\"\n" + " }\n" + " }\n" + "}"; diff --git a/frontend/src/business/components/api/test/ApiTestList.vue b/frontend/src/business/components/api/test/ApiTestList.vue index 4366a21153..8c2c7903f6 100644 --- a/frontend/src/business/components/api/test/ApiTestList.vue +++ b/frontend/src/business/components/api/test/ApiTestList.vue @@ -11,12 +11,13 @@ - + + @filter-change="filter" @select-all="select" @select="select"> @@ -59,175 +60,164 @@ diff --git a/frontend/src/business/components/api/test/OneClickOperation.vue b/frontend/src/business/components/api/test/OneClickOperation.vue index 7a1b3285bd..3081b87d8e 100644 --- a/frontend/src/business/components/api/test/OneClickOperation.vue +++ b/frontend/src/business/components/api/test/OneClickOperation.vue @@ -26,7 +26,7 @@ import MsApiScenarioConfig from "./components/ApiScenarioConfig"; import MsApiReportStatus from "../report/ApiReportStatus"; import MsApiReportDialog from "./ApiReportDialog"; - import {getUUID} from "../../../../common/js/utils"; + import {getUUID} from "@/common/js/utils"; export default { @@ -41,6 +41,7 @@ tests: [], ruleForm: {}, change: false, + projectId: "", rule: { testName: [ {required: true, message: this.$t('api_test.input_name'), trigger: 'blur'}, @@ -61,10 +62,10 @@ selectIds: { type: Set }, - selectNames: { + selectProjectNames: { type: Set }, - selectProjectNames: { + selectProjectId: { type: Set } }, @@ -73,26 +74,33 @@ this.oneClickOperationVisible = true; }, checkedSaveAndRunTest() { - if (this.selectNames.has(this.ruleForm.testName)) { - this.selectIds.clear() - this.$warning(this.$t('load_test.already_exists')); - this.oneClickOperationVisible = false; - this.$emit('refresh') - } else { + if (this.ruleForm.testName) { if (this.selectProjectNames.size > 1) { - this.selectIds.clear() this.$warning(this.$t('load_test.same_project_test')); this.oneClickOperationVisible = false; this.$emit('refresh') } else { - for (let x of this.selectIds) { - this.getTest(x) - } + this.checkNameResult(this.ruleForm.testName) } + } else { + this.$warning(this.$t('api_test.input_name')) + } + }, + checkNameResult() { + this.checkName(() => { + for (let x of this.selectIds) { + this.getTest(x) + } + }) + }, + checkName(callback) { + for (let i of this.selectProjectId) { + this.result = this.$post('/api/checkName', {name: this.ruleForm.testName, projectId: i}, () => { + if (callback) callback(); + }) } }, _getEnvironmentAndRunTest: function (item) { - let count = 0; this.result = this.$get('/api/environment/list/' + item.projectId, response => { let environments = response.data; let environmentMap = new Map(); diff --git a/frontend/src/business/components/performance/report/PerformanceReportView.vue b/frontend/src/business/components/performance/report/PerformanceReportView.vue index 573ec9f502..34b33e0bd0 100644 --- a/frontend/src/business/components/performance/report/PerformanceReportView.vue +++ b/frontend/src/business/components/performance/report/PerformanceReportView.vue @@ -22,9 +22,9 @@ @click="rerun(testId)"> {{ $t('report.test_execute_again') }} - +