优化 获取关注、粉丝列表

This commit is contained in:
2024-08-21 10:23:55 +08:00
parent 203c88dd70
commit 28df672a7d
19 changed files with 334 additions and 74 deletions

View File

@@ -0,0 +1,55 @@
<?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="com.ai.da.mapper.primary.UserFollowMapper">
<select id="getFolloweeListByFollower" resultType="com.ai.da.model.vo.AccountFollowVO">
SELECT a.id as user_id, a.user_name AS user_name, a.avatar AS avatar, b.create_time AS follow_time
FROM t_account a
INNER JOIN t_user_follow b ON a.id = b.followee_id
WHERE b.follower_id = #{followerAccountId}
<if test="order != null and order != ''">
ORDER BY b.create_time ${order}
</if>
LIMIT #{limit} OFFSET #{offset}
</select>
<select id="getFollowerListByFollowee" resultType="com.ai.da.model.vo.AccountFollowVO">
SELECT a.id as user_id, a.user_name AS user_name, a.avatar AS avatar, b.create_time AS follow_time
FROM t_account a
INNER JOIN t_user_follow b ON a.id = b.follower_id
WHERE b.followee_id = #{followeeAccountId}
<if test="order != null and order != ''">
ORDER BY b.create_time ${order}
</if>
LIMIT #{limit} OFFSET #{offset}
</select>
<select id="getFolloweeListByName" resultType="com.ai.da.model.vo.AccountFollowVO">
SELECT a.id as user_id, a.user_name, a.avatar, b.create_time as follow_time
FROM t_account a
INNER JOIN t_user_follow b ON a.id = b.followee_id
WHERE b.follower_id = #{followerId}
AND b.followee_id in (
SELECT id
FROM t_account
WHERE user_name = #{name} OR user_email = #{name}
)
GROUP BY a.user_email;
</select>
<select id="getFollowerListByName" resultType="com.ai.da.model.vo.AccountFollowVO">
SELECT a.id as user_id, a.user_name, a.avatar, b.create_time as follow_time
FROM t_account a
INNER JOIN t_user_follow b ON a.id = b.follower_id
WHERE b.followee_id = #{followeeId}
AND b.follower_id in (
SELECT id
FROM t_account
WHERE user_name = #{name} OR user_email = #{name}
)
GROUP BY a.user_email;
</select>
</mapper>