You've already forked FrameTour-BE
feat(service): 优化商品查询逻辑并新增分组查询接口
- 在 SourceMapper 中新增 queryGroupedByFaceAndType 方法,支持按 faceId 和 type 分组查询 - 调整 orderBiz.isBuy 方法的参数顺序,统一调用格式 - 修改 GoodsServiceImpl 中源素材查询逻辑,使用新分组方法减少循环嵌套 - 简化源素材去重及过滤禁用类型的处理流程 - 提前获取景区配置信息,避免重复查询 - 优化代码结构,提升可读性和维护性
This commit is contained in:
@@ -265,15 +265,58 @@
|
||||
select so.id, ms.face_id, ms.scenic_id, ms.type, so.thumb_url, so.url, ms.is_free, so.create_time, so.update_time,ms.is_buy
|
||||
from member_source ms
|
||||
left join source so on ms.source_id = so.id
|
||||
|
||||
|
||||
where
|
||||
ms.member_id = #{memberId} and so.id
|
||||
ms.member_id = #{memberId} and so.id is not null
|
||||
<if test="faceId!= null">and ms.face_id = #{faceId} </if>
|
||||
<if test="type!=null">and ms.type = #{type} </if>
|
||||
<if test="scenicId!= null">and ms.scenic_id = #{scenicId} </if>
|
||||
<if test="isBuy!=null">and ms.is_buy = #{isBuy}</if>
|
||||
order by so.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="queryGroupedByFaceAndType" resultType="com.ycwl.basic.model.pc.source.resp.SourceRespVO">
|
||||
SELECT
|
||||
t.id,
|
||||
t.face_id,
|
||||
t.scenic_id,
|
||||
t.type,
|
||||
t.thumb_url,
|
||||
t.url,
|
||||
t.is_free,
|
||||
t.create_time,
|
||||
t.update_time,
|
||||
t.is_buy
|
||||
FROM (
|
||||
SELECT
|
||||
so.id,
|
||||
ms.face_id,
|
||||
ms.scenic_id,
|
||||
ms.type,
|
||||
so.thumb_url,
|
||||
so.url,
|
||||
ms.is_free,
|
||||
so.create_time,
|
||||
so.update_time,
|
||||
ms.is_buy,
|
||||
ROW_NUMBER() OVER (PARTITION BY ms.face_id, ms.type ORDER BY so.create_time DESC) as rn
|
||||
FROM member_source ms
|
||||
LEFT JOIN source so ON ms.source_id = so.id
|
||||
WHERE so.id IS NOT NULL
|
||||
<if test="faceIds != null and faceIds.size() > 0">
|
||||
AND ms.face_id IN
|
||||
<foreach collection="faceIds" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="faceId != null">AND ms.face_id = #{faceId}</if>
|
||||
<if test="scenicId != null">AND ms.scenic_id = #{scenicId}</if>
|
||||
<if test="isBuy != null">AND ms.is_buy = #{isBuy}</if>
|
||||
) t
|
||||
WHERE t.rn = 1
|
||||
ORDER BY t.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="querySameVideo" resultType="com.ycwl.basic.model.pc.source.entity.SourceEntity">
|
||||
select *
|
||||
from source
|
||||
|
||||
Reference in New Issue
Block a user