| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 |
- <?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.fs.qw.mapper.QwSessionMapper">
- <resultMap type="QwSession" id="QwSessionResult">
- <result property="sessionId" column="session_id" />
- <result property="chatId" column="chat_id" />
- <result property="qwExtWxId" column="qw_ext_wx_id" />
- <result property="qwExtId" column="qw_ext_id" />
- <result property="corpId" column="corp_id" />
- <result property="qwUserId" column="qw_user_id" />
- <result property="createTime" column="create_time" />
- <result property="updateTime" column="update_time" />
- <result property="status" column="status" />
- <result property="companyId" column="company_id" />
- <result property="userType" column="user_type" />
- <result property="nickName" column="nick_name" />
- <result property="avatar" column="avatar" />
- <result property="companyUserId" column="company_user_id" />
- <result property="isRoom" column="is_room" />
- <result property="firstLetter" column="first_letter" />
- <result property="lastMsgId" column="last_msg_id" />
- <result property="lastMsgType" column="last_msg_type" />
- <result property="lastSendTime" column="last_send_time" />
- <result property="lastContent" column="last_content" />
- </resultMap>
- <sql id="selectQwSessionVo">
- select session_id,qw_ext_wx_id, chat_id, qw_ext_id, corp_id, qw_user_id, create_time, update_time, status,
- company_id, user_type, nick_name, avatar, company_user_id, is_room, first_letter, last_msg_id,
- last_send_time,last_content, last_msg_type from qw_session
- </sql>
- <select id="selectQwSessionList" parameterType="QwSession" resultMap="QwSessionResult">
- <include refid="selectQwSessionVo"/>
- <where>
- <if test="chatId != null and chatId != ''"> and chat_id = #{chatId}</if>
- <if test="qwExtId != null "> and qw_ext_id = #{qwExtId}</if>
- <if test="corpId != null and corpId != ''"> and corp_id = #{corpId}</if>
- <if test="qwUserId != null and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
- <if test="status != null "> and status = #{status}</if>
- <if test="companyId != null "> and company_id = #{companyId}</if>
- <if test="userType != null "> and user_type = #{userType}</if>
- <if test="nickName != null and nickName != ''"> and nick_name like concat( #{nickName}, '%')</if>
- <if test="avatar != null and avatar != ''"> and avatar = #{avatar}</if>
- <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
- <if test="isRoom != null "> and is_room = #{isRoom}</if>
- <if test="firstLetter != null "> and first_letter = #{firstLetter}</if>
- <if test="lastMsgId != null "> and last_msg_id = #{lastMsgId}</if>
- <if test="lastMsgType != null "> and last_msg_type = #{lastMsgType}</if>
- <if test="lastSendTime != null "> and last_send_time = #{lastSendTime}</if>
- <if test="lastContent != null "> and last_content = #{lastContent}</if>
- </where>
- </select>
- <select id="selectQwSessionBySessionId" parameterType="Long" resultMap="QwSessionResult">
- <include refid="selectQwSessionVo"/>
- where session_id = #{sessionId}
- </select>
- <select id="selectQwConversationByMap" resultType="com.fs.qw.vo.QwContactListVO">
- select
- s.session_id as id,
- s.qw_ext_id as extId,
- s.avatar,
- s.session_id as conversationId,
- s.nick_name as displayName,
- ec.comment_status = 1 as isBlack,
- s.is_room as isGroup,
- (u.qw_repeat = 1 OR u.user_repeat = 1) as isRepeat,
- false as isPend,
- s.last_msg_id as msgId,
- s.last_msg_type as type,
- s.last_content as lastContent,
- s.last_send_time as lastSendTime,
- 0 as unread
- from qw_session s
- left join qw_external_contact ec on s.qw_ext_id = ec.id
- left join fs_user u on ec.fs_user_id = u.user_id
- where s.qw_user_id = #{params.qwUserId}
- <if test="params.removeBlack != null and params.removeBlack">
- and ec.comment_status = 0
- </if>
- <if test="params.removeRepeat != null and params.removeRepeat">
- and u.qw_repeat != 1 and u.user_repeat != 1
- </if>
- order by s.update_time desc
- </select>
- <insert id="insertQwSession" parameterType="QwSession" useGeneratedKeys="true" keyProperty="sessionId">
- insert into qw_session
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="chatId != null">chat_id,</if>
- <if test="qwExtId != null">qw_ext_id,</if>
- <if test="qwExtWxId != null">qw_ext_wx_id,</if>
- <if test="corpId != null">corp_id,</if>
- <if test="qwUserId != null">qw_user_id,</if>
- <if test="createTime != null">create_time,</if>
- <if test="updateTime != null">update_time,</if>
- <if test="status != null">status,</if>
- <if test="companyId != null">company_id,</if>
- <if test="userType != null">user_type,</if>
- <if test="nickName != null">nick_name,</if>
- <if test="avatar != null">avatar,</if>
- <if test="companyUserId != null">company_user_id,</if>
- <if test="isRoom != null">is_room,</if>
- <if test="firstLetter != null">first_letter,</if>
- <if test="lastMsgId != null">last_msg_id,</if>
- <if test="lastMsgType != null">last_msg_type,</if>
- <if test="lastSendTime != null">last_send_time,</if>
- <if test="lastContent != null">last_content,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="chatId != null">#{chatId},</if>
- <if test="qwExtId != null">#{qwExtId},</if>
- <if test="qwExtWxId != null">#{qwExtWxId},</if>
- <if test="corpId != null">#{corpId},</if>
- <if test="qwUserId != null">#{qwUserId},</if>
- <if test="createTime != null">#{createTime},</if>
- <if test="updateTime != null">#{updateTime},</if>
- <if test="status != null">#{status},</if>
- <if test="companyId != null">#{companyId},</if>
- <if test="userType != null">#{userType},</if>
- <if test="nickName != null">#{nickName},</if>
- <if test="avatar != null">#{avatar},</if>
- <if test="companyUserId != null">#{companyUserId},</if>
- <if test="isRoom != null">#{isRoom},</if>
- <if test="firstLetter != null">#{firstLetter},</if>
- <if test="lastMsgId != null">#{lastMsgId},</if>
- <if test="lastMsgType != null">#{lastMsgType},</if>
- <if test="lastSendTime != null">#{lastSendTime},</if>
- <if test="lastContent != null">#{lastContent},</if>
- </trim>
- </insert>
- <update id="updateQwSession" parameterType="QwSession">
- update qw_session
- <trim prefix="SET" suffixOverrides=",">
- <if test="chatId != null">chat_id = #{chatId},</if>
- <if test="qwExtId != null">qw_ext_id = #{qwExtId},</if>
- <if test="qwExtWxId != null">qw_ext_wx_id = #{qwExtWxId},</if>
- <if test="corpId != null">corp_id = #{corpId},</if>
- <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- <if test="updateTime != null">update_time = #{updateTime},</if>
- <if test="status != null">status = #{status},</if>
- <if test="companyId != null">company_id = #{companyId},</if>
- <if test="userType != null">user_type = #{userType},</if>
- <if test="nickName != null">nick_name = #{nickName},</if>
- <if test="avatar != null">avatar = #{avatar},</if>
- <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
- <if test="isRoom != null">is_room = #{isRoom},</if>
- <if test="firstLetter != null">first_letter = #{firstLetter},</if>
- <if test="lastMsgId != null">last_msg_id = #{lastMsgId},</if>
- <if test="lastMsgType != null">last_msg_type = #{lastMsgType},</if>
- <if test="lastSendTime != null">last_send_time = #{lastSendTime},</if>
- <if test="lastContent != null">last_content = #{lastContent},</if>
- </trim>
- where session_id = #{sessionId}
- </update>
- <delete id="deleteQwSessionBySessionId" parameterType="Long">
- delete from qw_session where session_id = #{sessionId}
- </delete>
- <delete id="deleteQwSessionBySessionIds" parameterType="String">
- delete from qw_session where session_id in
- <foreach item="sessionId" collection="array" open="(" separator="," close=")">
- #{sessionId}
- </foreach>
- </delete>
- <select id="selectQwSessionByGroupChatId" resultType="com.fs.qw.domain.QwSession">
- select
- qs.*
- from qw_session qs
- inner join qw_group_chat qgc on qs.chat_id = qgc.chat_id
- where qgc.chat_id = #{groupChatId}
- </select>
- <select id="selectQwSessionByContactId" resultType="com.fs.qw.domain.QwSession">
- select
- qs.*
- from qw_session qs
- inner join qw_external_contact qec on qs.qw_ext_id = qec.id
- where qec.id = #{contactId}
- </select>
- </mapper>
|