QwMsgMapper.xml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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.qw.mapper.QwMsgMapper">
  6. <resultMap type="QwMsg" id="QwMsgResult">
  7. <result property="msgId" column="msg_id" />
  8. <result property="sessionId" column="session_id" />
  9. <result property="qwExtId" column="qw_ext_id" />
  10. <result property="qwUserId" column="qw_user_id" />
  11. <result property="content" column="content" />
  12. <result property="msgType" column="msg_type" />
  13. <result property="sendType" column="send_type" />
  14. <result property="companyId" column="company_id" />
  15. <result property="roleId" column="role_id" />
  16. <result property="companyUserId" column="company_user_id" />
  17. <result property="createTime" column="create_time" />
  18. <result property="msgJson" column="msg_json" />
  19. <result property="status" column="status" />
  20. <result property="nickName" column="nick_name" />
  21. <result property="avatar" column="avatar" />
  22. <result property="qwMsgId" column="qw_msg_id" />
  23. <result property="qwAppInfo" column="qw_app_info" />
  24. </resultMap>
  25. <sql id="selectQwMsgVo">
  26. select msg_id, session_id, qw_ext_id, qw_user_id, content, msg_type, send_type, company_id, role_id, company_user_id, create_time, msg_json, status, nick_name, avatar, qw_msg_id, qw_app_info from qw_msg
  27. </sql>
  28. <select id="selectQwMsgList" parameterType="QwMsg" resultMap="QwMsgResult">
  29. <include refid="selectQwMsgVo"/>
  30. <where>
  31. <if test="sessionId != null "> and session_id = #{sessionId}</if>
  32. <if test="qwExtId != null and qwExtId != ''"> and qw_ext_id = #{qwExtId}</if>
  33. <if test="qwUserId != null and qwUserId != ''"> and qw_user_id = #{qwUserId}</if>
  34. <if test="content != null and content != ''"> and content = #{content}</if>
  35. <if test="msgType != null "> and msg_type = #{msgType}</if>
  36. <if test="sendType != null "> and send_type = #{sendType}</if>
  37. <if test="companyId != null "> and company_id = #{companyId}</if>
  38. <if test="roleId != null "> and role_id = #{roleId}</if>
  39. <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
  40. <if test="msgJson != null and msgJson != ''"> and msg_json = #{msgJson}</if>
  41. <if test="status != null "> and status = #{status}</if>
  42. <if test="nickName != null and nickName != ''"> and nick_name like concat( #{nickName}, '%')</if>
  43. <if test="avatar != null and avatar != ''"> and avatar = #{avatar}</if>
  44. <if test="qwMsgId != null"> and qw_msg_id = #{qwMsgId}</if>
  45. <if test="qwAppInfo != null and qwAppInfo != ''"> and qw_app_info = #{qwAppInfo}</if>
  46. </where>
  47. </select>
  48. <select id="selectQwMsgByMsgId" parameterType="Long" resultMap="QwMsgResult">
  49. <include refid="selectQwMsgVo"/>
  50. where msg_id = #{msgId}
  51. </select>
  52. <insert id="insertQwMsg" parameterType="QwMsg" useGeneratedKeys="true" keyProperty="msgId">
  53. insert into qw_msg
  54. <trim prefix="(" suffix=")" suffixOverrides=",">
  55. <if test="sessionId != null">session_id,</if>
  56. <if test="qwExtId != null">qw_ext_id,</if>
  57. <if test="qwUserId != null">qw_user_id,</if>
  58. <if test="content != null">content,</if>
  59. <if test="msgType != null">msg_type,</if>
  60. <if test="sendType != null">send_type,</if>
  61. <if test="companyId != null">company_id,</if>
  62. <if test="roleId != null">role_id,</if>
  63. <if test="companyUserId != null">company_user_id,</if>
  64. <if test="createTime != null">create_time,</if>
  65. <if test="msgJson != null">msg_json,</if>
  66. <if test="status != null">status,</if>
  67. <if test="nickName != null">nick_name,</if>
  68. <if test="avatar != null">avatar,</if>
  69. <if test="qwMsgId != null">qw_msg_id,</if>
  70. <if test="qwAppInfo != null">qw_app_info,</if>
  71. </trim>
  72. <trim prefix="values (" suffix=")" suffixOverrides=",">
  73. <if test="sessionId != null">#{sessionId},</if>
  74. <if test="qwExtId != null">#{qwExtId},</if>
  75. <if test="qwUserId != null">#{qwUserId},</if>
  76. <if test="content != null">#{content},</if>
  77. <if test="msgType != null">#{msgType},</if>
  78. <if test="sendType != null">#{sendType},</if>
  79. <if test="companyId != null">#{companyId},</if>
  80. <if test="roleId != null">#{roleId},</if>
  81. <if test="companyUserId != null">#{companyUserId},</if>
  82. <if test="createTime != null">#{createTime},</if>
  83. <if test="msgJson != null">#{msgJson},</if>
  84. <if test="status != null">#{status},</if>
  85. <if test="nickName != null">#{nickName},</if>
  86. <if test="avatar != null">#{avatar},</if>
  87. <if test="qwMsgId != null">#{qwMsgId},</if>
  88. <if test="qwAppInfo != null">#{qwAppInfo},</if>
  89. </trim>
  90. </insert>
  91. <update id="updateQwMsg" parameterType="QwMsg">
  92. update qw_msg
  93. <trim prefix="SET" suffixOverrides=",">
  94. <if test="sessionId != null">session_id = #{sessionId},</if>
  95. <if test="qwExtId != null">qw_ext_id = #{qwExtId},</if>
  96. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  97. <if test="content != null">content = #{content},</if>
  98. <if test="msgType != null">msg_type = #{msgType},</if>
  99. <if test="sendType != null">send_type = #{sendType},</if>
  100. <if test="companyId != null">company_id = #{companyId},</if>
  101. <if test="roleId != null">role_id = #{roleId},</if>
  102. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  103. <if test="createTime != null">create_time = #{createTime},</if>
  104. <if test="msgJson != null">msg_json = #{msgJson},</if>
  105. <if test="status != null">status = #{status},</if>
  106. <if test="nickName != null">nick_name = #{nickName},</if>
  107. <if test="avatar != null">avatar = #{avatar},</if>
  108. <if test="qwMsgId != null">qw_msg_id = #{qwMsgId},</if>
  109. <if test="qwAppInfo != null">qw_app_info = #{qwAppInfo},</if>
  110. </trim>
  111. where msg_id = #{msgId}
  112. </update>
  113. <update id="updateQwMsgByMsgIdAndSessionId">
  114. update qw_msg
  115. <trim prefix="SET" suffixOverrides=",">
  116. <if test="qwExtId != null">qw_ext_id = #{qwExtId},</if>
  117. <if test="qwUserId != null">qw_user_id = #{qwUserId},</if>
  118. <if test="content != null">content = #{content},</if>
  119. <if test="msgType != null">msg_type = #{msgType},</if>
  120. <if test="sendType != null">send_type = #{sendType},</if>
  121. <if test="companyId != null">company_id = #{companyId},</if>
  122. <if test="roleId != null">role_id = #{roleId},</if>
  123. <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
  124. <if test="createTime != null">create_time = #{createTime},</if>
  125. <if test="msgJson != null">msg_json = #{msgJson},</if>
  126. <if test="status != null">status = #{status},</if>
  127. <if test="nickName != null">nick_name = #{nickName},</if>
  128. <if test="avatar != null">avatar = #{avatar},</if>
  129. <if test="qwMsgId != null">qw_msg_id = #{qwMsgId},</if>
  130. <if test="qwAppInfo != null">qw_app_info = #{qwAppInfo},</if>
  131. </trim>
  132. where msg_id = #{msgId} and session_id = #{sessionId}
  133. </update>
  134. <delete id="deleteQwMsgByMsgId" parameterType="Long">
  135. delete from qw_msg where msg_id = #{msgId}
  136. </delete>
  137. <delete id="deleteQwMsgByMsgIds" parameterType="String">
  138. delete from qw_msg where msg_id in
  139. <foreach item="msgId" collection="array" open="(" separator="," close=")">
  140. #{msgId}
  141. </foreach>
  142. </delete>
  143. </mapper>