guohongjin
2024-05-15 5b7639f0bd9e056738ec15100ed0532e965c6cd5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?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.stylefeng.guns.modular.business.mapper.ImGroupMapper">
 
    <select id="getMyGroup" resultType="cn.stylefeng.guns.modular.business.entity.ImGroup">
        SELECT * FROM im_group o
        LEFT JOIN im_group_user gu ON gu.group_id = o.id
        LEFT JOIN toc_customer tu ON tu.customer_id = gu.user_id
        <where>
            o.is_delete = 0 AND gu.is_delete = 0
            <if test="groupType != null">
                AND o.group_type = #{groupType}
            </if>
            <if test="orderId != null">
                AND o.order_id = #{orderId}
            </if>
            <if test="statusFlag != null">
                AND o.status_flag = #{statusFlag}
            </if>
            <if test="userId != null">
                AND gu.user_id = #{userId}
            </if>
            <if test="groupName != null and groupName != ''">
                AND o.`name` LIKE CONCAT('%',#{groupName},'%')
            </if>
            <if test="nickName != null and nickName != ''">
                AND tu.nick_name LIKE CONCAT('%',#{nickName},'%')
            </if>
        </where>
        GROUP BY o.id
    </select>
 
    <select id="groupUser" resultType="cn.stylefeng.guns.modular.business.dto.ImGroupUserDto">
        SELECT
            o.*, u.nick_name, u.avatar, u.user_type, u.im_token, u.post_ids
        FROM
            im_group_user o
        LEFT JOIN
            toc_customer u ON o.user_id = u.customer_id
        <where>
            o.is_delete = 0
            <if test="groupId != null">
                AND o.group_id = #{groupId}
            </if>
        </where>
    </select>
 
</mapper>