fix: 查询case的时候默认显示最新版本

--bug=1009672 --user=刘瑞斌 [接口CASE]-同一个接口不同版本CASE 的ID是相同的 https://www.tapd.cn/55049933/s/1092827
This commit is contained in:
CaptainB 2022-01-17 13:13:42 +08:00 committed by 刘瑞斌
parent b06940796a
commit 835aea45fa
1 changed files with 20 additions and 0 deletions

View File

@ -416,6 +416,26 @@
<if test="request.versionId != null">
AND t1.version_id = #{request.versionId}
</if>
<if test="request.versionId == null and request.refId == null and request.id == null">
AND (
t1.version_id = (SELECT project_version.id
FROM api_definition tmp
JOIN project_version
ON tmp.project_id = project_version.project_id AND tmp.version_id = project_version.id AND latest = TRUE
WHERE ref_id = a.ref_id
LIMIT 1)
OR
t1.version_id = (SELECT project_version.id
FROM api_definition tmp
JOIN project_version ON tmp.project_id = project_version.project_id AND
tmp.version_id = project_version.id
WHERE ref_id = a.ref_id
GROUP BY ref_id
HAVING MAX(latest) = 0
ORDER BY MAX(project_version.create_time) DESC
LIMIT 1)
)
</if>
GROUP BY t1.id,
t1.project_id,
t1.name,