ChatMsgMapper.xml 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.fs.chat.mapper.ChatMsgMapper">
  6. <resultMap type="ChatMsg" id="ChatMsgResult">
  7. <result property="msgId" column="msg_id" />
  8. <result property="sessionId" column="session_id" />
  9. <result property="extId" column="ext_id" />
  10. <result property="content" column="content" />
  11. <result property="msgType" column="msg_type" />
  12. <result property="sendType" column="send_type" />
  13. <result property="companyId" column="company_id" />
  14. <result property="roleId" column="role_id" />
  15. <result property="companyUserId" column="company_user_id" />
  16. <result property="createTime" column="create_time" />
  17. <result property="msgJson" column="msg_json" />
  18. <result property="userId" column="user_id" />
  19. <result property="status" column="status" />
  20. <result property="nickName" column="nick_name" />
  21. <result property="avatar" column="avatar" />
  22. <result property="userType" column="user_type" />
  23. </resultMap>
  24. <sql id="selectChatMsgVo">
  25. select msg_id,session_id,nick_name, avatar,ext_id, content,status,msg_type, send_type, company_id, role_id, company_user_id, create_time, msg_json,user_id,user_type from chat_msg
  26. </sql>
  27. <select id="selectChatMsgList" parameterType="ChatMsg" resultMap="ChatMsgResult">
  28. <include refid="selectChatMsgVo"/>
  29. <where>
  30. <if test="extId != null and extId != ''"> and ext_id = #{extId}</if>
  31. <if test="sessionId != null "> and session_id = #{sessionId}</if>
  32. <if test="content != null and content != ''"> and content = #{content}</if>
  33. <if test="msgType != null "> and msg_type = #{msgType}</if>
  34. <if test="status != null "> and status = #{status}</if>
  35. <if test="sendType != null "> and send_type = #{sendType}</if>
  36. <if test="companyId != null "> and company_id = #{companyId}</if>
  37. <if test="roleId != null "> and role_id = #{roleId}</if>
  38. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  39. <if test="msgJson != null and msgJson != ''"> and msg_json = #{msgJson}</if>
  40. <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
  41. AND date_format(create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
  42. </if>
  43. <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
  44. AND date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
  45. </if>
  46. </where>
  47. </select>
  48. <select id="selectChatMsgByMsgId" parameterType="Long" resultMap="ChatMsgResult">
  49. <include refid="selectChatMsgVo"/>
  50. where msg_id = #{msgId}
  51. </select>
  52. <insert id="insertChatMsg" parameterType="ChatMsg" useGeneratedKeys="true" keyProperty="msgId">
  53. insert into chat_msg
  54. <trim prefix="(" suffix=")" suffixOverrides=",">
  55. <if test="extId != null">ext_id,</if>
  56. <if test="sessionId != null">session_id,</if>
  57. <if test="content != null">content,</if>
  58. <if test="msgType != null">msg_type,</if>
  59. <if test="sendType != null">send_type,</if>
  60. <if test="companyId != null">company_id,</if>
  61. <if test="roleId != null">role_id,</if>
  62. <if test="companyUserId != null">company_user_id,</if>
  63. <if test="createTime != null">create_time,</if>
  64. <if test="msgJson != null">msg_json,</if>
  65. <if test="userId != null">user_id,</if>
  66. <if test="status != null">status,</if>
  67. <if test="avatar != null">avatar,</if>
  68. <if test="nickName != null">nick_name,</if>
  69. <if test="userType != null">user_type,</if>
  70. </trim>
  71. <trim prefix="values (" suffix=")" suffixOverrides=",">
  72. <if test="extId != null">#{extId},</if>
  73. <if test="sessionId != null">#{sessionId},</if>
  74. <if test="content != null">#{content},</if>
  75. <if test="msgType != null">#{msgType},</if>
  76. <if test="sendType != null">#{sendType},</if>
  77. <if test="companyId != null">#{companyId},</if>
  78. <if test="roleId != null">#{roleId},</if>
  79. <if test="companyUserId != null">#{companyUserId},</if>
  80. <if test="createTime != null">#{createTime},</if>
  81. <if test="msgJson != null">#{msgJson},</if>
  82. <if test="userId != null">#{userId},</if>
  83. <if test="status != null">#{status},</if>
  84. <if test="avatar != null">#{avatar},</if>
  85. <if test="nickName != null">#{nickName},</if>
  86. <if test="userType != null">#{userType},</if>
  87. </trim>
  88. </insert>
  89. <update id="updateChatMsg" parameterType="ChatMsg">
  90. update chat_msg
  91. <trim prefix="SET" suffixOverrides=",">
  92. <if test="extId != null">ext_id = #{extId},</if>
  93. <if test="sessionId != null">session_id = #{sessionId},</if>
  94. <if test="content != null">content = #{content},</if>
  95. <if test="msgType != null">msg_type = #{msgType},</if>
  96. <if test="sendType != null">send_type = #{sendType},</if>
  97. <if test="companyId != null">company_id = #{companyId},</if>
  98. <if test="roleId != null">role_id = #{roleId},</if>
  99. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  100. <if test="createTime != null">create_time = #{createTime},</if>
  101. <if test="msgJson != null">msg_json = #{msgJson},</if>
  102. <if test="userId != null">user_id = #{userId},</if>
  103. <if test="status != null">status = #{status},</if>
  104. <if test="avatar != null">avatar = #{avatar},</if>
  105. <if test="nickName != null">nick_name = #{nickName},</if>
  106. <if test="userType != null">user_type = #{userType},</if>
  107. </trim>
  108. where msg_id = #{msgId}
  109. </update>
  110. <delete id="deleteChatMsgByMsgId" parameterType="Long">
  111. delete from chat_msg where msg_id = #{msgId}
  112. </delete>
  113. <delete id="deleteChatMsgByMsgIds" parameterType="String">
  114. delete from chat_msg where msg_id in
  115. <foreach item="msgId" collection="array" open="(" separator="," close=")">
  116. #{msgId}
  117. </foreach>
  118. </delete>
  119. </mapper>