MomentsCommentMapper.xml 8.8 KB

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