Feat(ToolStore): Add tool favorite controller

Add controller to add and remove favorite tool
This commit is contained in:
2024-04-26 18:07:49 +08:00
parent 96afb185e7
commit 5c3484a22d
21 changed files with 389 additions and 21 deletions

View File

@@ -237,6 +237,7 @@
<result property="createTime" column="tool_create_time"/>
<result property="deleted" column="tool_deleted"/>
<result property="version" column="tool_version"/>
<result property="favorite" column="tool_favorite"/>
<result property="keywords" column="tool_keywords"
typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
<collection property="categories"

View File

@@ -140,7 +140,8 @@
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
tbtc.version as tool_category_version,
if(tbtf.id is null, 0, 1) as tool_favorite
from (select *, row_number() over (partition by t_b_tool_main.tool_id, t_b_tool_main.author_id, t_b_tool_main.platform order by t_b_tool_main.publish desc) as rn
from t_b_tool_main
where deleted = 0
@@ -149,11 +150,13 @@
) as tbtm
left join (select * from t_s_user where deleted = 0) as tsu on tsu.id = tbtm.author_id
left join (select * from t_s_user_info where deleted = 0) as tsui
on tsui.user_id = tbtm.author_id
on tsui.user_id = tbtm.author_id
left join (select * from t_r_tool_main_category where deleted = 0) as trtmc
on tbtm.id = trtmc.tool_id
on tbtm.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
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
<where>
and tbtm.rn = 1
<foreach collection="ids" item="item" index="index" open="and concat(tbtm.author_id, ':', tbtm.tool_id) in (" separator="," close=")"

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="top.fatweb.oxygen.api.mapper.tool.ToolFavoriteMapper">
<resultMap id="toolFavoriteMap" type="toolFavorite">
<id property="id" column="tool_favorite_id"/>
<result property="userId" column="tool_favorite_user_id"/>
<result property="username" column="tool_favorite_username"/>
<result property="toolId" column="tool_favorite_tool_id"/>
</resultMap>
</mapper>