| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 |
- <?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.QwMsgAuditMessageMapper">
- <!-- 分表:上下文需含 corpId -->
- <sql id="physicalTableByCorpId">qw_msg_audit_message_${@com.fs.qw.shardingConfig.QwMsgAuditMessageSharding@shardIndex(corpId)}</sql>
- <resultMap type="QwMsgAuditMessage" id="QwMsgAuditMessageResult">
- <result property="id" column="id" />
- <result property="corpId" column="corp_id" />
- <result property="seq" column="seq" />
- <result property="msgId" column="msg_id" />
- <result property="msgTime" column="msg_time" />
- <result property="msgType" column="msg_type" />
- <result property="fromUser" column="from_user" />
- <result property="toList" column="to_list" />
- <result property="roomId" column="room_id" />
- <result property="conversationKey" column="conversation_key" />
- <result property="fromUserRole" column="from_user_role" />
- <result property="textContent" column="text_content" />
- <result property="mediaSdkfileid" column="media_sdkfileid" />
- <result property="mediaMd5sum" column="media_md5sum" />
- <result property="mediaSize" column="media_size" />
- <result property="mediaPlayLength" column="media_play_length" />
- <result property="mediaWidth" column="media_width" />
- <result property="mediaHeight" column="media_height" />
- <result property="mediaFileName" column="media_file_name" />
- <result property="mediaFileExt" column="media_file_ext" />
- <result property="mediaOssUrl" column="media_oss_url" />
- <result property="rawId" column="raw_id" />
- <result property="createTime" column="create_time" />
- </resultMap>
- <sql id="selectQwMsgAuditMessageVo">
- select id, corp_id, seq, msg_id, msg_time, msg_type, from_user, to_list, room_id, conversation_key, from_user_role, text_content, media_sdkfileid, media_md5sum, media_size, media_play_length, media_width, media_height, media_file_name, media_file_ext, media_oss_url, raw_id, create_time from
- </sql>
- <select id="selectQwMsgAuditMessageList" parameterType="QwMsgAuditMessage" resultMap="QwMsgAuditMessageResult">
- <include refid="selectQwMsgAuditMessageVo"/>
- <include refid="physicalTableByCorpId"/>
- <where>
- <if test="corpId != null and corpId != ''"> and corp_id = #{corpId}</if>
- <if test="seq != null "> and seq = #{seq}</if>
- <if test="msgId != null and msgId != ''"> and msg_id = #{msgId}</if>
- <if test="msgTime != null "> and msg_time = #{msgTime}</if>
- <if test="msgType != null and msgType != ''"> and msg_type = #{msgType}</if>
- <if test="fromUser != null and fromUser != ''"> and from_user = #{fromUser}</if>
- <if test="toList != null and toList != ''"> and to_list = #{toList}</if>
- <if test="roomId != null and roomId != ''"> and room_id = #{roomId}</if>
- <if test="conversationKey != null and conversationKey != ''"> and conversation_key = #{conversationKey}</if>
- <if test="fromUserRole != null "> and from_user_role = #{fromUserRole}</if>
- <if test="textContent != null and textContent != ''"> and text_content = #{textContent}</if>
- <if test="mediaSdkfileid != null and mediaSdkfileid != ''"> and media_sdkfileid = #{mediaSdkfileid}</if>
- <if test="mediaMd5sum != null and mediaMd5sum != ''"> and media_md5sum = #{mediaMd5sum}</if>
- <if test="mediaSize != null "> and media_size = #{mediaSize}</if>
- <if test="mediaPlayLength != null "> and media_play_length = #{mediaPlayLength}</if>
- <if test="mediaWidth != null "> and media_width = #{mediaWidth}</if>
- <if test="mediaHeight != null "> and media_height = #{mediaHeight}</if>
- <if test="mediaFileName != null and mediaFileName != ''"> and media_file_name like concat('%', #{mediaFileName}, '%')</if>
- <if test="mediaFileExt != null and mediaFileExt != ''"> and media_file_ext = #{mediaFileExt}</if>
- <if test="rawId != null "> and raw_id = #{rawId}</if>
- </where>
- order by msg_time desc
- </select>
- <select id="selectQwMsgAuditMessageById" resultMap="QwMsgAuditMessageResult">
- <include refid="selectQwMsgAuditMessageVo"/>
- qw_msg_audit_message_${shard}
- where id = #{id}
- </select>
- <insert id="insertQwMsgAuditMessage" parameterType="QwMsgAuditMessage" useGeneratedKeys="true" keyProperty="id">
- insert into
- <include refid="physicalTableByCorpId"/>
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="corpId != null and corpId != ''">corp_id,</if>
- <if test="seq != null">seq,</if>
- <if test="msgId != null">msg_id,</if>
- <if test="msgTime != null">msg_time,</if>
- <if test="msgType != null">msg_type,</if>
- <if test="fromUser != null">from_user,</if>
- <if test="toList != null">to_list,</if>
- <if test="roomId != null">room_id,</if>
- <if test="conversationKey != null">conversation_key,</if>
- <if test="fromUserRole != null">from_user_role,</if>
- <if test="textContent != null">text_content,</if>
- <if test="mediaSdkfileid != null">media_sdkfileid,</if>
- <if test="mediaMd5sum != null">media_md5sum,</if>
- <if test="mediaSize != null">media_size,</if>
- <if test="mediaPlayLength != null">media_play_length,</if>
- <if test="mediaWidth != null">media_width,</if>
- <if test="mediaHeight != null">media_height,</if>
- <if test="mediaFileName != null">media_file_name,</if>
- <if test="mediaFileExt != null">media_file_ext,</if>
- <if test="mediaOssUrl != null">media_oss_url,</if>
- <if test="rawId != null">raw_id,</if>
- <if test="createTime != null">create_time,</if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="corpId != null and corpId != ''">#{corpId},</if>
- <if test="seq != null">#{seq},</if>
- <if test="msgId != null">#{msgId},</if>
- <if test="msgTime != null">#{msgTime},</if>
- <if test="msgType != null">#{msgType},</if>
- <if test="fromUser != null">#{fromUser},</if>
- <if test="toList != null">#{toList},</if>
- <if test="roomId != null">#{roomId},</if>
- <if test="conversationKey != null">#{conversationKey},</if>
- <if test="fromUserRole != null">#{fromUserRole},</if>
- <if test="textContent != null">#{textContent},</if>
- <if test="mediaSdkfileid != null">#{mediaSdkfileid},</if>
- <if test="mediaMd5sum != null">#{mediaMd5sum},</if>
- <if test="mediaSize != null">#{mediaSize},</if>
- <if test="mediaPlayLength != null">#{mediaPlayLength},</if>
- <if test="mediaWidth != null">#{mediaWidth},</if>
- <if test="mediaHeight != null">#{mediaHeight},</if>
- <if test="mediaFileName != null">#{mediaFileName},</if>
- <if test="mediaFileExt != null">#{mediaFileExt},</if>
- <if test="mediaOssUrl != null">#{mediaOssUrl},</if>
- <if test="rawId != null">#{rawId},</if>
- <if test="createTime != null">#{createTime},</if>
- </trim>
- </insert>
- <update id="updateQwMsgAuditMessage" parameterType="QwMsgAuditMessage">
- update
- <include refid="physicalTableByCorpId"/>
- <trim prefix="SET" suffixOverrides=",">
- <if test="corpId != null and corpId != ''">corp_id = #{corpId},</if>
- <if test="seq != null">seq = #{seq},</if>
- <if test="msgId != null">msg_id = #{msgId},</if>
- <if test="msgTime != null">msg_time = #{msgTime},</if>
- <if test="msgType != null">msg_type = #{msgType},</if>
- <if test="fromUser != null">from_user = #{fromUser},</if>
- <if test="toList != null">to_list = #{toList},</if>
- <if test="roomId != null">room_id = #{roomId},</if>
- <if test="conversationKey != null">conversation_key = #{conversationKey},</if>
- <if test="fromUserRole != null">from_user_role = #{fromUserRole},</if>
- <if test="textContent != null">text_content = #{textContent},</if>
- <if test="mediaSdkfileid != null">media_sdkfileid = #{mediaSdkfileid},</if>
- <if test="mediaMd5sum != null">media_md5sum = #{mediaMd5sum},</if>
- <if test="mediaSize != null">media_size = #{mediaSize},</if>
- <if test="mediaPlayLength != null">media_play_length = #{mediaPlayLength},</if>
- <if test="mediaWidth != null">media_width = #{mediaWidth},</if>
- <if test="mediaHeight != null">media_height = #{mediaHeight},</if>
- <if test="mediaFileName != null">media_file_name = #{mediaFileName},</if>
- <if test="mediaFileExt != null">media_file_ext = #{mediaFileExt},</if>
- <if test="mediaOssUrl != null">media_oss_url = #{mediaOssUrl},</if>
- <if test="rawId != null">raw_id = #{rawId},</if>
- <if test="createTime != null">create_time = #{createTime},</if>
- </trim>
- where id = #{id}
- </update>
- <delete id="deleteQwMsgAuditMessageById">
- delete from qw_msg_audit_message_${shard} where id = #{id}
- </delete>
- <delete id="deleteQwMsgAuditMessageByIdsInShard">
- delete from qw_msg_audit_message_${shard} where id in
- <foreach item="id" collection="ids" open="(" separator="," close=")">
- #{id}
- </foreach>
- </delete>
- <select id="selectByCorpIdAndSeq" resultMap="QwMsgAuditMessageResult">
- <include refid="selectQwMsgAuditMessageVo"/>
- <include refid="physicalTableByCorpId"/>
- where corp_id = #{corpId} and seq = #{seq} limit 1
- </select>
- <select id="selectMediaPendingOssUpload" resultMap="QwMsgAuditMessageResult">
- <include refid="selectQwMsgAuditMessageVo"/>
- <include refid="physicalTableByCorpId"/>
- where corp_id = #{corpId} and msg_type = #{msgType} and media_sdkfileid is not null and media_oss_url is null limit #{limit}
- </select>
- <!-- 单聊会话列表 -->
- <select id="selectSingleConversationList" resultType="com.fs.qw.dto.QwMsgAuditConversationDTO">
- SELECT m.conversation_key AS conversationKey,
- MAX(m.msg_time) AS lastMsgTime
- FROM
- qw_msg_audit_message_${@com.fs.qw.shardingConfig.QwMsgAuditMessageSharding@shardIndex(corpId)} m
- WHERE m.corp_id = #{corpId}
- AND (m.room_id IS NULL OR m.room_id = '')
- AND m.conversation_key IS NOT NULL
- AND m.conversation_key <> ''
- AND m.conversation_key LIKE CONCAT(#{corpId}, ':p2p:%')
- AND (
- m.from_user = #{qwUserId}
- OR (
- m.to_list IS NOT NULL AND m.to_list <> '' AND m.to_list <> '[]'
- AND JSON_CONTAINS(CAST(m.to_list AS JSON), JSON_QUOTE(#{qwUserId}), '$')
- )
- )
- GROUP BY m.conversation_key
- ORDER BY lastMsgTime DESC
- </select>
- </mapper>
|