QwConversationParticipantMapper.xml 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.fs.qw.mapper.QwConversationParticipantMapper">
  4. <resultMap id="BaseResultMap" type="com.fs.qw.domain.QwConversationParticipant">
  5. <id column="id" property="id"/>
  6. <result column="corp_id" property="corpId"/>
  7. <result column="msgid" property="msgid"/>
  8. <result column="participant_type" property="participantType"/>
  9. <result column="user_type" property="userType"/>
  10. <result column="user_id" property="userId"/>
  11. </resultMap>
  12. <sql id="Base_Column_List">
  13. id, corp_id, msgid, participant_type, user_type, user_id
  14. </sql>
  15. <!-- 插入参与者记录 -->
  16. <insert id="insert" useGeneratedKeys="true" keyProperty="id">
  17. INSERT INTO qw_conversation_participant
  18. <trim prefix="(" suffix=")" suffixOverrides=",">
  19. <if test="corpId != null">corp_id,</if>
  20. <if test="msgid != null">msgid,</if>
  21. <if test="participantType != null">participant_type,</if>
  22. <if test="userType != null">user_type,</if>
  23. <if test="userId != null">user_id,</if>
  24. </trim>
  25. <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
  26. <if test="corpId != null">#{corpId},</if>
  27. <if test="msgid != null">#{msgid},</if>
  28. <if test="participantType != null">#{participantType},</if>
  29. <if test="userType != null">#{userType},</if>
  30. <if test="userId != null">#{userId},</if>
  31. </trim>
  32. </insert>
  33. <!-- 根据消息ID删除所有参与者 -->
  34. <delete id="deleteByMsgid">
  35. DELETE FROM qw_conversation_participant WHERE corp_id = #{corpId} AND msgid = #{msgid}
  36. </delete>
  37. <!-- 根据消息ID和参与者类型删除 -->
  38. <delete id="deleteByMsgidAndParticipantType">
  39. DELETE FROM qw_conversation_participant
  40. WHERE corp_id = #{corpId} AND msgid = #{msgid} AND participant_type = #{participantType}
  41. </delete>
  42. <!-- 根据消息ID查询参与者列表 -->
  43. <select id="selectByMsgid" resultMap="BaseResultMap">
  44. SELECT <include refid="Base_Column_List"/>
  45. FROM qw_conversation_participant
  46. WHERE corp_id = #{corpId} AND msgid = #{msgid}
  47. </select>
  48. <!-- 查询用户参与的所有消息ID(用于快速过滤) -->
  49. <select id="selectByUser" resultMap="BaseResultMap">
  50. SELECT <include refid="Base_Column_List"/>
  51. FROM qw_conversation_participant
  52. WHERE corp_id = #{corpId} AND user_type = #{userType} AND user_id = #{userId}
  53. </select>
  54. <select id="selectByMsgidAndType" resultMap="BaseResultMap">
  55. SELECT <include refid="Base_Column_List"/>
  56. FROM qw_conversation_participant
  57. WHERE corp_id = #{corpId} AND msgid = #{msgid} AND participant_type = #{participantType}
  58. </select>
  59. </mapper>