fix(接口测试): 修改导入接口对ref的检查

--user=郭雨琦
This commit is contained in:
guoyuqi 2022-07-04 15:55:02 +08:00 committed by xiaomeinvG
parent 2888fb2775
commit 08f768ab01
4 changed files with 62 additions and 52 deletions

View File

@ -1335,6 +1335,10 @@ public class ApiDefinitionService {
MSException.throwException(Translator.get("connection_timeout"));
}
}
Project project = projectMapper.selectByPrimaryKey(request.getProjectId());
if (StringUtils.equals(request.getType(), "schedule")) {
request.setProtocol("HTTP");
}
try {
apiImport = (ApiDefinitionImport) Objects.requireNonNull(runService).parse(file == null ? null : file.getInputStream(), request);
if (apiImport.getMocks() == null) {
@ -1356,7 +1360,7 @@ public class ApiDefinitionService {
paramMap.put("url", request.getSwaggerUrl());
paramMap.put("projectId", request.getProjectId());
NoticeModel noticeModel = NoticeModel.builder()
.operator(SessionUtils.getUserId())
.operator(project.getCreateUser())
.context(context)
.testId(scheduleId)
.subject(Translator.get("swagger_url_scheduled_import_notification"))
@ -1381,7 +1385,7 @@ public class ApiDefinitionService {
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("url", request.getSwaggerUrl());
NoticeModel noticeModel = NoticeModel.builder()
.operator(SessionUtils.getUserId())
.operator(project.getCreateUser())
.context(context)
.testId(scheduleId)
.subject(Translator.get("swagger_url_scheduled_import_notification"))

View File

@ -1018,7 +1018,7 @@
<update id="clearLatestVersion">
UPDATE api_definition
SET latest = 0
and ref_id = #{refId}
where ref_id = #{refId}
</update>
<update id="addLatestVersion">

View File

@ -111,7 +111,8 @@
FROM load_test
LEFT JOIN project ON load_test.project_id = project.id
LEFT JOIN user ON load_test.user_id = user.id
LEFT JOIN project_version on project.id = project_version.project_id AND project_version.id = load_test.version_id
LEFT JOIN project_version on project.id = project_version.project_id AND project_version.id =
load_test.version_id
<where>
<if test="request.combine != null">
<include refid="combine">
@ -211,7 +212,10 @@
</where>
</select>
<select id="getNextNum" resultType="io.metersphere.base.domain.LoadTest">
select * from load_test lt where lt.project_id = #{projectId} ORDER BY num DESC LIMIT 1;
select *
from load_test lt
where lt.project_id = #{projectId}
ORDER BY num DESC LIMIT 1;
</select>
<select id="moduleCount" resultType="java.lang.Integer">
@ -322,7 +326,6 @@
</sql>
<select id="getProjectFiles" resultType="io.metersphere.base.domain.FileMetadata">
SELECT file_metadata.*
FROM file_metadata
@ -338,10 +341,14 @@
</select>
<select id="selectProjectIds" resultType="java.lang.String">
select DISTINCT project_id from load_test;
select DISTINCT project_id
from load_test;
</select>
<select id="getIdsOrderByUpdateTime" resultType="java.lang.String">
select id from load_test where project_id = #{projectId} order by update_time ASC;
select id
from load_test
where project_id = #{projectId}
order by update_time ASC;
</select>
<select id="getLastOrder" resultType="java.lang.Long">
@ -390,7 +397,7 @@
JOIN project_version
ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
AND NOT EXISTS(SELECT ref_id
AND NOT EXISTS (SELECT ref_id
FROM load_test tmp2
JOIN project_version
ON tmp2.project_id =
@ -401,7 +408,8 @@
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
LIMIT 1)) AS t
ON load_test.id = t.id
SET load_test.latest = TRUE
WHERE ref_id = #{refId,jdbcType=VARCHAR}
</update>
@ -409,11 +417,7 @@
<update id="clearLatestVersion">
UPDATE load_test
SET latest = 0
<where>
<if test="refId != null">
and ref_id = #{refId}
</if>
</where>
where ref_id = #{refId}
</update>
<select id="selectRefIdsForVersionChange" resultType="java.lang.String">
@ -422,8 +426,10 @@
WHERE ref_id NOT IN (
SELECT DISTINCT ref_id
FROM load_test
WHERE version_id = #{versionId} AND project_id = #{projectId}
) AND project_id = #{projectId}
WHERE version_id = #{versionId}
AND project_id = #{projectId}
)
AND project_id = #{projectId}
</select>
<select id="getFileMetadataByIds" resultType="io.metersphere.base.domain.FileMetadata">