You've already forked FrameTour-BE
refactor(SourceMapper): 优化查询条件动态拼接逻辑
- 使用<where>标签替换原有静态where条件 - 添加对scenicId、isBuy、type、faceId参数的动态判断 - 确保只有非空参数参与SQL查询条件构建 - 提高SQL语句可读性和维护性 - 避免因缺少条件导致的语法错误风险
This commit is contained in:
@@ -244,13 +244,12 @@
|
||||
select so.id, ms.scenic_id, device_id, thumb_url, url, ms.is_free, so.create_time, so.update_time, ms.is_buy, video_url
|
||||
from member_source ms
|
||||
left join source so on ms.source_id = so.id
|
||||
|
||||
where
|
||||
ms.member_id = #{memberId} and so.id is not null
|
||||
<where>
|
||||
<if test="scenicId!= null">and ms.scenic_id = #{scenicId} </if>
|
||||
<if test="isBuy!=null">and ms.is_buy = #{isBuy} </if>
|
||||
<if test="type!=null">and ms.type = #{type} </if>
|
||||
<if test="faceId!=null">and ms.face_id = #{faceId} </if>
|
||||
</where>
|
||||
order by ms.is_free desc, so.create_time asc
|
||||
</select>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user