From bdd0197d78d998bbc05cc5e19187b16582b518a2 Mon Sep 17 00:00:00 2001 From: FatttSnake Date: Fri, 26 Apr 2024 16:31:44 +0800 Subject: [PATCH] Fix(EditService): Fix get wrong tool detail Fix get wrong tool detail in source page --- .../kotlin/top/fatweb/oxygen/api/mapper/tool/EditMapper.kt | 2 +- .../fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt | 7 ++----- src/main/resources/mapper/tool/EditMapper.xml | 3 +++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/EditMapper.kt b/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/EditMapper.kt index f874483..2fb8321 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/EditMapper.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/mapper/tool/EditMapper.kt @@ -69,5 +69,5 @@ interface EditMapper : BaseMapper { @Param("ver") ver: String, @Param("platform") platform: ToolBase.Platform, @Param("operator") operator: String? - ): List? + ): Tool? } \ No newline at end of file diff --git a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt index 44165cb..c5ef9d3 100644 --- a/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt +++ b/src/main/kotlin/top/fatweb/oxygen/api/service/tool/impl/EditServiceImpl.kt @@ -219,12 +219,9 @@ class EditServiceImpl( if (username == "!" && WebUtil.getLoginUserId() == null) { throw NoRecordFoundException() } - val toolList = baseMapper.selectDetail(username, toolId, ver, platform, WebUtil.getLoginUsername()) - if (toolList.isNullOrEmpty()) { - throw NoRecordFoundException() - } - return toolList.first().let(ToolConverter::toolToToolVo) + return baseMapper.selectDetail(username, toolId, ver, platform, WebUtil.getLoginUsername()) + ?.let(ToolConverter::toolToToolVo) ?: throw NoRecordFoundException() } override fun submit(id: Long): Boolean { diff --git a/src/main/resources/mapper/tool/EditMapper.xml b/src/main/resources/mapper/tool/EditMapper.xml index ca46957..c48c967 100644 --- a/src/main/resources/mapper/tool/EditMapper.xml +++ b/src/main/resources/mapper/tool/EditMapper.xml @@ -195,6 +195,7 @@ and tsu.username = #{username} + and t_b_tool_main.publish != 0 @@ -206,11 +207,13 @@ and tsu.username = #{username} + and t_b_tool_main.publish != 0 order by t_b_tool_main.id desc + limit 1 \ No newline at end of file