MomentsMapper.xml 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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.juxiao.xchat.module.xbd.mapper.circle.MomentsMapper">
  4. <resultMap id="BaseResultMap" type="com.juxiao.xchat.module.xbd.domain.circle.Moments" >
  5. <id column="id" property="id" jdbcType="INTEGER" />
  6. <result column="topic_id" property="topicId" jdbcType="INTEGER" />
  7. <result column="uid" property="uid" jdbcType="BIGINT" />
  8. <result column="tape" property="tape" jdbcType="VARCHAR" />
  9. <result column="type" property="type" jdbcType="INTEGER" />
  10. <result column="location" property="location" jdbcType="VARCHAR" />
  11. <result column="privacy_type" property="privacyType" jdbcType="INTEGER" />
  12. <result column="likes" property="likes" jdbcType="INTEGER" />
  13. <result column="comments" property="comments" jdbcType="INTEGER" />
  14. <result column="admin_id" property="adminId" jdbcType="INTEGER" />
  15. <result column="state" property="state" jdbcType="INTEGER" />
  16. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  17. <result column="content" property="content" jdbcType="VARCHAR" />
  18. <result column="tape_duration" property="tapeDuration" jdbcType="INTEGER" />
  19. </resultMap>
  20. <sql id="Base_Column_List" >
  21. id, topic_id, uid, tape, type, location, privacy_type, likes, comments, admin_id,
  22. state, create_time,content,tape_duration
  23. </sql>
  24. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  25. select
  26. <include refid="Base_Column_List" />
  27. from moments
  28. where id = #{id,jdbcType=INTEGER}
  29. </select>
  30. <insert id="insert" parameterType="com.juxiao.xchat.module.xbd.domain.circle.Moments" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
  31. <selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER" >
  32. SELECT LAST_INSERT_ID()
  33. </selectKey>
  34. insert into moments (topic_id, uid, tape,
  35. type, location, privacy_type,
  36. likes, comments, admin_id,
  37. state, create_time, content
  38. )
  39. values (#{topicId,jdbcType=INTEGER}, #{uid,jdbcType=BIGINT}, #{tape,jdbcType=VARCHAR},
  40. #{type,jdbcType=INTEGER}, #{location,jdbcType=VARCHAR}, #{privacyType,jdbcType=INTEGER},
  41. #{likes,jdbcType=INTEGER}, #{comments,jdbcType=INTEGER}, #{adminId,jdbcType=INTEGER},
  42. #{state,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{content,jdbcType=LONGVARCHAR}
  43. )
  44. </insert>
  45. <insert id="insertSelective" parameterType="com.juxiao.xchat.module.xbd.domain.circle.Moments" useGeneratedKeys="true" keyProperty="id" keyColumn="id">
  46. <selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER" >
  47. SELECT LAST_INSERT_ID()
  48. </selectKey>
  49. insert into moments
  50. <trim prefix="(" suffix=")" suffixOverrides="," >
  51. <if test="topicId != null" >
  52. topic_id,
  53. </if>
  54. <if test="uid != null" >
  55. uid,
  56. </if>
  57. <if test="tape != null" >
  58. tape,
  59. </if>
  60. <if test="type != null" >
  61. type,
  62. </if>
  63. <if test="location != null" >
  64. location,
  65. </if>
  66. <if test="privacyType != null" >
  67. privacy_type,
  68. </if>
  69. <if test="likes != null" >
  70. likes,
  71. </if>
  72. <if test="comments != null" >
  73. comments,
  74. </if>
  75. <if test="adminId != null" >
  76. admin_id,
  77. </if>
  78. <if test="state != null" >
  79. state,
  80. </if>
  81. <if test="createTime != null" >
  82. create_time,
  83. </if>
  84. <if test="content != null" >
  85. content,
  86. </if>
  87. </trim>
  88. <trim prefix="values (" suffix=")" suffixOverrides="," >
  89. <if test="topicId != null" >
  90. #{topicId,jdbcType=INTEGER},
  91. </if>
  92. <if test="uid != null" >
  93. #{uid,jdbcType=BIGINT},
  94. </if>
  95. <if test="tape != null" >
  96. #{tape,jdbcType=VARCHAR},
  97. </if>
  98. <if test="type != null" >
  99. #{type,jdbcType=INTEGER},
  100. </if>
  101. <if test="location != null" >
  102. #{location,jdbcType=VARCHAR},
  103. </if>
  104. <if test="privacyType != null" >
  105. #{privacyType,jdbcType=INTEGER},
  106. </if>
  107. <if test="likes != null" >
  108. #{likes,jdbcType=INTEGER},
  109. </if>
  110. <if test="comments != null" >
  111. #{comments,jdbcType=INTEGER},
  112. </if>
  113. <if test="adminId != null" >
  114. #{adminId,jdbcType=INTEGER},
  115. </if>
  116. <if test="state != null" >
  117. #{state,jdbcType=INTEGER},
  118. </if>
  119. <if test="createTime != null" >
  120. #{createTime,jdbcType=TIMESTAMP},
  121. </if>
  122. <if test="content != null" >
  123. #{content,jdbcType=LONGVARCHAR},
  124. </if>
  125. </trim>
  126. </insert>
  127. <update id="updateByPrimaryKeySelective" parameterType="com.juxiao.xchat.module.xbd.domain.circle.Moments" >
  128. update moments
  129. <set >
  130. <if test="topicId != null" >
  131. topic_id = #{topicId,jdbcType=INTEGER},
  132. </if>
  133. <if test="uid != null" >
  134. uid = #{uid,jdbcType=BIGINT},
  135. </if>
  136. <if test="tape != null" >
  137. tape = #{tape,jdbcType=VARCHAR},
  138. </if>
  139. <if test="type != null" >
  140. type = #{type,jdbcType=INTEGER},
  141. </if>
  142. <if test="location != null" >
  143. location = #{location,jdbcType=VARCHAR},
  144. </if>
  145. <if test="privacyType != null" >
  146. privacy_type = #{privacyType,jdbcType=INTEGER},
  147. </if>
  148. <if test="likes != null" >
  149. likes = #{likes,jdbcType=INTEGER},
  150. </if>
  151. <if test="comments != null" >
  152. comments = #{comments,jdbcType=INTEGER},
  153. </if>
  154. <if test="adminId != null" >
  155. admin_id = #{adminId,jdbcType=INTEGER},
  156. </if>
  157. <if test="state != null" >
  158. state = #{state,jdbcType=INTEGER},
  159. </if>
  160. <if test="createTime != null" >
  161. create_time = #{createTime,jdbcType=TIMESTAMP},
  162. </if>
  163. <if test="content != null" >
  164. content = #{content,jdbcType=LONGVARCHAR},
  165. </if>
  166. <if test="updateTime != null" >
  167. update_time = #{updateTime,jdbcType=TIMESTAMP},
  168. </if>
  169. </set>
  170. where id = #{id,jdbcType=INTEGER}
  171. </update>
  172. <update id="updateByPrimaryKey" parameterType="com.juxiao.xchat.module.xbd.domain.circle.Moments" >
  173. update moments
  174. set topic_id = #{topicId,jdbcType=INTEGER},
  175. uid = #{uid,jdbcType=BIGINT},
  176. tape = #{tape,jdbcType=VARCHAR},
  177. type = #{type,jdbcType=INTEGER},
  178. location = #{location,jdbcType=VARCHAR},
  179. privacy_type = #{privacyType,jdbcType=INTEGER},
  180. likes = #{likes,jdbcType=INTEGER},
  181. comments = #{comments,jdbcType=INTEGER},
  182. admin_id = #{adminId,jdbcType=INTEGER},
  183. state = #{state,jdbcType=INTEGER},
  184. create_time = #{createTime,jdbcType=TIMESTAMP},
  185. content = #{content,jdbcType=LONGVARCHAR}
  186. where id = #{id,jdbcType=INTEGER}
  187. </update>
  188. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
  189. delete from moments
  190. where id = #{id,jdbcType=INTEGER}
  191. </delete>
  192. <select id="selectByMomentsByPage" resultType="com.juxiao.xchat.module.xbd.vo.MomentsVO">
  193. select m.id,u.erban_no as erBanNo,u.nick,m.uid,m.content,m.tape,t.id as topicId, t.title as topicTitle,m.state,su.user_name as adminName,m.admin_id as adminId,m.create_time as createTime,m.update_time as updateTime
  194. from moments m
  195. left join topic t on m.topic_id = t.id
  196. left join users u on u.uid = m.uid
  197. left join sys_user su on m.admin_id = su.user_id
  198. where 1 = 1
  199. <if test="keyWord != null and keyWord != ''">
  200. and u.erban_no = #{keyWord}
  201. </if>
  202. <if test="adminName != null and adminName != ''">
  203. and su.user_name = #{adminName}
  204. </if>
  205. <if test="state != null">
  206. and m.state = #{state}
  207. </if>
  208. <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
  209. and m.create_time between #{startTime} and #{endTime}
  210. </if>
  211. <if test="momentsId != null">
  212. and m.id = #{momentsId}
  213. </if>
  214. order by m.state asc, m.create_time desc
  215. </select>
  216. <select id="selectById" resultType="com.juxiao.xchat.module.xbd.vo.MomentsVO">
  217. SELECT m.id, m.topic_id as topicId, m.uid, m.tape, m.type, m.location, m.privacy_type, m.likes, m.comments, m.admin_id as adminId,
  218. m.state, m.create_time as createTime,m.content,t.title as topicTitle,u.erban_no as erBanNo
  219. from moments m
  220. left join users u on u.uid = m.uid
  221. left join topic t on m.topic_id = t.id
  222. where m.id = #{id}
  223. </select>
  224. <update id="updateByState" parameterType="com.juxiao.xchat.module.xbd.domain.circle.Moments" >
  225. update moments
  226. <set >
  227. <if test="adminId != null" >
  228. admin_id = #{adminId,jdbcType=INTEGER},
  229. </if>
  230. <if test="state != null" >
  231. state = #{state,jdbcType=INTEGER},
  232. </if>
  233. <if test="updateTime != null" >
  234. update_time = #{updateTime,jdbcType=TIMESTAMP},
  235. </if>
  236. </set>
  237. where id = #{id,jdbcType=INTEGER}
  238. </update>
  239. </mapper>