From a471f3c806a1197bfd7b8c57047507b1e1903577 Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Thu, 6 May 2021 18:06:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=8E=A5=E5=8F=A3=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96):=20=E5=9C=BA=E6=99=AFID=E8=87=AA=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../automation/SaveApiScenarioRequest.java | 2 + .../api/service/ApiAutomationService.java | 44 +++++++++++- .../metersphere/base/domain/ApiScenario.java | 2 + .../base/domain/ApiScenarioExample.java | 70 +++++++++++++++++++ .../io/metersphere/base/domain/Project.java | 2 + .../base/domain/ProjectExample.java | 60 ++++++++++++++++ .../base/mapper/ApiScenarioMapper.xml | 33 +++++++-- .../metersphere/base/mapper/ProjectMapper.xml | 25 +++++-- .../base/mapper/ext/ExtApiScenarioMapper.java | 2 + .../base/mapper/ext/ExtApiScenarioMapper.xml | 8 ++- .../base/mapper/ext/ExtProjectMapper.xml | 3 +- .../ext/ExtTestPlanScenarioCaseMapper.xml | 7 +- .../metersphere/service/ProjectService.java | 14 ++-- .../db/migration/V81__v1.9.1_release.sql | 5 +- .../api/automation/ApiAutomation.vue | 15 +++- .../automation/scenario/ApiScenarioList.vue | 18 ++++- .../automation/scenario/EditApiScenario.vue | 15 +++- .../components/settings/project/MsProject.vue | 3 + .../comonents/api/TestPlanApiScenarioList.vue | 2 +- 19 files changed, 301 insertions(+), 29 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiScenarioRequest.java b/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiScenarioRequest.java index bdfa94144b..e48e375e13 100644 --- a/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiScenarioRequest.java +++ b/backend/src/main/java/io/metersphere/api/dto/automation/SaveApiScenarioRequest.java @@ -54,4 +54,6 @@ public class SaveApiScenarioRequest { private List unSelectIds; + private String customNum; + } 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 71523d95c5..4500f158d5 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiAutomationService.java @@ -43,6 +43,7 @@ import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testplan.FileOperationRequest; import io.metersphere.track.service.TestPlanScenarioCaseService; import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.apache.ibatis.session.ExecutorType; import org.apache.ibatis.session.SqlSession; @@ -112,6 +113,8 @@ public class ApiAutomationService { private SystemParameterService systemParameterService; @Resource private ApiScenarioReportService apiScenarioReportService; + @Resource + private ProjectMapper projectMapper; public ApiScenarioWithBLOBs getDto(String id) { return apiScenarioMapper.selectByPrimaryKey(id); @@ -225,7 +228,7 @@ public class ApiAutomationService { public ApiScenario create(SaveApiScenarioRequest request, List bodyFiles) { request.setId(UUID.randomUUID().toString()); checkNameExist(request); - + checkScenarioNum(request); final ApiScenarioWithBLOBs scenario = buildSaveScenario(request); scenario.setCreateTime(System.currentTimeMillis()); @@ -241,6 +244,34 @@ public class ApiAutomationService { return scenario; } + private void checkScenarioNum(SaveApiScenarioRequest request) { + if (StringUtils.isNotBlank(request.getCustomNum())) { + String projectId = request.getProjectId(); + Project project = projectMapper.selectByPrimaryKey(projectId); + if (project != null) { + Boolean customNum = project.getCustomNum(); + // 未开启自定义ID + if (!customNum) { + request.setCustomNum(null); + } else { + checkCustomNumExist(request); + } + } else { + MSException.throwException("add scenario fail, project is not find."); + } + } + } + + private void checkCustomNumExist(SaveApiScenarioRequest request) { + ApiScenarioExample example = new ApiScenarioExample(); + example.createCriteria().andCustomNumEqualTo(request.getCustomNum()) + .andIdNotEqualTo(request.getId()); + List list = apiScenarioMapper.selectByExample(example); + if (CollectionUtils.isNotEmpty(list)) { + MSException.throwException("自定义ID已存在!"); + } + } + private int getNextNum(String projectId) { ApiScenario apiScenario = extApiScenarioMapper.getNextNum(projectId); if (apiScenario == null) { @@ -252,6 +283,7 @@ public class ApiAutomationService { public void update(SaveApiScenarioRequest request, List bodyFiles) { checkNameExist(request); + checkScenarioNum(request); List bodyUploadIds = request.getBodyUploadIds(); FileUtils.createBodyFiles(bodyUploadIds, bodyFiles); @@ -268,6 +300,7 @@ public class ApiAutomationService { scenario.setId(request.getId()); scenario.setName(request.getName()); scenario.setProjectId(request.getProjectId()); + scenario.setCustomNum(request.getCustomNum()); if (StringUtils.equals(request.getTags(), "[]")) { scenario.setTags(""); } else { @@ -1430,8 +1463,10 @@ public class ApiAutomationService { ApiScenarioMapper batchMapper = sqlSession.getMapper(ApiScenarioMapper.class); List data = apiImport.getData(); int num = 0; + Project project = new Project(); if (!CollectionUtils.isEmpty(data) && data.get(0) != null && data.get(0).getProjectId() != null) { num = getNextNum(data.get(0).getProjectId()); + project = projectMapper.selectByPrimaryKey(data.get(0).getProjectId()); } for (int i = 0; i < data.size(); i++) { ApiScenarioWithBLOBs item = data.get(i); @@ -1439,6 +1474,9 @@ public class ApiAutomationService { item.setName(item.getName().substring(0, 255)); } item.setNum(num++); + if (BooleanUtils.isTrue(project.getScenarioCustomNum())) { + item.setCustomNum(String.valueOf(num)); + } importCreate(item, batchMapper, request); if (i % 300 == 0) { sqlSession.flushStatements(); @@ -1715,4 +1753,8 @@ public class ApiAutomationService { } return returnList; } + + public void updateCustomNumByProjectId(String id) { + extApiScenarioMapper.updateCustomNumByProjectId(id); + } } diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiScenario.java b/backend/src/main/java/io/metersphere/base/domain/ApiScenario.java index 8268740cce..b758cadce1 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiScenario.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiScenario.java @@ -45,5 +45,7 @@ public class ApiScenario implements Serializable { private String originalState; + private String customNum; + private static final long serialVersionUID = 1L; } \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioExample.java b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioExample.java index 9aaff91c8d..1450f83426 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ApiScenarioExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/ApiScenarioExample.java @@ -1463,6 +1463,76 @@ public class ApiScenarioExample { addCriterion("original_state not between", value1, value2, "originalState"); return (Criteria) this; } + + public Criteria andCustomNumIsNull() { + addCriterion("custom_num is null"); + return (Criteria) this; + } + + public Criteria andCustomNumIsNotNull() { + addCriterion("custom_num is not null"); + return (Criteria) this; + } + + public Criteria andCustomNumEqualTo(String value) { + addCriterion("custom_num =", value, "customNum"); + return (Criteria) this; + } + + public Criteria andCustomNumNotEqualTo(String value) { + addCriterion("custom_num <>", value, "customNum"); + return (Criteria) this; + } + + public Criteria andCustomNumGreaterThan(String value) { + addCriterion("custom_num >", value, "customNum"); + return (Criteria) this; + } + + public Criteria andCustomNumGreaterThanOrEqualTo(String value) { + addCriterion("custom_num >=", value, "customNum"); + return (Criteria) this; + } + + public Criteria andCustomNumLessThan(String value) { + addCriterion("custom_num <", value, "customNum"); + return (Criteria) this; + } + + public Criteria andCustomNumLessThanOrEqualTo(String value) { + addCriterion("custom_num <=", value, "customNum"); + return (Criteria) this; + } + + public Criteria andCustomNumLike(String value) { + addCriterion("custom_num like", value, "customNum"); + return (Criteria) this; + } + + public Criteria andCustomNumNotLike(String value) { + addCriterion("custom_num not like", value, "customNum"); + return (Criteria) this; + } + + public Criteria andCustomNumIn(List values) { + addCriterion("custom_num in", values, "customNum"); + return (Criteria) this; + } + + public Criteria andCustomNumNotIn(List values) { + addCriterion("custom_num not in", values, "customNum"); + return (Criteria) this; + } + + public Criteria andCustomNumBetween(String value1, String value2) { + addCriterion("custom_num between", value1, value2, "customNum"); + return (Criteria) this; + } + + public Criteria andCustomNumNotBetween(String value1, String value2) { + addCriterion("custom_num not between", value1, value2, "customNum"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/domain/Project.java b/backend/src/main/java/io/metersphere/base/domain/Project.java index 8dff99cf43..a83a00ebcb 100644 --- a/backend/src/main/java/io/metersphere/base/domain/Project.java +++ b/backend/src/main/java/io/metersphere/base/domain/Project.java @@ -31,6 +31,8 @@ public class Project implements Serializable { private Boolean customNum; + private Boolean scenarioCustomNum; + private static final long serialVersionUID = 1L; private String protocal; diff --git a/backend/src/main/java/io/metersphere/base/domain/ProjectExample.java b/backend/src/main/java/io/metersphere/base/domain/ProjectExample.java index 0ea636173b..304be7d6e6 100644 --- a/backend/src/main/java/io/metersphere/base/domain/ProjectExample.java +++ b/backend/src/main/java/io/metersphere/base/domain/ProjectExample.java @@ -973,6 +973,66 @@ public class ProjectExample { addCriterion("custom_num not between", value1, value2, "customNum"); return (Criteria) this; } + + public Criteria andScenarioCustomNumIsNull() { + addCriterion("scenario_custom_num is null"); + return (Criteria) this; + } + + public Criteria andScenarioCustomNumIsNotNull() { + addCriterion("scenario_custom_num is not null"); + return (Criteria) this; + } + + public Criteria andScenarioCustomNumEqualTo(Boolean value) { + addCriterion("scenario_custom_num =", value, "scenarioCustomNum"); + return (Criteria) this; + } + + public Criteria andScenarioCustomNumNotEqualTo(Boolean value) { + addCriterion("scenario_custom_num <>", value, "scenarioCustomNum"); + return (Criteria) this; + } + + public Criteria andScenarioCustomNumGreaterThan(Boolean value) { + addCriterion("scenario_custom_num >", value, "scenarioCustomNum"); + return (Criteria) this; + } + + public Criteria andScenarioCustomNumGreaterThanOrEqualTo(Boolean value) { + addCriterion("scenario_custom_num >=", value, "scenarioCustomNum"); + return (Criteria) this; + } + + public Criteria andScenarioCustomNumLessThan(Boolean value) { + addCriterion("scenario_custom_num <", value, "scenarioCustomNum"); + return (Criteria) this; + } + + public Criteria andScenarioCustomNumLessThanOrEqualTo(Boolean value) { + addCriterion("scenario_custom_num <=", value, "scenarioCustomNum"); + return (Criteria) this; + } + + public Criteria andScenarioCustomNumIn(List values) { + addCriterion("scenario_custom_num in", values, "scenarioCustomNum"); + return (Criteria) this; + } + + public Criteria andScenarioCustomNumNotIn(List values) { + addCriterion("scenario_custom_num not in", values, "scenarioCustomNum"); + return (Criteria) this; + } + + public Criteria andScenarioCustomNumBetween(Boolean value1, Boolean value2) { + addCriterion("scenario_custom_num between", value1, value2, "scenarioCustomNum"); + return (Criteria) this; + } + + public Criteria andScenarioCustomNumNotBetween(Boolean value1, Boolean value2) { + addCriterion("scenario_custom_num not between", value1, value2, "scenarioCustomNum"); + return (Criteria) this; + } } public static class Criteria extends GeneratedCriteria { diff --git a/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioMapper.xml index 96c4137138..2770d13b74 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ApiScenarioMapper.xml @@ -22,6 +22,7 @@ + @@ -88,7 +89,7 @@ id, project_id, tags, user_id, api_scenario_module_id, module_path, `name`, `level`, `status`, principal, step_total, follow_people, schedule, create_time, update_time, - pass_rate, last_result, report_id, num, original_state + pass_rate, last_result, report_id, num, original_state, custom_num scenario_definition, description @@ -148,16 +149,18 @@ principal, step_total, follow_people, schedule, create_time, update_time, pass_rate, last_result, report_id, - num, original_state, scenario_definition, - description) + num, original_state, custom_num, + scenario_definition, description + ) values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR}, #{apiScenarioModuleId,jdbcType=VARCHAR}, #{modulePath,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{level,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{principal,jdbcType=VARCHAR}, #{stepTotal,jdbcType=INTEGER}, #{followPeople,jdbcType=VARCHAR}, #{schedule,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT}, #{passRate,jdbcType=VARCHAR}, #{lastResult,jdbcType=VARCHAR}, #{reportId,jdbcType=VARCHAR}, - #{num,jdbcType=INTEGER}, #{originalState,jdbcType=VARCHAR}, #{scenarioDefinition,jdbcType=LONGVARCHAR}, - #{description,jdbcType=LONGVARCHAR}) + #{num,jdbcType=INTEGER}, #{originalState,jdbcType=VARCHAR}, #{customNum,jdbcType=VARCHAR}, + #{scenarioDefinition,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR} + ) insert into api_scenario @@ -222,6 +225,9 @@ original_state, + + custom_num, + scenario_definition, @@ -290,6 +296,9 @@ #{originalState,jdbcType=VARCHAR}, + + #{customNum,jdbcType=VARCHAR}, + #{scenarioDefinition,jdbcType=LONGVARCHAR}, @@ -367,6 +376,9 @@ original_state = #{record.originalState,jdbcType=VARCHAR}, + + custom_num = #{record.customNum,jdbcType=VARCHAR}, + scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR}, @@ -400,6 +412,7 @@ report_id = #{record.reportId,jdbcType=VARCHAR}, num = #{record.num,jdbcType=INTEGER}, original_state = #{record.originalState,jdbcType=VARCHAR}, + custom_num = #{record.customNum,jdbcType=VARCHAR}, scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR}, description = #{record.description,jdbcType=LONGVARCHAR} @@ -427,7 +440,8 @@ last_result = #{record.lastResult,jdbcType=VARCHAR}, report_id = #{record.reportId,jdbcType=VARCHAR}, num = #{record.num,jdbcType=INTEGER}, - original_state = #{record.originalState,jdbcType=VARCHAR} + original_state = #{record.originalState,jdbcType=VARCHAR}, + custom_num = #{record.customNum,jdbcType=VARCHAR} @@ -492,6 +506,9 @@ original_state = #{originalState,jdbcType=VARCHAR}, + + custom_num = #{customNum,jdbcType=VARCHAR}, + scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR}, @@ -522,6 +539,7 @@ report_id = #{reportId,jdbcType=VARCHAR}, num = #{num,jdbcType=INTEGER}, original_state = #{originalState,jdbcType=VARCHAR}, + custom_num = #{customNum,jdbcType=VARCHAR}, scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR}, description = #{description,jdbcType=LONGVARCHAR} where id = #{id,jdbcType=VARCHAR} @@ -546,7 +564,8 @@ last_result = #{lastResult,jdbcType=VARCHAR}, report_id = #{reportId,jdbcType=VARCHAR}, num = #{num,jdbcType=INTEGER}, - original_state = #{originalState,jdbcType=VARCHAR} + original_state = #{originalState,jdbcType=VARCHAR}, + custom_num = #{customNum,jdbcType=VARCHAR} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ProjectMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ProjectMapper.xml index 2723649d41..8e3c257961 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ProjectMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ProjectMapper.xml @@ -15,6 +15,7 @@ + @@ -76,7 +77,7 @@ id, workspace_id, `name`, description, create_time, update_time, tapd_id, jira_key, - zentao_id, `repeatable`, case_template_id, issue_template_id, custom_num + zentao_id, `repeatable`, case_template_id, issue_template_id, custom_num, scenario_custom_num @@ -253,6 +260,9 @@ custom_num = #{record.customNum,jdbcType=BIT}, + + scenario_custom_num = #{record.scenarioCustomNum,jdbcType=BIT}, + @@ -272,7 +282,8 @@ `repeatable` = #{record.repeatable,jdbcType=BIT}, case_template_id = #{record.caseTemplateId,jdbcType=VARCHAR}, issue_template_id = #{record.issueTemplateId,jdbcType=VARCHAR}, - custom_num = #{record.customNum,jdbcType=BIT} + custom_num = #{record.customNum,jdbcType=BIT}, + scenario_custom_num = #{record.scenarioCustomNum,jdbcType=BIT} @@ -316,6 +327,9 @@ custom_num = #{customNum,jdbcType=BIT}, + + scenario_custom_num = #{scenarioCustomNum,jdbcType=BIT}, + where id = #{id,jdbcType=VARCHAR} @@ -332,7 +346,8 @@ `repeatable` = #{repeatable,jdbcType=BIT}, case_template_id = #{caseTemplateId,jdbcType=VARCHAR}, issue_template_id = #{issueTemplateId,jdbcType=VARCHAR}, - custom_num = #{customNum,jdbcType=BIT} + custom_num = #{customNum,jdbcType=BIT}, + scenario_custom_num = #{scenarioCustomNum,jdbcType=BIT} where id = #{id,jdbcType=VARCHAR} \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.java index dec88579d4..826797085f 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiScenarioMapper.java @@ -41,4 +41,6 @@ public interface ExtApiScenarioMapper { ApiScenario getNextNum(@Param("projectId") String projectId); List selectIdsByQuery(@Param("request") ApiScenarioRequest request); + + void updateCustomNumByProjectId(@Param("projectId") String projectId); } 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 cf43d027d2..fd5b67a1ba 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 @@ -133,7 +133,7 @@ SELECT COUNT(id) AS countNumber FROM api_scenario WHERE project_id = #{0} AND status != 'Trash' diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml index fdb9841919..2da6d2e5f2 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtProjectMapper.xml @@ -4,7 +4,8 @@ select t.id, t.environment, t.create_time, t.update_time, t.last_result, t.pass_rate, t.report_id, c.scenario_definition, - c.id as case_id, c.project_id, c.user_id,c.api_scenario_module_id, c.module_path, c.name, c.level, - c.status, c.principal, c.step_total, c.follow_people, c.schedule, c.description, c.tags, c.num, - p.name as project_name, p.id as project_id, u.name as user_name + c.id as case_id, c.user_id,c.api_scenario_module_id, c.module_path, c.name, c.level, + c.status, c.principal, c.step_total, c.follow_people, c.schedule, c.description, c.tags, + p.name as project_name, p.id as project_id, u.name as user_name, if(p.scenario_custom_num = 0, cast(c.num as char), c.custom_num) as custom_num from test_plan_api_scenario t inner join @@ -46,6 +46,7 @@ and (c.name like CONCAT('%', #{request.name},'%') or c.num like CONCAT('%', #{request.name},'%') + or c.custom_num like CONCAT('%', #{request.name},'%') or c.tags like CONCAT('%', #{request.name},'%')) diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index 2fe87c82a0..2ff75e6aee 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -3,11 +3,9 @@ package io.metersphere.service; import io.metersphere.api.dto.DeleteAPITestRequest; import io.metersphere.api.dto.QueryAPITestRequest; import io.metersphere.api.service.APITestService; +import io.metersphere.api.service.ApiAutomationService; import io.metersphere.base.domain.*; -import io.metersphere.base.mapper.ApiTestFileMapper; -import io.metersphere.base.mapper.LoadTestFileMapper; -import io.metersphere.base.mapper.LoadTestMapper; -import io.metersphere.base.mapper.ProjectMapper; +import io.metersphere.base.mapper.*; import io.metersphere.base.mapper.ext.ExtProjectMapper; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.ServiceUtils; @@ -21,6 +19,7 @@ import io.metersphere.performance.service.PerformanceTestService; import io.metersphere.track.service.TestCaseService; import io.metersphere.track.service.TestPlanProjectService; import io.metersphere.track.service.TestPlanService; +import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -59,6 +58,8 @@ public class ProjectService { private LoadTestFileMapper loadTestFileMapper; @Resource private ApiTestFileMapper apiTestFileMapper; + @Resource + private ApiAutomationService apiAutomationService; public Project addProject(Project project) { if (StringUtils.isBlank(project.getName())) { @@ -145,9 +146,12 @@ public class ProjectService { project.setCreateTime(null); project.setUpdateTime(System.currentTimeMillis()); checkProjectExist(project); - if (project.getCustomNum()) { + if (BooleanUtils.isTrue(project.getCustomNum())) { testCaseService.updateTestCaseCustomNumByProjectId(project.getId()); } + if (BooleanUtils.isTrue(project.getScenarioCustomNum())) { + apiAutomationService.updateCustomNumByProjectId(project.getId()); + } projectMapper.updateByPrimaryKeySelective(project); } diff --git a/backend/src/main/resources/db/migration/V81__v1.9.1_release.sql b/backend/src/main/resources/db/migration/V81__v1.9.1_release.sql index 83c3983345..3740e4c690 100644 --- a/backend/src/main/resources/db/migration/V81__v1.9.1_release.sql +++ b/backend/src/main/resources/db/migration/V81__v1.9.1_release.sql @@ -1 +1,4 @@ -ALTER TABLE api_scenario_report MODIFY COLUMN scenario_name VARCHAR(3000); \ No newline at end of file +ALTER TABLE api_scenario_report MODIFY COLUMN scenario_name VARCHAR(3000); + +alter table project add scenario_custom_num tinyint(1) default 0 null comment '是否开启场景自定义ID(默认关闭)'; +alter table api_scenario add custom_num varchar(64) null comment 'custom num'; \ No newline at end of file diff --git a/frontend/src/business/components/api/automation/ApiAutomation.vue b/frontend/src/business/components/api/automation/ApiAutomation.vue index 85152d6f06..f0639b91e5 100644 --- a/frontend/src/business/components/api/automation/ApiAutomation.vue +++ b/frontend/src/business/components/api/automation/ApiAutomation.vue @@ -30,6 +30,7 @@ @openScenario="editScenario" @edit="editScenario" @changeSelectDataRangeAll="changeSelectDataRangeAll" + :custom-num="customNum" ref="apiScenarioList"/> @@ -41,7 +42,7 @@ closable>
+ :custom-num="customNum" :moduleOptions="moduleOptions" ref="autoScenarioConfig"/>
@@ -116,8 +117,12 @@ selectNodeIds: [], nodeTree: [], currentModulePath: "", + customNum: false } }, + mounted() { + this.getProject(); + }, watch: { redirectID() { this.renderComponent = false; @@ -335,6 +340,14 @@ }, enableTrash(data) { this.trashEnable = data; + }, + getProject() { + this.$get("/project/get/" + this.projectId, result => { + let data = result.data; + if (data) { + this.customNum = data.scenarioCustomNum; + } + }) } } } diff --git a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue index 14b1c94499..14e6a6b645 100644 --- a/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue +++ b/frontend/src/business/components/api/automation/scenario/ApiScenarioList.vue @@ -29,7 +29,7 @@ + + + + + + + + @@ -262,7 +267,11 @@ props: { moduleOptions: Array, currentScenario: {}, - type: String + type: String, + customNum: { + type: Boolean, + default: false + } }, components: { MsVariableList, @@ -299,6 +308,10 @@ apiScenarioModuleId: [{required: true, message: this.$t('test_track.case.input_module'), trigger: 'change'}], status: [{required: true, message: this.$t('commons.please_select'), trigger: 'change'}], principal: [{required: true, message: this.$t('api_test.definition.request.responsible'), trigger: 'change'}], + customNum: [ + {required: true, message: "ID必填", trigger: 'blur'}, + {max: 50, message: this.$t('test_track.length_less_than') + '50', trigger: 'blur'} + ], }, environments: [], currentEnvironmentId: "", diff --git a/frontend/src/business/components/settings/project/MsProject.vue b/frontend/src/business/components/settings/project/MsProject.vue index 985629601f..dadaa7f767 100644 --- a/frontend/src/business/components/settings/project/MsProject.vue +++ b/frontend/src/business/components/settings/project/MsProject.vue @@ -87,6 +87,9 @@ + + +