Feat(StoreController): Add get favorite tool list api

Add get favorite tool list api to StoreController
This commit is contained in:
2024-04-28 15:29:06 +08:00
parent c49b7d7532
commit 059b5dc2cb
10 changed files with 118 additions and 145 deletions

View File

@@ -95,11 +95,15 @@
</select>
<select id="selectPersonalToolIdPage" resultType="string">
select distinct t_b_tool_main.tool_id
from t_b_tool_main
where t_b_tool_main.deleted = 0
and t_b_tool_main.author_id = #{userId}
order by t_b_tool_main.id desc
select t.tool_id
from (select tbtm.tool_id
from (select *,
row_number() over (partition by t_b_tool_main.tool_id order by t_b_tool_main.id desc ) as rn
from t_b_tool_main
where t_b_tool_main.deleted = 0
and t_b_tool_main.author_id = #{userId}) tbtm
where tbtm.rn = 1
order by tbtm.id desc) t
</select>
<select id="selectListByToolIds" resultMap="top.fatweb.oxygen.api.mapper.tool.ManagementMapper.toolMap">

View File

@@ -57,58 +57,6 @@
where temp2.rn2 = 1
</select>
<select id="selectListByIds" resultMap="top.fatweb.oxygen.api.mapper.tool.ManagementMapper.toolWithAuthor">
select t_b_tool_main.id as tool_id,
t_b_tool_main.name as tool_name,
t_b_tool_main.tool_id as tool_tool_id,
t_b_tool_main.icon as tool_icon,
t_b_tool_main.platform as tool_platform,
t_b_tool_main.description as tool_description,
t_b_tool_main.base_id as tool_base_id,
t_b_tool_main.author_id as tool_author_id,
t_b_tool_main.ver as tool_ver,
t_b_tool_main.keywords as tool_keywords,
t_b_tool_main.source_id as tool_source_id,
t_b_tool_main.dist_id as tool_dist_id,
t_b_tool_main.entry_point as tool_entry_point,
t_b_tool_main.publish as tool_publish,
t_b_tool_main.review as tool_review,
t_b_tool_main.create_time as tool_create_time,
t_b_tool_main.update_time as tool_update_time,
t_b_tool_main.deleted as tool_deleted,
t_b_tool_main.version as tool_version,
tsu.id as user_id,
tsu.username as user_username,
tsui.id as user_info_id,
tsui.nickname as user_info_nickname,
tsui.avatar as user_info_avatar,
tbtc.id as tool_category_id,
tbtc.name as tool_category_name,
tbtc.enable as tool_category_enable,
tbtc.create_time as tool_category_create_time,
tbtc.update_time as tool_category_update_time,
tbtc.deleted as tool_category_deleted,
tbtc.version as tool_category_version
from t_b_tool_main
left join (select * from t_s_user where deleted = 0) as tsu on tsu.id = t_b_tool_main.author_id
left join (select * from t_s_user_info where deleted = 0) as tsui
on tsui.user_id = t_b_tool_main.author_id
left join (select * from t_r_tool_main_category where deleted = 0) as trtmc
on t_b_tool_main.id = trtmc.tool_id
left join (select * from t_b_tool_category where deleted = 0 and enable = 1) as tbtc
on tbtc.id = trtmc.category_id
<where>
<foreach collection="ids" item="item" index="index" open="and t_b_tool_main.id in (" separator="," close=")"
nullable="true">
#{item}
</foreach>
</where>
<foreach collection="ids" item="item" index="index" open="order by field(t_b_tool_main.id," separator=","
close=")" nullable="true">
#{item}
</foreach>
</select>
<select id="selectListByAuthorToolIds" resultMap="top.fatweb.oxygen.api.mapper.tool.ManagementMapper.toolWithAuthor">
select tbtm.id as tool_id,
tbtm.name as tool_name,
@@ -156,7 +104,7 @@
left join (select * from t_b_tool_category where deleted = 0 and enable = 1) as tbtc
on tbtc.id = trtmc.category_id
left join (select * from t_b_tool_favorite where deleted = 0) as tbtf
on tbtf.user_id = ${operator} and tbtf.username = tsu.username and tbtf.tool_id = tbtm.tool_id and tbtf.platform = tbtm.platform
on tbtf.user_id = #{operator} and tbtf.author_id = tbtm.author_id and tbtf.tool_id = tbtm.tool_id
<where>
and tbtm.rn = 1
<foreach collection="ids" item="item" index="index" open="and concat(tbtm.author_id, ':', tbtm.tool_id) in (" separator="," close=")"
@@ -169,4 +117,14 @@
#{item}
</foreach>
</select>
<select id="countPublishedToolByAuthorAndToolId" resultType="long">
select count(1)
from t_b_tool_main
where t_b_tool_main.deleted = 0
and t_b_tool_main.author_id = #{authorId}
and t_b_tool_main.tool_id = #{toolId}
and t_b_tool_main.publish != 0
and t_b_tool_main.review = 'PASS'
</select>
</mapper>