This commit is contained in:
oneao committed 2025-12-29 17:31:10 +08:00
1 parent 00b21b6b44
commit 6fd3bf5138
41 files changed
+1183 -98

No files matched your search

@@ -0,0 +1,42 @@
<?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="cn.link56.im.mapper.ImFriendMapper">
<select id="selectFriend" resultType="cn.link56.im.model.vo.QueryFriendVO">
SELECT *
FROM (
SELECT
f.b_id AS id,
f.b_friend_id AS friendId,
u.b_name AS friendName,
u.b_avatar AS friendAvatar,
f.b_unread_count AS unreadCount,
m.b_id AS lastMessageId,
m.b_send_time AS lastMessageTime,
m.b_type AS lastMessageType,
m.b_content AS lastMessageContent,
ROW_NUMBER() OVER (
ORDER BY
<if test="id != null and id != 0">
CASE WHEN f.b_id = #{id} THEN 0 ELSE 1 END,
</if>
m.b_send_time DESC
) AS rn
FROM b_im_friend f
LEFT JOIN b_company_user u ON f.b_friend_id = u.b_id
LEFT JOIN b_im_private_message m ON f.b_last_message_id = m.b_id
WHERE f.b_user_id = #{userId}
) AS t
WHERE t.rn BETWEEN #{offset} AND #{limit}
</select>
<select id="selectFriendTotal" resultType="java.lang.Long">
SELECT COUNT(*)
FROM b_im_friend f
WHERE f.b_user_id = #{userId}
</select>
</mapper>
@@ -0,0 +1,43 @@
<?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="cn.link56.im.mapper.ImGroupMapper">
<select id="selectGroup" resultType="cn.link56.im.model.vo.QueryGroupVO">
SELECT *
FROM (
SELECT
g.b_id AS id,
g.b_name AS name,
g.b_avatar AS avatar,
gu.b_unread_count AS unreadCount,
m.b_id AS lastMessageId,
m.b_send_time AS lastMessageTime,
m.b_type AS lastMessageType,
m.b_content AS lastMessageContent,
ROW_NUMBER() OVER (
ORDER BY
<if test="id != null and id != 0">
CASE WHEN g.b_id = #{id} THEN 0 ELSE 1 END,
</if>
m.b_send_time DESC
) AS rn
FROM b_im_group g
INNER JOIN b_im_group_user gu ON g.b_id = gu.b_group_id
LEFT JOIN b_im_group_message m ON gu.b_last_message_id = m.b_id
WHERE gu.b_user_id = #{userId}
) AS t
WHERE t.rn BETWEEN #{offset} AND #{limit}
</select>
<select id="selectGroupTotal" resultType="java.lang.Long">
SELECT COUNT(DISTINCT g.b_id)
FROM b_im_group g
INNER JOIN b_im_group_user gu ON g.b_id = gu.b_group_id
WHERE gu.b_user_id = #{userId}
</select>
</mapper>