Merge branch 'v1.6' of https://github.com/metersphere/metersphere into v1.6
This commit is contained in:
commit
007ede7069
|
@ -109,6 +109,7 @@ public class ApiAutomationService {
|
|||
scenario.setScenarioDefinition(JSON.toJSONString(request.getScenarioDefinition()));
|
||||
scenario.setCreateTime(System.currentTimeMillis());
|
||||
scenario.setUpdateTime(System.currentTimeMillis());
|
||||
scenario.setNum(getNextNum(request.getProjectId()));
|
||||
if (StringUtils.isNotEmpty(request.getStatus())) {
|
||||
scenario.setStatus(request.getStatus());
|
||||
} else {
|
||||
|
@ -127,6 +128,15 @@ public class ApiAutomationService {
|
|||
return scenario;
|
||||
}
|
||||
|
||||
private int getNextNum(String projectId) {
|
||||
ApiScenario apiScenario = extApiScenarioMapper.getNextNum(projectId);
|
||||
if (apiScenario == null) {
|
||||
return 100001;
|
||||
} else {
|
||||
return Optional.of(apiScenario.getNum() + 1).orElse(100001);
|
||||
}
|
||||
}
|
||||
|
||||
public void update(SaveApiScenarioRequest request, List<MultipartFile> bodyFiles) {
|
||||
checkNameExist(request);
|
||||
List<String> bodyUploadIds = request.getBodyUploadIds();
|
||||
|
|
|
@ -238,6 +238,7 @@ public class ApiDefinitionService {
|
|||
test.setModulePath(request.getModulePath());
|
||||
test.setResponse(JSONObject.toJSONString(request.getResponse()));
|
||||
test.setEnvironmentId(request.getEnvironmentId());
|
||||
test.setNum(getNextNum(request.getProjectId()));
|
||||
if (request.getUserId() == null) {
|
||||
test.setUserId(Objects.requireNonNull(SessionUtils.getUser()).getId());
|
||||
} else {
|
||||
|
@ -248,6 +249,15 @@ public class ApiDefinitionService {
|
|||
return test;
|
||||
}
|
||||
|
||||
private int getNextNum(String projectId) {
|
||||
ApiDefinition apiDefinition = extApiDefinitionMapper.getNextNum(projectId);
|
||||
if (apiDefinition == null) {
|
||||
return 100001;
|
||||
} else {
|
||||
return Optional.of(apiDefinition.getNum() + 1).orElse(100001);
|
||||
}
|
||||
}
|
||||
|
||||
private ApiDefinition createTest(ApiDefinitionResult request, ApiDefinitionMapper batchMapper) {
|
||||
SaveApiDefinitionRequest saveReq = new SaveApiDefinitionRequest();
|
||||
BeanUtils.copyBean(saveReq, request);
|
||||
|
@ -372,11 +382,16 @@ public class ApiDefinitionService {
|
|||
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
|
||||
ApiDefinitionMapper batchMapper = sqlSession.getMapper(ApiDefinitionMapper.class);
|
||||
List<ApiDefinitionResult> data = apiImport.getData();
|
||||
int num = 0;
|
||||
if (!CollectionUtils.isEmpty(data) && data.get(0) != null && data.get(0).getProjectId() != null) {
|
||||
num = getNextNum(data.get(0).getProjectId());
|
||||
}
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
ApiDefinitionResult item = data.get(i);
|
||||
if (item.getName().length() > 255) {
|
||||
item.setName(item.getName().substring(0, 255));
|
||||
}
|
||||
item.setNum(num++);
|
||||
createTest(item, batchMapper);
|
||||
if (i % 300 == 0) {
|
||||
sqlSession.flushStatements();
|
||||
|
|
|
@ -8,6 +8,7 @@ import io.metersphere.api.dto.definition.SaveApiTestCaseRequest;
|
|||
import io.metersphere.api.dto.ApiCaseBatchRequest;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseDTO;
|
||||
import io.metersphere.base.domain.*;
|
||||
import io.metersphere.base.mapper.ApiDefinitionMapper;
|
||||
import io.metersphere.base.mapper.ApiTestCaseMapper;
|
||||
import io.metersphere.base.mapper.ApiTestFileMapper;
|
||||
import io.metersphere.base.mapper.ext.ExtApiDefinitionExecResultMapper;
|
||||
|
@ -54,6 +55,8 @@ public class ApiTestCaseService {
|
|||
private FileService fileService;
|
||||
@Resource
|
||||
private ExtApiDefinitionExecResultMapper extApiDefinitionExecResultMapper;
|
||||
@Resource
|
||||
private ApiDefinitionMapper apiDefinitionMapper;
|
||||
|
||||
private static final String BODY_FILE_DIR = "/opt/metersphere/data/body";
|
||||
|
||||
|
@ -218,10 +221,22 @@ public class ApiTestCaseService {
|
|||
test.setPriority(request.getPriority());
|
||||
test.setUpdateTime(System.currentTimeMillis());
|
||||
test.setDescription(request.getDescription());
|
||||
test.setNum(getNextNum(request.getApiDefinitionId()));
|
||||
apiTestCaseMapper.insert(test);
|
||||
return test;
|
||||
}
|
||||
|
||||
private int getNextNum(String definitionId) {
|
||||
ApiTestCase apiTestCase = extApiTestCaseMapper.getNextNum(definitionId);
|
||||
if (apiTestCase == null) {
|
||||
int n = apiDefinitionMapper.selectByPrimaryKey(definitionId).getNum();
|
||||
return n * 1000 + 1;
|
||||
} else {
|
||||
return Optional.of(apiTestCase.getNum() + 1)
|
||||
.orElse(apiDefinitionMapper.selectByPrimaryKey(definitionId).getNum() * 1000 + 1);
|
||||
}
|
||||
}
|
||||
|
||||
private void saveFile(String testId, MultipartFile file) {
|
||||
final FileMetadata fileMetadata = fileService.saveFile(file);
|
||||
ApiTestFile apiTestFile = new ApiTestFile();
|
||||
|
|
|
@ -33,5 +33,7 @@ public class ApiDefinition implements Serializable {
|
|||
|
||||
private String path;
|
||||
|
||||
private Integer num;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -1063,6 +1063,66 @@ public class ApiDefinitionExample {
|
|||
addCriterion("`path` not between", value1, value2, "path");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumIsNull() {
|
||||
addCriterion("num is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumIsNotNull() {
|
||||
addCriterion("num is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumEqualTo(Integer value) {
|
||||
addCriterion("num =", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumNotEqualTo(Integer value) {
|
||||
addCriterion("num <>", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumGreaterThan(Integer value) {
|
||||
addCriterion("num >", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("num >=", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumLessThan(Integer value) {
|
||||
addCriterion("num <", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("num <=", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumIn(List<Integer> values) {
|
||||
addCriterion("num in", values, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumNotIn(List<Integer> values) {
|
||||
addCriterion("num not in", values, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumBetween(Integer value1, Integer value2) {
|
||||
addCriterion("num between", value1, value2, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("num not between", value1, value2, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
|
|
@ -41,5 +41,7 @@ public class ApiScenario implements Serializable {
|
|||
|
||||
private String reportId;
|
||||
|
||||
private Integer num;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -1333,6 +1333,66 @@ public class ApiScenarioExample {
|
|||
addCriterion("report_id not between", value1, value2, "reportId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumIsNull() {
|
||||
addCriterion("num is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumIsNotNull() {
|
||||
addCriterion("num is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumEqualTo(Integer value) {
|
||||
addCriterion("num =", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumNotEqualTo(Integer value) {
|
||||
addCriterion("num <>", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumGreaterThan(Integer value) {
|
||||
addCriterion("num >", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("num >=", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumLessThan(Integer value) {
|
||||
addCriterion("num <", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("num <=", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumIn(List<Integer> values) {
|
||||
addCriterion("num in", values, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumNotIn(List<Integer> values) {
|
||||
addCriterion("num not in", values, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumBetween(Integer value1, Integer value2) {
|
||||
addCriterion("num between", value1, value2, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("num not between", value1, value2, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
|
|
@ -23,5 +23,7 @@ public class ApiTestCase implements Serializable {
|
|||
|
||||
private Long updateTime;
|
||||
|
||||
private Integer num;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -713,6 +713,66 @@ public class ApiTestCaseExample {
|
|||
addCriterion("update_time not between", value1, value2, "updateTime");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumIsNull() {
|
||||
addCriterion("num is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumIsNotNull() {
|
||||
addCriterion("num is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumEqualTo(Integer value) {
|
||||
addCriterion("num =", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumNotEqualTo(Integer value) {
|
||||
addCriterion("num <>", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumGreaterThan(Integer value) {
|
||||
addCriterion("num >", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumGreaterThanOrEqualTo(Integer value) {
|
||||
addCriterion("num >=", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumLessThan(Integer value) {
|
||||
addCriterion("num <", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumLessThanOrEqualTo(Integer value) {
|
||||
addCriterion("num <=", value, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumIn(List<Integer> values) {
|
||||
addCriterion("num in", values, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumNotIn(List<Integer> values) {
|
||||
addCriterion("num not in", values, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumBetween(Integer value1, Integer value2) {
|
||||
addCriterion("num between", value1, value2, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andNumNotBetween(Integer value1, Integer value2) {
|
||||
addCriterion("num not between", value1, value2, "num");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
<result column="protocol" jdbcType="VARCHAR" property="protocol" />
|
||||
<result column="path" jdbcType="VARCHAR" property="path" />
|
||||
<result column="num" jdbcType="INTEGER" property="num" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiDefinitionWithBLOBs">
|
||||
<result column="description" jdbcType="LONGVARCHAR" property="description" />
|
||||
|
@ -82,7 +83,7 @@
|
|||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, project_id, `name`, `method`, module_path, environment_id, schedule, `status`,
|
||||
module_id, user_id, create_time, update_time, protocol, `path`
|
||||
module_id, user_id, create_time, update_time, protocol, `path`, num
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
description, request, response
|
||||
|
@ -140,14 +141,16 @@
|
|||
`method`, module_path, environment_id,
|
||||
schedule, `status`, module_id,
|
||||
user_id, create_time, update_time,
|
||||
protocol, `path`, description,
|
||||
request, response)
|
||||
protocol, `path`, num,
|
||||
description, request, response
|
||||
)
|
||||
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
|
||||
#{method,jdbcType=VARCHAR}, #{modulePath,jdbcType=VARCHAR}, #{environmentId,jdbcType=VARCHAR},
|
||||
#{schedule,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{moduleId,jdbcType=VARCHAR},
|
||||
#{userId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
|
||||
#{protocol,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR}, #{description,jdbcType=LONGVARCHAR},
|
||||
#{request,jdbcType=LONGVARCHAR}, #{response,jdbcType=LONGVARCHAR})
|
||||
#{protocol,jdbcType=VARCHAR}, #{path,jdbcType=VARCHAR}, #{num,jdbcType=INTEGER},
|
||||
#{description,jdbcType=LONGVARCHAR}, #{request,jdbcType=LONGVARCHAR}, #{response,jdbcType=LONGVARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiDefinitionWithBLOBs">
|
||||
insert into api_definition
|
||||
|
@ -194,6 +197,9 @@
|
|||
<if test="path != null">
|
||||
`path`,
|
||||
</if>
|
||||
<if test="num != null">
|
||||
num,
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description,
|
||||
</if>
|
||||
|
@ -247,6 +253,9 @@
|
|||
<if test="path != null">
|
||||
#{path,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="num != null">
|
||||
#{num,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
#{description,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
|
@ -309,6 +318,9 @@
|
|||
<if test="record.path != null">
|
||||
`path` = #{record.path,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.num != null">
|
||||
num = #{record.num,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.description != null">
|
||||
description = #{record.description,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
|
@ -339,6 +351,7 @@
|
|||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
protocol = #{record.protocol,jdbcType=VARCHAR},
|
||||
`path` = #{record.path,jdbcType=VARCHAR},
|
||||
num = #{record.num,jdbcType=INTEGER},
|
||||
description = #{record.description,jdbcType=LONGVARCHAR},
|
||||
request = #{record.request,jdbcType=LONGVARCHAR},
|
||||
response = #{record.response,jdbcType=LONGVARCHAR}
|
||||
|
@ -361,7 +374,8 @@
|
|||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
protocol = #{record.protocol,jdbcType=VARCHAR},
|
||||
`path` = #{record.path,jdbcType=VARCHAR}
|
||||
`path` = #{record.path,jdbcType=VARCHAR},
|
||||
num = #{record.num,jdbcType=INTEGER}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
|
@ -408,6 +422,9 @@
|
|||
<if test="path != null">
|
||||
`path` = #{path,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="num != null">
|
||||
num = #{num,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description = #{description,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
|
@ -435,6 +452,7 @@
|
|||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
protocol = #{protocol,jdbcType=VARCHAR},
|
||||
`path` = #{path,jdbcType=VARCHAR},
|
||||
num = #{num,jdbcType=INTEGER},
|
||||
description = #{description,jdbcType=LONGVARCHAR},
|
||||
request = #{request,jdbcType=LONGVARCHAR},
|
||||
response = #{response,jdbcType=LONGVARCHAR}
|
||||
|
@ -454,7 +472,8 @@
|
|||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
protocol = #{protocol,jdbcType=VARCHAR},
|
||||
`path` = #{path,jdbcType=VARCHAR}
|
||||
`path` = #{path,jdbcType=VARCHAR},
|
||||
num = #{num,jdbcType=INTEGER}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
|
@ -20,6 +20,7 @@
|
|||
<result column="pass_rate" jdbcType="VARCHAR" property="passRate" />
|
||||
<result column="last_result" jdbcType="VARCHAR" property="lastResult" />
|
||||
<result column="report_id" jdbcType="VARCHAR" property="reportId" />
|
||||
<result column="num" jdbcType="INTEGER" property="num" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiScenarioWithBLOBs">
|
||||
<result column="scenario_definition" jdbcType="LONGVARCHAR" property="scenarioDefinition" />
|
||||
|
@ -86,7 +87,7 @@
|
|||
<sql id="Base_Column_List">
|
||||
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
|
||||
pass_rate, last_result, report_id, num
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
scenario_definition, description
|
||||
|
@ -146,7 +147,7 @@
|
|||
principal, step_total, follow_people,
|
||||
schedule, create_time, update_time,
|
||||
pass_rate, last_result, report_id,
|
||||
scenario_definition, description
|
||||
num, scenario_definition, description
|
||||
)
|
||||
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{tags,jdbcType=VARCHAR},
|
||||
#{userId,jdbcType=VARCHAR}, #{apiScenarioModuleId,jdbcType=VARCHAR}, #{modulePath,jdbcType=VARCHAR},
|
||||
|
@ -154,7 +155,7 @@
|
|||
#{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},
|
||||
#{scenarioDefinition,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR}
|
||||
#{num,jdbcType=INTEGER}, #{scenarioDefinition,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiScenarioWithBLOBs">
|
||||
|
@ -214,6 +215,9 @@
|
|||
<if test="reportId != null">
|
||||
report_id,
|
||||
</if>
|
||||
<if test="num != null">
|
||||
num,
|
||||
</if>
|
||||
<if test="scenarioDefinition != null">
|
||||
scenario_definition,
|
||||
</if>
|
||||
|
@ -276,6 +280,9 @@
|
|||
<if test="reportId != null">
|
||||
#{reportId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="num != null">
|
||||
#{num,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="scenarioDefinition != null">
|
||||
#{scenarioDefinition,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
|
@ -347,6 +354,9 @@
|
|||
<if test="record.reportId != null">
|
||||
report_id = #{record.reportId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.num != null">
|
||||
num = #{record.num,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.scenarioDefinition != null">
|
||||
scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
|
@ -378,6 +388,7 @@
|
|||
pass_rate = #{record.passRate,jdbcType=VARCHAR},
|
||||
last_result = #{record.lastResult,jdbcType=VARCHAR},
|
||||
report_id = #{record.reportId,jdbcType=VARCHAR},
|
||||
num = #{record.num,jdbcType=INTEGER},
|
||||
scenario_definition = #{record.scenarioDefinition,jdbcType=LONGVARCHAR},
|
||||
description = #{record.description,jdbcType=LONGVARCHAR}
|
||||
<if test="_parameter != null">
|
||||
|
@ -403,7 +414,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},
|
||||
num = #{record.num,jdbcType=INTEGER}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
|
@ -462,6 +474,9 @@
|
|||
<if test="reportId != null">
|
||||
report_id = #{reportId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="num != null">
|
||||
num = #{num,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="scenarioDefinition != null">
|
||||
scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
|
@ -490,6 +505,7 @@
|
|||
pass_rate = #{passRate,jdbcType=VARCHAR},
|
||||
last_result = #{lastResult,jdbcType=VARCHAR},
|
||||
report_id = #{reportId,jdbcType=VARCHAR},
|
||||
num = #{num,jdbcType=INTEGER},
|
||||
scenario_definition = #{scenarioDefinition,jdbcType=LONGVARCHAR},
|
||||
description = #{description,jdbcType=LONGVARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
|
@ -512,7 +528,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},
|
||||
num = #{num,jdbcType=INTEGER}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
|
@ -11,6 +11,7 @@
|
|||
<result column="update_user_id" jdbcType="VARCHAR" property="updateUserId" />
|
||||
<result column="create_time" jdbcType="BIGINT" property="createTime" />
|
||||
<result column="update_time" jdbcType="BIGINT" property="updateTime" />
|
||||
<result column="num" jdbcType="INTEGER" property="num" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
|
||||
<result column="description" jdbcType="LONGVARCHAR" property="description" />
|
||||
|
@ -77,7 +78,7 @@
|
|||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, project_id, `name`, priority, api_definition_id, create_user_id, update_user_id,
|
||||
create_time, update_time
|
||||
create_time, update_time, num
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
description, request, response
|
||||
|
@ -134,13 +135,13 @@
|
|||
insert into api_test_case (id, project_id, `name`,
|
||||
priority, api_definition_id, create_user_id,
|
||||
update_user_id, create_time, update_time,
|
||||
description, request, response
|
||||
)
|
||||
num, description, request,
|
||||
response)
|
||||
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
|
||||
#{priority,jdbcType=VARCHAR}, #{apiDefinitionId,jdbcType=VARCHAR}, #{createUserId,jdbcType=VARCHAR},
|
||||
#{updateUserId,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
|
||||
#{description,jdbcType=LONGVARCHAR}, #{request,jdbcType=LONGVARCHAR}, #{response,jdbcType=LONGVARCHAR}
|
||||
)
|
||||
#{num,jdbcType=INTEGER}, #{description,jdbcType=LONGVARCHAR}, #{request,jdbcType=LONGVARCHAR},
|
||||
#{response,jdbcType=LONGVARCHAR})
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.ApiTestCaseWithBLOBs">
|
||||
insert into api_test_case
|
||||
|
@ -172,6 +173,9 @@
|
|||
<if test="updateTime != null">
|
||||
update_time,
|
||||
</if>
|
||||
<if test="num != null">
|
||||
num,
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description,
|
||||
</if>
|
||||
|
@ -210,6 +214,9 @@
|
|||
<if test="updateTime != null">
|
||||
#{updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="num != null">
|
||||
#{num,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
#{description,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
|
@ -257,6 +264,9 @@
|
|||
<if test="record.updateTime != null">
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.num != null">
|
||||
num = #{record.num,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="record.description != null">
|
||||
description = #{record.description,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
|
@ -282,6 +292,7 @@
|
|||
update_user_id = #{record.updateUserId,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
num = #{record.num,jdbcType=INTEGER},
|
||||
description = #{record.description,jdbcType=LONGVARCHAR},
|
||||
request = #{record.request,jdbcType=LONGVARCHAR},
|
||||
response = #{record.response,jdbcType=LONGVARCHAR}
|
||||
|
@ -299,7 +310,8 @@
|
|||
create_user_id = #{record.createUserId,jdbcType=VARCHAR},
|
||||
update_user_id = #{record.updateUserId,jdbcType=VARCHAR},
|
||||
create_time = #{record.createTime,jdbcType=BIGINT},
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT}
|
||||
update_time = #{record.updateTime,jdbcType=BIGINT},
|
||||
num = #{record.num,jdbcType=INTEGER}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
|
@ -331,6 +343,9 @@
|
|||
<if test="updateTime != null">
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="num != null">
|
||||
num = #{num,jdbcType=INTEGER},
|
||||
</if>
|
||||
<if test="description != null">
|
||||
description = #{description,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
|
@ -353,6 +368,7 @@
|
|||
update_user_id = #{updateUserId,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
num = #{num,jdbcType=INTEGER},
|
||||
description = #{description,jdbcType=LONGVARCHAR},
|
||||
request = #{request,jdbcType=LONGVARCHAR},
|
||||
response = #{response,jdbcType=LONGVARCHAR}
|
||||
|
@ -367,7 +383,8 @@
|
|||
create_user_id = #{createUserId,jdbcType=VARCHAR},
|
||||
update_user_id = #{updateUserId,jdbcType=VARCHAR},
|
||||
create_time = #{createTime,jdbcType=BIGINT},
|
||||
update_time = #{updateTime,jdbcType=BIGINT}
|
||||
update_time = #{updateTime,jdbcType=BIGINT},
|
||||
num = #{num,jdbcType=INTEGER}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
|
@ -4,6 +4,7 @@ import io.metersphere.api.dto.datacount.ApiDataCountResult;
|
|||
import io.metersphere.api.dto.definition.ApiComputeResult;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionRequest;
|
||||
import io.metersphere.api.dto.definition.ApiDefinitionResult;
|
||||
import io.metersphere.base.domain.ApiDefinition;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -25,4 +26,6 @@ public interface ExtApiDefinitionMapper {
|
|||
List<ApiDataCountResult> countStateByProjectID(String projectId);
|
||||
|
||||
List<ApiDataCountResult> countApiCoverageByProjectID(String projectId);
|
||||
|
||||
ApiDefinition getNextNum(@Param("projectId") String projectId);
|
||||
}
|
|
@ -194,7 +194,7 @@
|
|||
</sql>
|
||||
|
||||
<select id="list" resultType="io.metersphere.api.dto.definition.ApiDefinitionResult">
|
||||
select api_definition.id, api_definition.project_id,
|
||||
select api_definition.id, api_definition.project_id, api_definition.num,
|
||||
api_definition.name,api_definition.protocol,api_definition.path,api_definition.module_id,api_definition.module_path,api_definition.method,
|
||||
api_definition.description,api_definition.request,api_definition.response,api_definition.environment_id,
|
||||
api_definition.status, api_definition.user_id, api_definition.create_time, api_definition.update_time, project.name as
|
||||
|
@ -292,4 +292,7 @@
|
|||
WHERE api.project_id = #{0} and api.`status` != 'Trash'
|
||||
GROUP BY groupField
|
||||
</select>
|
||||
<select id="getNextNum" resultType="io.metersphere.base.domain.ApiDefinition">
|
||||
SELECT * FROM api_definition WHERE api_definition.project_id = #{projectId} ORDER BY num DESC LIMIT 1;
|
||||
</select>
|
||||
</mapper>
|
|
@ -29,4 +29,6 @@ public interface ExtApiScenarioMapper {
|
|||
List<ApiDataCountResult> countRunResultByProjectID(String projectId);
|
||||
|
||||
List<String> selectIdsNotExistsInPlan(String projectId, String planId);
|
||||
|
||||
ApiScenario getNextNum(@Param("projectId") String projectId);
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
</resultMap>
|
||||
|
||||
<select id="list" resultMap="BaseResultMap">
|
||||
select api_scenario.id, api_scenario.project_id, api_scenario.tags, api_scenario.user_id,
|
||||
select api_scenario.id, api_scenario.project_id, api_scenario.tags, api_scenario.user_id, api_scenario.num,
|
||||
api_scenario.api_scenario_module_id,api_scenario.module_path, api_scenario.name, api_scenario.level,
|
||||
api_scenario.status, api_scenario.principal, api_scenario.step_total, api_scenario.follow_people,
|
||||
api_scenario.last_result,api_scenario.pass_rate,api_scenario.report_id,
|
||||
|
@ -138,5 +138,8 @@
|
|||
where pc.test_plan_id = #{planId}
|
||||
)
|
||||
</select>
|
||||
<select id="getNextNum" resultType="io.metersphere.base.domain.ApiScenario">
|
||||
SELECT * FROM api_scenario WHERE api_scenario.project_id = #{projectId} ORDER BY num DESC LIMIT 1;
|
||||
</select>
|
||||
|
||||
</mapper>
|
|
@ -4,6 +4,7 @@ import io.metersphere.api.dto.datacount.ApiDataCountResult;
|
|||
import io.metersphere.api.dto.definition.ApiTestCaseDTO;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseRequest;
|
||||
import io.metersphere.api.dto.definition.ApiTestCaseResult;
|
||||
import io.metersphere.base.domain.ApiTestCase;
|
||||
import io.metersphere.base.domain.ApiTestCaseWithBLOBs;
|
||||
import org.apache.ibatis.annotations.MapKey;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
@ -25,4 +26,6 @@ public interface ExtApiTestCaseMapper {
|
|||
long countByProjectIDAndCreateInThisWeek(@Param("projectId") String projectId, @Param("firstDayTimestamp") long firstDayTimestamp, @Param("lastDayTimestamp") long lastDayTimestamp);
|
||||
|
||||
List<ApiTestCaseWithBLOBs> getRequest(@Param("request") ApiTestCaseRequest request);
|
||||
|
||||
ApiTestCase getNextNum(@Param("definitionId") String definitionId);
|
||||
}
|
|
@ -161,6 +161,7 @@
|
|||
atc.create_time,
|
||||
atc.update_user_id,
|
||||
atc.update_time,
|
||||
atc.num,
|
||||
ader.status execResult,
|
||||
ader.create_time execTime
|
||||
from
|
||||
|
@ -204,7 +205,7 @@
|
|||
|
||||
<select id="listSimple" resultType="io.metersphere.api.dto.definition.ApiTestCaseDTO">
|
||||
select
|
||||
c.id, c.project_id, c.name, c.api_definition_id, c.priority, c.description, c.create_user_id, c.update_user_id, c.create_time, c.update_time,
|
||||
c.id, c.project_id, c.name, c.api_definition_id, c.priority, c.description, c.create_user_id, c.update_user_id, c.create_time, c.update_time, c.num,
|
||||
a.module_id, a.path, a.protocol
|
||||
from
|
||||
api_test_case c
|
||||
|
@ -304,6 +305,9 @@
|
|||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
<select id="getNextNum" resultType="io.metersphere.base.domain.ApiTestCase">
|
||||
SELECT * FROM api_test_case WHERE api_test_case.api_definition_id = #{definitionId} ORDER BY num DESC LIMIT 1;
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,125 @@
|
|||
alter table api_definition add num int null comment 'api definition ID';
|
||||
alter table api_test_case add num int null comment 'api test case ID';
|
||||
alter table api_scenario add num int null comment 'api scenario ID';
|
||||
|
||||
DROP PROCEDURE IF EXISTS test_cursor;
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE test_cursor()
|
||||
BEGIN
|
||||
DECLARE projectId VARCHAR(64);
|
||||
DECLARE definitionId VARCHAR(64);
|
||||
DECLARE apiTestCaseId VARCHAR(64);
|
||||
DECLARE num1 INT;
|
||||
DECLARE num2 INT;
|
||||
DECLARE done INT DEFAULT 0;
|
||||
DECLARE cursor1 CURSOR FOR (SELECT DISTINCT project_id
|
||||
FROM api_definition
|
||||
WHERE num IS NULL);
|
||||
DECLARE cursor2 CURSOR FOR (SELECT id
|
||||
FROM api_definition
|
||||
WHERE project_id = projectId
|
||||
ORDER BY create_time);
|
||||
DECLARE cursor3 CURSOR FOR (SELECT id
|
||||
FROM api_test_case
|
||||
WHERE api_definition_id = definitionId
|
||||
ORDER BY create_time);
|
||||
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
||||
OPEN cursor1;
|
||||
outer_loop:
|
||||
LOOP
|
||||
FETCH cursor1 INTO projectId;
|
||||
IF done
|
||||
THEN
|
||||
LEAVE outer_loop;
|
||||
END IF;
|
||||
SET num1 = 100001;
|
||||
OPEN cursor2;
|
||||
inner_loop:
|
||||
LOOP
|
||||
FETCH cursor2 INTO definitionId;
|
||||
IF done
|
||||
THEN
|
||||
LEAVE inner_loop;
|
||||
END IF;
|
||||
UPDATE api_definition
|
||||
SET num = num1
|
||||
WHERE id = definitionId;
|
||||
SET num2 = num1 * 1000 + 1;
|
||||
OPEN cursor3;
|
||||
inner_loop2:
|
||||
LOOP
|
||||
FETCH cursor3 INTO apiTestCaseId;
|
||||
IF done
|
||||
THEN
|
||||
LEAVE inner_loop2;
|
||||
END IF;
|
||||
UPDATE api_test_case
|
||||
SET num = num2
|
||||
WHERE id = apiTestCaseId;
|
||||
SET num2 = num2 + 1;
|
||||
END LOOP;
|
||||
SET done = 0;
|
||||
CLOSE cursor3;
|
||||
SET num1 = num1 + 1;
|
||||
END LOOP;
|
||||
SET done = 0;
|
||||
CLOSE cursor2;
|
||||
END LOOP;
|
||||
CLOSE cursor1;
|
||||
END //
|
||||
DELIMITER ;
|
||||
|
||||
CALL test_cursor();
|
||||
DROP PROCEDURE IF EXISTS test_cursor;
|
||||
|
||||
|
||||
DROP PROCEDURE IF EXISTS test_cursor1;
|
||||
DELIMITER //
|
||||
CREATE PROCEDURE test_cursor1()
|
||||
BEGIN
|
||||
DECLARE projectId VARCHAR(64);
|
||||
DECLARE scenarioId VARCHAR(64);
|
||||
DECLARE num INT;
|
||||
DECLARE done INT DEFAULT 0;
|
||||
DECLARE cursor1 CURSOR FOR (SELECT DISTINCT project_id
|
||||
FROM api_scenario
|
||||
WHERE num IS NULL);
|
||||
DECLARE cursor2 CURSOR FOR (SELECT id
|
||||
FROM api_scenario
|
||||
WHERE project_id = projectId
|
||||
ORDER BY create_time);
|
||||
|
||||
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = TRUE;
|
||||
OPEN cursor1;
|
||||
outer_loop:
|
||||
LOOP
|
||||
FETCH cursor1 INTO projectId;
|
||||
IF done
|
||||
THEN
|
||||
LEAVE outer_loop;
|
||||
END IF;
|
||||
SET num = 100001;
|
||||
OPEN cursor2;
|
||||
inner_loop:
|
||||
LOOP
|
||||
FETCH cursor2 INTO scenarioId;
|
||||
IF done
|
||||
THEN
|
||||
LEAVE inner_loop;
|
||||
END IF;
|
||||
UPDATE api_scenario
|
||||
SET num = num
|
||||
WHERE id = scenarioId;
|
||||
SET num = num + 1;
|
||||
END LOOP;
|
||||
SET done = 0;
|
||||
CLOSE cursor2;
|
||||
END LOOP;
|
||||
CLOSE cursor1;
|
||||
END //
|
||||
DELIMITER ;
|
||||
|
||||
CALL test_cursor1();
|
||||
DROP PROCEDURE IF EXISTS test_cursor1;
|
|
@ -13,6 +13,8 @@
|
|||
<show-more-btn :is-show="isSelect(row)" :buttons="buttons" :size="selection.length"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="num" label="ID"
|
||||
show-overflow-tooltip/>
|
||||
<el-table-column prop="name" :label="$t('api_test.automation.scenario_name')"
|
||||
show-overflow-tooltip/>
|
||||
<el-table-column prop="level" :label="$t('api_test.automation.case_level')"
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="num" label="ID" show-overflow-tooltip/>
|
||||
<el-table-column prop="name" :label="$t('test_track.case.name')" show-overflow-tooltip/>
|
||||
|
||||
<el-table-column
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column prop="num" label="ID" show-overflow-tooltip/>
|
||||
<el-table-column prop="name" :label="$t('api_test.definition.api_name')" show-overflow-tooltip/>
|
||||
<el-table-column
|
||||
prop="status"
|
||||
|
|
Loading…
Reference in New Issue