TopicMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  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.TopicMapper">
  4. <resultMap id="BaseResultMap" type="com.juxiao.xchat.module.xbd.domain.circle.Topic" >
  5. <id column="id" property="id" jdbcType="INTEGER" />
  6. <result column="title" property="title" jdbcType="VARCHAR" />
  7. <result column="pic" property="pic" jdbcType="VARCHAR" />
  8. <result column="sort" property="sort" jdbcType="INTEGER" />
  9. <result column="activation" property="activation" jdbcType="INTEGER" />
  10. <result column="pk" property="pk" jdbcType="INTEGER" />
  11. <result column="red_option" property="redOption" jdbcType="VARCHAR" />
  12. <result column="blue_option" property="blueOption" jdbcType="VARCHAR" />
  13. <result column="lead" property="lead" jdbcType="VARCHAR" />
  14. <result column="red_desc" property="redDesc" jdbcType="VARCHAR" />
  15. <result column="blue_desc" property="blueDesc" jdbcType="VARCHAR" />
  16. <result column="end_time" property="endTime" jdbcType="VARCHAR" />
  17. <result column="examine" property="examine" jdbcType="INTEGER" />
  18. <result column="examine_num" property="examineNum" jdbcType="INTEGER" />
  19. <result column="red_ticket" property="redTicket" jdbcType="INTEGER" />
  20. <result column="blue_ticket" property="blueTicket" jdbcType="INTEGER" />
  21. <result column="admin_id" property="adminId" jdbcType="INTEGER" />
  22. <result column="pk_vote_num" property="pkVoteNum" jdbcType="INTEGER"/>
  23. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  24. </resultMap>
  25. <sql id="Base_Column_List" >
  26. id, title, pic, sort, activation, pk, red_option, blue_option, end_time, examine,
  27. examine_num, red_ticket, blue_ticket, admin_id, create_time,lead, red_desc, blue_desc,pk_vote_num
  28. </sql>
  29. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
  30. select
  31. <include refid="Base_Column_List" />
  32. from topic
  33. where id = #{id,jdbcType=INTEGER}
  34. </select>
  35. <insert id="insert" parameterType="com.juxiao.xchat.module.xbd.domain.circle.Topic" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  36. <selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER" >
  37. SELECT LAST_INSERT_ID()
  38. </selectKey>
  39. insert into topic (title, pic, sort,
  40. activation, pk, red_option,
  41. blue_option, end_time, examine,
  42. examine_num, red_ticket, blue_ticket,
  43. admin_id, create_time, lead,
  44. red_desc, blue_desc,pk_vote_num)
  45. values (#{title,jdbcType=VARCHAR}, #{pic,jdbcType=VARCHAR}, #{sort,jdbcType=INTEGER},
  46. #{activation,jdbcType=INTEGER}, #{pk,jdbcType=INTEGER}, #{redOption,jdbcType=VARCHAR},
  47. #{blueOption,jdbcType=VARCHAR}, #{endTime,jdbcType=VARCHAR}, #{examine,jdbcType=INTEGER},
  48. #{examineNum,jdbcType=INTEGER}, #{redTicket,jdbcType=INTEGER}, #{blueTicket,jdbcType=INTEGER},
  49. #{adminId,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{lead,jdbcType=LONGVARCHAR},
  50. #{redDesc,jdbcType=LONGVARCHAR}, #{blueDesc,jdbcType=LONGVARCHAR},#{pkVoteNum,jdbcType=INTEGER})
  51. </insert>
  52. <insert id="insertSelective" parameterType="com.juxiao.xchat.module.xbd.domain.circle.Topic" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
  53. <selectKey resultType="java.lang.Integer" keyProperty="id" order="AFTER" >
  54. SELECT LAST_INSERT_ID()
  55. </selectKey>
  56. insert into topic
  57. <trim prefix="(" suffix=")" suffixOverrides="," >
  58. <if test="title != null and title != ''" >
  59. title,
  60. </if>
  61. <if test="pic != null and pic != ''" >
  62. pic,
  63. </if>
  64. <if test="sort != null" >
  65. sort,
  66. </if>
  67. <if test="activation != null" >
  68. activation,
  69. </if>
  70. <if test="pk != null" >
  71. pk,
  72. </if>
  73. <if test="redOption != null" >
  74. red_option,
  75. </if>
  76. <if test="blueOption != null" >
  77. blue_option,
  78. </if>
  79. <if test="endTime != null" >
  80. end_time,
  81. </if>
  82. <if test="examine != null" >
  83. examine,
  84. </if>
  85. <if test="examineNum != null" >
  86. examine_num,
  87. </if>
  88. <if test="redTicket != null" >
  89. red_ticket,
  90. </if>
  91. <if test="blueTicket != null" >
  92. blue_ticket,
  93. </if>
  94. <if test="adminId != null" >
  95. admin_id,
  96. </if>
  97. <if test="createTime != null" >
  98. create_time,
  99. </if>
  100. <if test="lead != null lead != ''" >
  101. lead,
  102. </if>
  103. <if test="redDesc != null and redDesc != ''" >
  104. red_desc,
  105. </if>
  106. <if test="blueDesc != null and blueDesc != ''" >
  107. blue_desc,
  108. </if>
  109. <if test="pkVoteNum != null">
  110. pk_vote_num,
  111. </if>
  112. </trim>
  113. <trim prefix="values (" suffix=")" suffixOverrides="," >
  114. <if test="title != null and title != ''" >
  115. #{title,jdbcType=VARCHAR},
  116. </if>
  117. <if test="pic != null" >
  118. #{pic,jdbcType=VARCHAR},
  119. </if>
  120. <if test="sort != null" >
  121. #{sort,jdbcType=INTEGER},
  122. </if>
  123. <if test="activation != null" >
  124. #{activation,jdbcType=INTEGER},
  125. </if>
  126. <if test="pk != null" >
  127. #{pk,jdbcType=INTEGER},
  128. </if>
  129. <if test="redOption != null" >
  130. #{redOption,jdbcType=VARCHAR},
  131. </if>
  132. <if test="blueOption != null" >
  133. #{blueOption,jdbcType=VARCHAR},
  134. </if>
  135. <if test="endTime != null" >
  136. #{endTime,jdbcType=VARCHAR},
  137. </if>
  138. <if test="examine != null" >
  139. #{examine,jdbcType=INTEGER},
  140. </if>
  141. <if test="examineNum != null" >
  142. #{examineNum,jdbcType=INTEGER},
  143. </if>
  144. <if test="redTicket != null" >
  145. #{redTicket,jdbcType=INTEGER},
  146. </if>
  147. <if test="blueTicket != null" >
  148. #{blueTicket,jdbcType=INTEGER},
  149. </if>
  150. <if test="adminId != null" >
  151. #{adminId,jdbcType=INTEGER},
  152. </if>
  153. <if test="createTime != null" >
  154. #{createTime,jdbcType=TIMESTAMP},
  155. </if>
  156. <if test="lead != null and lead != ''" >
  157. #{lead,jdbcType=LONGVARCHAR},
  158. </if>
  159. <if test="redDesc != null and redDesc != ''" >
  160. #{redDesc,jdbcType=LONGVARCHAR},
  161. </if>
  162. <if test="blueDesc != null and blueDesc != ''" >
  163. #{blueDesc,jdbcType=LONGVARCHAR},
  164. </if>
  165. <if test="pkVoteNum != null">
  166. #{pkVoteNum,jdbcType=INTEGER},
  167. </if>
  168. </trim>
  169. </insert>
  170. <update id="updateByPrimaryKeySelective" parameterType="com.juxiao.xchat.module.xbd.domain.circle.Topic" >
  171. update topic
  172. <set >
  173. <if test="title != null" >
  174. title = #{title,jdbcType=VARCHAR},
  175. </if>
  176. <if test="pic != null" >
  177. pic = #{pic,jdbcType=VARCHAR},
  178. </if>
  179. <if test="sort != null" >
  180. sort = #{sort,jdbcType=INTEGER},
  181. </if>
  182. <if test="activation != null" >
  183. activation = #{activation,jdbcType=INTEGER},
  184. </if>
  185. <if test="pk != null" >
  186. pk = #{pk,jdbcType=INTEGER},
  187. </if>
  188. <if test="redOption != null" >
  189. red_option = #{redOption,jdbcType=VARCHAR},
  190. </if>
  191. <if test="blueOption != null" >
  192. blue_option = #{blueOption,jdbcType=VARCHAR},
  193. </if>
  194. <if test="endTime != null" >
  195. end_time = #{endTime,jdbcType=VARCHAR},
  196. </if>
  197. <if test="examine != null" >
  198. examine = #{examine,jdbcType=INTEGER},
  199. </if>
  200. <if test="examineNum != null" >
  201. examine_num = #{examineNum,jdbcType=INTEGER},
  202. </if>
  203. <if test="redTicket != null" >
  204. red_ticket = #{redTicket,jdbcType=INTEGER},
  205. </if>
  206. <if test="blueTicket != null" >
  207. blue_ticket = #{blueTicket,jdbcType=INTEGER},
  208. </if>
  209. <if test="adminId != null" >
  210. admin_id = #{adminId,jdbcType=INTEGER},
  211. </if>
  212. <if test="createTime != null" >
  213. create_time = #{createTime,jdbcType=TIMESTAMP},
  214. </if>
  215. <if test="lead != null" >
  216. lead = #{lead,jdbcType=LONGVARCHAR},
  217. </if>
  218. <if test="redDesc != null" >
  219. red_desc = #{redDesc,jdbcType=LONGVARCHAR},
  220. </if>
  221. <if test="blueDesc != null" >
  222. blue_desc = #{blueDesc,jdbcType=LONGVARCHAR},
  223. </if>
  224. </set>
  225. where id = #{id,jdbcType=INTEGER}
  226. </update>
  227. <update id="updateByPrimaryKey" parameterType="com.juxiao.xchat.module.xbd.domain.circle.Topic" >
  228. update topic
  229. set title = #{title,jdbcType=VARCHAR},
  230. pic = #{pic,jdbcType=VARCHAR},
  231. sort = #{sort,jdbcType=INTEGER},
  232. activation = #{activation,jdbcType=INTEGER},
  233. pk = #{pk,jdbcType=INTEGER},
  234. red_option = #{redOption,jdbcType=VARCHAR},
  235. blue_option = #{blueOption,jdbcType=VARCHAR},
  236. end_time = #{endTime,jdbcType=VARCHAR},
  237. examine = #{examine,jdbcType=INTEGER},
  238. examine_num = #{examineNum,jdbcType=INTEGER},
  239. red_ticket = #{redTicket,jdbcType=INTEGER},
  240. blue_ticket = #{blueTicket,jdbcType=INTEGER},
  241. admin_id = #{adminId,jdbcType=INTEGER},
  242. create_time = #{createTime,jdbcType=TIMESTAMP},
  243. pk_vote_num = #{pkVoteNum,jdbcType=INTEGER},
  244. where id = #{id,jdbcType=INTEGER}
  245. </update>
  246. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
  247. delete from topic
  248. where id = #{id,jdbcType=INTEGER}
  249. </delete>
  250. <select id="selectTopicByPage" resultType="com.juxiao.xchat.module.xbd.vo.TopicVO">
  251. select t.id, t.title, t.pic, t.sort, t.activation, t.pk, t.red_option as redOption, t.blue_option as blueOption, t.end_time as endTime, t.examine,
  252. t.examine_num as examineNum, t.red_ticket as redTicket, t.blue_ticket as blueTicket, t.admin_id as adminId, t.create_time as createTime,t.lead,
  253. t.red_desc as redDesc, t.blue_desc as blueDesc,su.user_name as adminName,t.pk_vote_num as pkVoteNum
  254. from topic t
  255. left join sys_user su on t.admin_id = su.user_id
  256. where 1 = 1
  257. <if test="title != null and title != ''">
  258. and t.title LIKE "%"#{title}"%"
  259. </if>
  260. <if test="status != null">
  261. and t.activation = #{status}
  262. </if>
  263. <if test="adminName != null and adminName != ''">
  264. and su.user_name = #{adminName}
  265. </if>
  266. order by t.sort asc , t.create_time desc
  267. </select>
  268. </mapper>