refactor: 优化性能测试查询
This commit is contained in:
parent
f1076eee66
commit
c6d129cf24
|
@ -34,9 +34,13 @@ public class LoadTest implements Serializable {
|
|||
|
||||
private Long order;
|
||||
|
||||
private String versionId;
|
||||
private String version;
|
||||
|
||||
private String refId;
|
||||
|
||||
private String versionId;
|
||||
|
||||
private Boolean latest;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
|
@ -1034,73 +1034,73 @@ public class LoadTestExample {
|
|||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdIsNull() {
|
||||
addCriterion("version_id is null");
|
||||
public Criteria andVersionIsNull() {
|
||||
addCriterion("version is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdIsNotNull() {
|
||||
addCriterion("version_id is not null");
|
||||
public Criteria andVersionIsNotNull() {
|
||||
addCriterion("version is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdEqualTo(String value) {
|
||||
addCriterion("version_id =", value, "versionId");
|
||||
public Criteria andVersionEqualTo(String value) {
|
||||
addCriterion("version =", value, "version");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdNotEqualTo(String value) {
|
||||
addCriterion("version_id <>", value, "versionId");
|
||||
public Criteria andVersionNotEqualTo(String value) {
|
||||
addCriterion("version <>", value, "version");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdGreaterThan(String value) {
|
||||
addCriterion("version_id >", value, "versionId");
|
||||
public Criteria andVersionGreaterThan(String value) {
|
||||
addCriterion("version >", value, "version");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("version_id >=", value, "versionId");
|
||||
public Criteria andVersionGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("version >=", value, "version");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdLessThan(String value) {
|
||||
addCriterion("version_id <", value, "versionId");
|
||||
public Criteria andVersionLessThan(String value) {
|
||||
addCriterion("version <", value, "version");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("version_id <=", value, "versionId");
|
||||
public Criteria andVersionLessThanOrEqualTo(String value) {
|
||||
addCriterion("version <=", value, "version");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdLike(String value) {
|
||||
addCriterion("version_id like", value, "versionId");
|
||||
public Criteria andVersionLike(String value) {
|
||||
addCriterion("version like", value, "version");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdNotLike(String value) {
|
||||
addCriterion("version_id not like", value, "versionId");
|
||||
public Criteria andVersionNotLike(String value) {
|
||||
addCriterion("version not like", value, "version");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdIn(List<String> values) {
|
||||
addCriterion("version_id in", values, "versionId");
|
||||
public Criteria andVersionIn(List<String> values) {
|
||||
addCriterion("version in", values, "version");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdNotIn(List<String> values) {
|
||||
addCriterion("version_id not in", values, "versionId");
|
||||
public Criteria andVersionNotIn(List<String> values) {
|
||||
addCriterion("version not in", values, "version");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdBetween(String value1, String value2) {
|
||||
addCriterion("version_id between", value1, value2, "versionId");
|
||||
public Criteria andVersionBetween(String value1, String value2) {
|
||||
addCriterion("version between", value1, value2, "version");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdNotBetween(String value1, String value2) {
|
||||
addCriterion("version_id not between", value1, value2, "versionId");
|
||||
public Criteria andVersionNotBetween(String value1, String value2) {
|
||||
addCriterion("version not between", value1, value2, "version");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
|
@ -1173,6 +1173,136 @@ public class LoadTestExample {
|
|||
addCriterion("ref_id not between", value1, value2, "refId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdIsNull() {
|
||||
addCriterion("version_id is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdIsNotNull() {
|
||||
addCriterion("version_id is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdEqualTo(String value) {
|
||||
addCriterion("version_id =", value, "versionId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdNotEqualTo(String value) {
|
||||
addCriterion("version_id <>", value, "versionId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdGreaterThan(String value) {
|
||||
addCriterion("version_id >", value, "versionId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("version_id >=", value, "versionId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdLessThan(String value) {
|
||||
addCriterion("version_id <", value, "versionId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdLessThanOrEqualTo(String value) {
|
||||
addCriterion("version_id <=", value, "versionId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdLike(String value) {
|
||||
addCriterion("version_id like", value, "versionId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdNotLike(String value) {
|
||||
addCriterion("version_id not like", value, "versionId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdIn(List<String> values) {
|
||||
addCriterion("version_id in", values, "versionId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdNotIn(List<String> values) {
|
||||
addCriterion("version_id not in", values, "versionId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdBetween(String value1, String value2) {
|
||||
addCriterion("version_id between", value1, value2, "versionId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andVersionIdNotBetween(String value1, String value2) {
|
||||
addCriterion("version_id not between", value1, value2, "versionId");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLatestIsNull() {
|
||||
addCriterion("latest is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLatestIsNotNull() {
|
||||
addCriterion("latest is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLatestEqualTo(Boolean value) {
|
||||
addCriterion("latest =", value, "latest");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLatestNotEqualTo(Boolean value) {
|
||||
addCriterion("latest <>", value, "latest");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLatestGreaterThan(Boolean value) {
|
||||
addCriterion("latest >", value, "latest");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLatestGreaterThanOrEqualTo(Boolean value) {
|
||||
addCriterion("latest >=", value, "latest");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLatestLessThan(Boolean value) {
|
||||
addCriterion("latest <", value, "latest");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLatestLessThanOrEqualTo(Boolean value) {
|
||||
addCriterion("latest <=", value, "latest");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLatestIn(List<Boolean> values) {
|
||||
addCriterion("latest in", values, "latest");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLatestNotIn(List<Boolean> values) {
|
||||
addCriterion("latest not in", values, "latest");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLatestBetween(Boolean value1, Boolean value2) {
|
||||
addCriterion("latest between", value1, value2, "latest");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andLatestNotBetween(Boolean value1, Boolean value2) {
|
||||
addCriterion("latest not between", value1, value2, "latest");
|
||||
return (Criteria) this;
|
||||
}
|
||||
}
|
||||
|
||||
public static class Criteria extends GeneratedCriteria {
|
||||
|
|
|
@ -16,8 +16,10 @@
|
|||
<result column="scenario_version" jdbcType="INTEGER" property="scenarioVersion" />
|
||||
<result column="scenario_id" jdbcType="VARCHAR" property="scenarioId" />
|
||||
<result column="order" jdbcType="BIGINT" property="order" />
|
||||
<result column="version_id" jdbcType="VARCHAR" property="versionId" />
|
||||
<result column="version" jdbcType="VARCHAR" property="version" />
|
||||
<result column="ref_id" jdbcType="VARCHAR" property="refId" />
|
||||
<result column="version_id" jdbcType="VARCHAR" property="versionId" />
|
||||
<result column="latest" jdbcType="BIT" property="latest" />
|
||||
</resultMap>
|
||||
<resultMap extends="BaseResultMap" id="ResultMapWithBLOBs" type="io.metersphere.base.domain.LoadTestWithBLOBs">
|
||||
<result column="load_configuration" jdbcType="LONGVARCHAR" property="loadConfiguration" />
|
||||
|
@ -83,7 +85,8 @@
|
|||
</sql>
|
||||
<sql id="Base_Column_List">
|
||||
id, project_id, `name`, description, create_time, update_time, `status`, test_resource_pool_id,
|
||||
user_id, num, create_user, scenario_version, scenario_id, `order`, version_id, ref_id
|
||||
user_id, num, create_user, scenario_version, scenario_id, `order`, version, ref_id,
|
||||
version_id, latest
|
||||
</sql>
|
||||
<sql id="Blob_Column_List">
|
||||
load_configuration, advanced_configuration
|
||||
|
@ -137,19 +140,21 @@
|
|||
</if>
|
||||
</delete>
|
||||
<insert id="insert" parameterType="io.metersphere.base.domain.LoadTestWithBLOBs">
|
||||
insert into load_test (id, project_id, `name`,
|
||||
INSERT INTO load_test (id, project_id, `name`,
|
||||
description, create_time, update_time,
|
||||
`status`, test_resource_pool_id, user_id,
|
||||
num, create_user, scenario_version,
|
||||
scenario_id, `order`, version_id,
|
||||
ref_id, load_configuration, advanced_configuration
|
||||
scenario_id, `order`, version,
|
||||
ref_id, version_id, latest,
|
||||
load_configuration, advanced_configuration
|
||||
)
|
||||
values (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
|
||||
VALUES (#{id,jdbcType=VARCHAR}, #{projectId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
|
||||
#{description,jdbcType=VARCHAR}, #{createTime,jdbcType=BIGINT}, #{updateTime,jdbcType=BIGINT},
|
||||
#{status,jdbcType=VARCHAR}, #{testResourcePoolId,jdbcType=VARCHAR}, #{userId,jdbcType=VARCHAR},
|
||||
#{num,jdbcType=INTEGER}, #{createUser,jdbcType=VARCHAR}, #{scenarioVersion,jdbcType=INTEGER},
|
||||
#{scenarioId,jdbcType=VARCHAR}, #{order,jdbcType=BIGINT}, #{versionId,jdbcType=VARCHAR},
|
||||
#{refId,jdbcType=VARCHAR}, #{loadConfiguration,jdbcType=LONGVARCHAR}, #{advancedConfiguration,jdbcType=LONGVARCHAR}
|
||||
#{scenarioId,jdbcType=VARCHAR}, #{order,jdbcType=BIGINT}, #{version,jdbcType=VARCHAR},
|
||||
#{refId,jdbcType=VARCHAR}, #{versionId,jdbcType=VARCHAR}, #{latest,jdbcType=BIT},
|
||||
#{loadConfiguration,jdbcType=LONGVARCHAR}, #{advancedConfiguration,jdbcType=LONGVARCHAR}
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertSelective" parameterType="io.metersphere.base.domain.LoadTestWithBLOBs">
|
||||
|
@ -197,12 +202,18 @@
|
|||
<if test="order != null">
|
||||
`order`,
|
||||
</if>
|
||||
<if test="versionId != null">
|
||||
version_id,
|
||||
<if test="version != null">
|
||||
version,
|
||||
</if>
|
||||
<if test="refId != null">
|
||||
ref_id,
|
||||
</if>
|
||||
<if test="versionId != null">
|
||||
version_id,
|
||||
</if>
|
||||
<if test="latest != null">
|
||||
latest,
|
||||
</if>
|
||||
<if test="loadConfiguration != null">
|
||||
load_configuration,
|
||||
</if>
|
||||
|
@ -253,12 +264,18 @@
|
|||
<if test="order != null">
|
||||
#{order,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="versionId != null">
|
||||
#{versionId,jdbcType=VARCHAR},
|
||||
<if test="version != null">
|
||||
#{version,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="refId != null">
|
||||
#{refId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="versionId != null">
|
||||
#{versionId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="latest != null">
|
||||
#{latest,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="loadConfiguration != null">
|
||||
#{loadConfiguration,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
|
@ -318,12 +335,18 @@
|
|||
<if test="record.order != null">
|
||||
`order` = #{record.order,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.versionId != null">
|
||||
version_id = #{record.versionId,jdbcType=VARCHAR},
|
||||
<if test="record.version != null">
|
||||
version = #{record.version,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.refId != null">
|
||||
ref_id = #{record.refId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.versionId != null">
|
||||
version_id = #{record.versionId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.latest != null">
|
||||
latest = #{record.latest,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="record.loadConfiguration != null">
|
||||
load_configuration = #{record.loadConfiguration,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
|
@ -351,8 +374,10 @@
|
|||
scenario_version = #{record.scenarioVersion,jdbcType=INTEGER},
|
||||
scenario_id = #{record.scenarioId,jdbcType=VARCHAR},
|
||||
`order` = #{record.order,jdbcType=BIGINT},
|
||||
version_id = #{record.versionId,jdbcType=VARCHAR},
|
||||
version = #{record.version,jdbcType=VARCHAR},
|
||||
ref_id = #{record.refId,jdbcType=VARCHAR},
|
||||
version_id = #{record.versionId,jdbcType=VARCHAR},
|
||||
latest = #{record.latest,jdbcType=BIT},
|
||||
load_configuration = #{record.loadConfiguration,jdbcType=LONGVARCHAR},
|
||||
advanced_configuration = #{record.advancedConfiguration,jdbcType=LONGVARCHAR}
|
||||
<if test="_parameter != null">
|
||||
|
@ -375,8 +400,10 @@
|
|||
scenario_version = #{record.scenarioVersion,jdbcType=INTEGER},
|
||||
scenario_id = #{record.scenarioId,jdbcType=VARCHAR},
|
||||
`order` = #{record.order,jdbcType=BIGINT},
|
||||
version = #{record.version,jdbcType=VARCHAR},
|
||||
ref_id = #{record.refId,jdbcType=VARCHAR},
|
||||
version_id = #{record.versionId,jdbcType=VARCHAR},
|
||||
ref_id = #{record.refId,jdbcType=VARCHAR}
|
||||
latest = #{record.latest,jdbcType=BIT}
|
||||
<if test="_parameter != null">
|
||||
<include refid="Update_By_Example_Where_Clause" />
|
||||
</if>
|
||||
|
@ -423,12 +450,18 @@
|
|||
<if test="order != null">
|
||||
`order` = #{order,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="versionId != null">
|
||||
version_id = #{versionId,jdbcType=VARCHAR},
|
||||
<if test="version != null">
|
||||
version = #{version,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="refId != null">
|
||||
ref_id = #{refId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="versionId != null">
|
||||
version_id = #{versionId,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="latest != null">
|
||||
latest = #{latest,jdbcType=BIT},
|
||||
</if>
|
||||
<if test="loadConfiguration != null">
|
||||
load_configuration = #{loadConfiguration,jdbcType=LONGVARCHAR},
|
||||
</if>
|
||||
|
@ -453,8 +486,10 @@
|
|||
scenario_version = #{scenarioVersion,jdbcType=INTEGER},
|
||||
scenario_id = #{scenarioId,jdbcType=VARCHAR},
|
||||
`order` = #{order,jdbcType=BIGINT},
|
||||
version_id = #{versionId,jdbcType=VARCHAR},
|
||||
version = #{version,jdbcType=VARCHAR},
|
||||
ref_id = #{refId,jdbcType=VARCHAR},
|
||||
version_id = #{versionId,jdbcType=VARCHAR},
|
||||
latest = #{latest,jdbcType=BIT},
|
||||
load_configuration = #{loadConfiguration,jdbcType=LONGVARCHAR},
|
||||
advanced_configuration = #{advancedConfiguration,jdbcType=LONGVARCHAR}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
|
@ -474,8 +509,10 @@
|
|||
scenario_version = #{scenarioVersion,jdbcType=INTEGER},
|
||||
scenario_id = #{scenarioId,jdbcType=VARCHAR},
|
||||
`order` = #{order,jdbcType=BIGINT},
|
||||
version = #{version,jdbcType=VARCHAR},
|
||||
ref_id = #{refId,jdbcType=VARCHAR},
|
||||
version_id = #{versionId,jdbcType=VARCHAR},
|
||||
ref_id = #{refId,jdbcType=VARCHAR}
|
||||
latest = #{latest,jdbcType=BIT}
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
</update>
|
||||
</mapper>
|
|
@ -5,7 +5,6 @@ import io.metersphere.base.domain.LoadTest;
|
|||
import io.metersphere.dto.LoadTestDTO;
|
||||
import io.metersphere.performance.request.QueryProjectFileRequest;
|
||||
import io.metersphere.performance.request.QueryTestPlanRequest;
|
||||
import io.metersphere.track.request.testcase.QueryTestCaseRequest;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -27,9 +26,13 @@ public interface ExtLoadTestMapper {
|
|||
|
||||
List<String> getIdsOrderByUpdateTime(@Param("projectId") String projectId);
|
||||
|
||||
Long getPreOrder(@Param("projectId")String projectId, @Param("baseOrder") Long baseOrder);
|
||||
Long getPreOrder(@Param("projectId") String projectId, @Param("baseOrder") Long baseOrder);
|
||||
|
||||
Long getLastOrder(@Param("projectId")String projectId, @Param("baseOrder") Long baseOrder);
|
||||
Long getLastOrder(@Param("projectId") String projectId, @Param("baseOrder") Long baseOrder);
|
||||
|
||||
int moduleCount(@Param("request") QueryTestPlanRequest request);
|
||||
|
||||
void addLatestVersion(String refId);
|
||||
|
||||
void clearLatestVersion(String refId);
|
||||
}
|
||||
|
|
|
@ -287,4 +287,48 @@
|
|||
AND ${versionTable}.latest = 1
|
||||
</if>
|
||||
</sql>
|
||||
|
||||
<update id="addLatestVersion">
|
||||
UPDATE load_test
|
||||
INNER JOIN ((
|
||||
SELECT tmp.id
|
||||
FROM load_test tmp
|
||||
JOIN project_version
|
||||
ON tmp.project_id = project_version.project_id AND
|
||||
tmp.version_id = project_version.id AND project_version.latest = TRUE
|
||||
WHERE ref_id = #{refId,jdbcType=VARCHAR}
|
||||
LIMIT 1
|
||||
)
|
||||
UNION
|
||||
(
|
||||
SELECT tmp.id
|
||||
FROM load_test tmp
|
||||
JOIN project_version
|
||||
ON tmp.project_id = project_version.project_id AND
|
||||
tmp.version_id = project_version.id
|
||||
AND NOT EXISTS(SELECT ref_id
|
||||
FROM load_test tmp2
|
||||
JOIN project_version
|
||||
ON tmp2.project_id =
|
||||
project_version.project_id AND
|
||||
version_id =
|
||||
project_version.id AND
|
||||
project_version.latest = TRUE
|
||||
WHERE tmp.ref_id = tmp2.ref_id)
|
||||
WHERE tmp.ref_id = #{refId,jdbcType=VARCHAR}
|
||||
ORDER BY tmp.update_time DESC
|
||||
LIMIT 1)) AS t ON load_test.id = t.id
|
||||
SET load_test.latest = TRUE
|
||||
</update>
|
||||
|
||||
<update id="clearLatestVersion">
|
||||
UPDATE load_test
|
||||
SET latest = 0
|
||||
<where>
|
||||
<if test="refId != null">
|
||||
and ref_id = #{refId}
|
||||
</if>
|
||||
</where>
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
|
|
@ -282,6 +282,7 @@ public class PerformanceTestService {
|
|||
loadTest.setOrder(ServiceUtils.getNextOrder(request.getProjectId(), extLoadTestMapper::getLastOrder));
|
||||
loadTest.setVersionId(request.getVersionId());
|
||||
loadTest.setRefId(request.getId());
|
||||
loadTest.setLatest(true); // 创建新版本的时候一定是最新的
|
||||
List<ApiLoadTest> apiList = request.getApiList();
|
||||
apiPerformanceService.add(apiList, loadTest.getId());
|
||||
loadTestMapper.insert(loadTest);
|
||||
|
@ -348,9 +349,18 @@ public class PerformanceTestService {
|
|||
copyLoadTestFiles(testId, loadTest.getId());
|
||||
loadTestMapper.insertSelective(loadTest);
|
||||
}
|
||||
checkAndSetLatestVersion(loadTest.getRefId());
|
||||
return loadTest;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查设置最新版本
|
||||
*/
|
||||
private void checkAndSetLatestVersion(String refId) {
|
||||
extLoadTestMapper.clearLatestVersion(refId);
|
||||
extLoadTestMapper.addLatestVersion(refId);
|
||||
}
|
||||
|
||||
public void saveFollows(String testId, List<String> follows) {
|
||||
LoadTestFollowExample example = new LoadTestFollowExample();
|
||||
example.createCriteria().andTestIdEqualTo(testId);
|
||||
|
@ -577,6 +587,7 @@ public class PerformanceTestService {
|
|||
copy.setCreateUser(Objects.requireNonNull(SessionUtils.getUser()).getId());
|
||||
copy.setNum(getNextNum(copy.getProjectId()));
|
||||
copy.setRefId(copy.getId());
|
||||
copy.setLatest(true);
|
||||
loadTestMapper.insert(copy);
|
||||
// copy test file
|
||||
copyLoadTestFiles(request.getId(), copy.getId());
|
||||
|
@ -1003,16 +1014,16 @@ public class PerformanceTestService {
|
|||
|
||||
public List<LoadTestDTO> getLoadTestVersions(String loadTestId) {
|
||||
LoadTestWithBLOBs loadTestWithBLOBs = loadTestMapper.selectByPrimaryKey(loadTestId);
|
||||
if(loadTestWithBLOBs==null){
|
||||
if (loadTestWithBLOBs == null) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
QueryTestPlanRequest request = new QueryTestPlanRequest() ;
|
||||
QueryTestPlanRequest request = new QueryTestPlanRequest();
|
||||
request.setRefId(loadTestWithBLOBs.getRefId());
|
||||
return this.list(request);
|
||||
}
|
||||
|
||||
public LoadTestDTO getLoadTestByVersion(String versionId,String refId) {
|
||||
QueryTestPlanRequest request = new QueryTestPlanRequest() ;
|
||||
public LoadTestDTO getLoadTestByVersion(String versionId, String refId) {
|
||||
QueryTestPlanRequest request = new QueryTestPlanRequest();
|
||||
request.setRefId(refId);
|
||||
request.setVersionId(versionId);
|
||||
List<LoadTestDTO> list = this.list(request);
|
||||
|
@ -1022,9 +1033,14 @@ public class PerformanceTestService {
|
|||
return list.get(0);
|
||||
}
|
||||
|
||||
public void deleteLoadTestByVersion(String version,String refId) {
|
||||
public void deleteLoadTestByVersion(String version, String refId) {
|
||||
LoadTestExample loadTestExample = new LoadTestExample();
|
||||
loadTestExample.createCriteria().andRefIdEqualTo(refId).andVersionIdEqualTo(version);
|
||||
List<LoadTest> loadTests = loadTestMapper.selectByExample(loadTestExample);
|
||||
if (CollectionUtils.isEmpty(loadTests)) {
|
||||
return;
|
||||
}
|
||||
loadTestMapper.deleteByExample(loadTestExample);
|
||||
checkAndSetLatestVersion(refId);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue