LiveMsgMapper.xml 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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.live.mapper.LiveMsgMapper">
  6. <resultMap type="LiveMsg" id="LiveMsgResult">
  7. <result property="msgId" column="msg_id" />
  8. <result property="liveId" column="live_id" />
  9. <result property="userId" column="user_id" />
  10. <result property="nickName" column="nick_name" />
  11. <result property="msg" column="msg" />
  12. <result property="createTime" column="create_time" />
  13. <result property="createBy" column="create_by" />
  14. <result property="updateBy" column="update_by" />
  15. <result property="updateTime" column="update_time" />
  16. <result property="remark" column="remark" />
  17. </resultMap>
  18. <sql id="selectLiveMsgVo">
  19. select msg_id, live_id,user_id, nick_name, avatar, msg, create_time, create_by, update_by, update_time, remark from live_msg
  20. </sql>
  21. <select id="selectLiveMsgList" parameterType="LiveMsg" resultMap="LiveMsgResult">
  22. <include refid="selectLiveMsgVo"/>
  23. <where>
  24. <if test="liveId != null "> and live_id = #{liveId}</if>
  25. <if test="userId != null "> and user_id = #{userId}</if>
  26. <if test="msg != null and msg != ''"> and msg = #{msg}</if>
  27. </where>
  28. order by create_time desc
  29. </select>
  30. <select id="selectLiveMsgSingleList" parameterType="LiveMsg" resultMap="LiveMsgResult">
  31. select lm.msg_id, lm.live_id,lm.user_id, lm.nick_name, lm.avatar, lm.msg, lm.create_time, lm.create_by, lm.update_by, lm.update_time, lm.remark,lwu.single_visible from live_msg lm
  32. left join live_watch_user lwu on lwu.user_id = lm.user_id
  33. <where>
  34. <if test="liveId != null "> and lm.live_id = #{liveId}</if>
  35. <if test="userId != null "> and lm.user_id = #{userId}</if>
  36. <if test="msg != null and msg != ''"> and lm.msg = #{msg}</if>
  37. </where>
  38. order by create_time desc
  39. </select>
  40. <select id="selectLiveMsgByMsgId" parameterType="Long" resultMap="LiveMsgResult">
  41. <include refid="selectLiveMsgVo"/>
  42. where msg_id = #{msgId}
  43. order by create_time desc
  44. </select>
  45. <select id="selectLiveMsgByMsgIdAndCompanyIdAndCompanyUserId" resultMap="LiveMsgResult">
  46. <include refid="selectLiveMsgVo"/>
  47. where msg_id = #{msgId} and company_id = #{companyId} and company_user_id = #{companyUserId}
  48. order by create_time desc
  49. </select>
  50. <insert id="insertLiveMsg" parameterType="LiveMsg" useGeneratedKeys="true" keyProperty="msgId">
  51. insert into live_msg
  52. <trim prefix="(" suffix=")" suffixOverrides=",">
  53. <if test="liveId != null">live_id,</if>
  54. <if test="userId != null">user_id,</if>
  55. <if test="nickName != null">nick_name,</if>
  56. <if test="msg != null">msg,</if>
  57. <if test="createTime != null">create_time,</if>
  58. <if test="createBy != null">create_by,</if>
  59. <if test="updateBy != null">update_by,</if>
  60. <if test="updateTime != null">update_time,</if>
  61. <if test="remark != null">remark,</if>
  62. <if test="liveFlag != null">live_flag,</if>
  63. <if test="replayFlag != null">replay_flag,</if>
  64. </trim>
  65. <trim prefix="values (" suffix=")" suffixOverrides=",">
  66. <if test="liveId != null">#{liveId},</if>
  67. <if test="userId != null">#{userId},</if>
  68. <if test="nickName != null">#{nickName},</if>
  69. <if test="msg != null">#{msg},</if>
  70. <if test="createTime != null">#{createTime},</if>
  71. <if test="createBy != null">#{createBy},</if>
  72. <if test="updateBy != null">#{updateBy},</if>
  73. <if test="updateTime != null">#{updateTime},</if>
  74. <if test="remark != null">#{remark},</if>
  75. <if test="liveFlag != null">#{liveFlag},</if>
  76. <if test="replayFlag != null">#{replayFlag},</if>
  77. </trim>
  78. </insert>
  79. <update id="updateLiveMsg" parameterType="LiveMsg">
  80. update live_msg
  81. <trim prefix="SET" suffixOverrides=",">
  82. <if test="liveId != null">live_id = #{liveId},</if>
  83. <if test="userId != null">user_id = #{userId},</if>
  84. <if test="nickName != null">nick_name = #{nickName},</if>
  85. <if test="msg != null">msg = #{msg},</if>
  86. <if test="createTime != null">create_time = #{createTime},</if>
  87. <if test="createBy != null">create_by = #{createBy},</if>
  88. <if test="updateBy != null">update_by = #{updateBy},</if>
  89. <if test="updateTime != null">update_time = #{updateTime},</if>
  90. <if test="remark != null">remark = #{remark},</if>
  91. </trim>
  92. where msg_id = #{msgId}
  93. </update>
  94. <delete id="deleteLiveMsgByMsgId" parameterType="Long">
  95. delete from live_msg where msg_id = #{msgId}
  96. </delete>
  97. <delete id="deleteLiveMsgByMsgIds" parameterType="String">
  98. delete from live_msg where msg_id in
  99. <foreach item="msgId" collection="array" open="(" separator="," close=")">
  100. #{msgId}
  101. </foreach>
  102. </delete>
  103. </mapper>