LectureMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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.goafanti.common.dao.LectureMapper" >
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.Lecture" >
  5. <id column="id" property="id" jdbcType="VARCHAR" />
  6. <result column="uid" property="uid" jdbcType="VARCHAR" />
  7. <result column="lecture_time" property="lectureTime" jdbcType="TIMESTAMP" />
  8. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  9. <result column="last_update_time" property="lastUpdateTime" jdbcType="TIMESTAMP" />
  10. <result column="name" property="name" jdbcType="VARCHAR" />
  11. <result column="summary" property="summary" jdbcType="VARCHAR" />
  12. <result column="deleted_sign" property="deletedSign" jdbcType="INTEGER" />
  13. <result column="lecture_url" property="lectureUrl" jdbcType="VARCHAR" />
  14. <result column="hot" property="hot" jdbcType="INTEGER" />
  15. <result column="dynamic" property="dynamic" jdbcType="INTEGER" />
  16. <result column="end_time" property="endTime" jdbcType="TIMESTAMP" />
  17. </resultMap>
  18. <sql id="Base_Column_List" >
  19. id, uid, lecture_time, create_time, last_update_time, name, summary, deleted_sign, lecture_url,
  20. hot, dynamic, end_time
  21. </sql>
  22. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
  23. select
  24. <include refid="Base_Column_List" />
  25. from lecture
  26. where id = #{id,jdbcType=VARCHAR}
  27. </select>
  28. <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
  29. delete from lecture
  30. where id = #{id,jdbcType=VARCHAR}
  31. </delete>
  32. <insert id="insert" parameterType="com.goafanti.common.model.Lecture" >
  33. insert into lecture (id, uid, lecture_time,
  34. create_time, last_update_time, name,
  35. summary, deleted_sign, lecture_url, hot, dynamic, end_time)
  36. values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, #{lectureTime,jdbcType=TIMESTAMP},
  37. #{createTime,jdbcType=TIMESTAMP}, #{lastUpdateTime,jdbcType=TIMESTAMP}, #{name,jdbcType=VARCHAR},
  38. #{summary,jdbcType=VARCHAR}, #{deletedSign,jdbcType=INTEGER}, #{lectureUrl,jdbcType=VARCHAR},
  39. #{hot,jdbcType=INTEGER}, #{dynamic,jdbcType=INTEGER}, #{endTime,jdbcType=TIMESTAMP})
  40. </insert>
  41. <insert id="insertSelective" parameterType="com.goafanti.common.model.Lecture" >
  42. insert into lecture
  43. <trim prefix="(" suffix=")" suffixOverrides="," >
  44. <if test="id != null" >
  45. id,
  46. </if>
  47. <if test="uid != null" >
  48. uid,
  49. </if>
  50. <if test="lectureTime != null" >
  51. lecture_time,
  52. </if>
  53. <if test="createTime != null" >
  54. create_time,
  55. </if>
  56. <if test="lastUpdateTime != null" >
  57. last_update_time,
  58. </if>
  59. <if test="name != null" >
  60. name,
  61. </if>
  62. <if test="summary != null" >
  63. summary,
  64. </if>
  65. <if test="deletedSign != null" >
  66. deleted_sign,
  67. </if>
  68. <if test="lectureUrl != null" >
  69. lecture_url,
  70. </if>
  71. <if test="hot != null" >
  72. hot,
  73. </if>
  74. <if test="dynamic != null" >
  75. dynamic,
  76. </if>
  77. <if test="endTime != null" >
  78. end_time,
  79. </if>
  80. </trim>
  81. <trim prefix="values (" suffix=")" suffixOverrides="," >
  82. <if test="id != null" >
  83. #{id,jdbcType=VARCHAR},
  84. </if>
  85. <if test="uid != null" >
  86. #{uid,jdbcType=VARCHAR},
  87. </if>
  88. <if test="lectureTime != null" >
  89. #{lectureTime,jdbcType=TIMESTAMP},
  90. </if>
  91. <if test="createTime != null" >
  92. #{createTime,jdbcType=TIMESTAMP},
  93. </if>
  94. <if test="lastUpdateTime != null" >
  95. #{lastUpdateTime,jdbcType=TIMESTAMP},
  96. </if>
  97. <if test="name != null" >
  98. #{name,jdbcType=VARCHAR},
  99. </if>
  100. <if test="summary != null" >
  101. #{summary,jdbcType=VARCHAR},
  102. </if>
  103. <if test="deletedSign != null" >
  104. #{deletedSign,jdbcType=INTEGER},
  105. </if>
  106. <if test="lectureUrl != null" >
  107. #{lectureUrl,jdbcType=VARCHAR},
  108. </if>
  109. <if test="hot != null" >
  110. #{hot,jdbcType=INTEGER},
  111. </if>
  112. <if test="dynamic != null" >
  113. #{dynamic,jdbcType=INTEGER},
  114. </if>
  115. <if test="endTime != null" >
  116. #{endTime,jdbcType=TIMESTAMP},
  117. </if>
  118. </trim>
  119. </insert>
  120. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Lecture" >
  121. update lecture
  122. <set >
  123. <if test="uid != null" >
  124. uid = #{uid,jdbcType=VARCHAR},
  125. </if>
  126. <if test="lectureTime != null" >
  127. lecture_time = #{lectureTime,jdbcType=TIMESTAMP},
  128. </if>
  129. <if test="createTime != null" >
  130. create_time = #{createTime,jdbcType=TIMESTAMP},
  131. </if>
  132. <if test="lastUpdateTime != null" >
  133. last_update_time = #{lastUpdateTime,jdbcType=TIMESTAMP},
  134. </if>
  135. <if test="name != null" >
  136. name = #{name,jdbcType=VARCHAR},
  137. </if>
  138. <if test="summary != null" >
  139. summary = #{summary,jdbcType=VARCHAR},
  140. </if>
  141. <if test="deletedSign != null" >
  142. deleted_sign = #{deletedSign,jdbcType=INTEGER},
  143. </if>
  144. <if test="lectureUrl != null" >
  145. lecture_url = #{lectureUrl,jdbcType=VARCHAR},
  146. </if>
  147. <if test="hot != null" >
  148. hot = #{hot,jdbcType=INTEGER},
  149. </if>
  150. <if test="dynamic != null" >
  151. dynamic = #{dynamic,jdbcType=INTEGER},
  152. </if>
  153. <if test="endTime != null" >
  154. end_time = #{endTime,jdbcType=TIMESTAMP},
  155. </if>
  156. </set>
  157. where id = #{id,jdbcType=VARCHAR}
  158. </update>
  159. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Lecture" >
  160. update lecture
  161. set uid = #{uid,jdbcType=VARCHAR},
  162. lecture_time = #{lectureTime,jdbcType=TIMESTAMP},
  163. create_time = #{createTime,jdbcType=TIMESTAMP},
  164. last_update_time = #{lastUpdateTime,jdbcType=TIMESTAMP},
  165. name = #{name,jdbcType=VARCHAR},
  166. summary = #{summary,jdbcType=VARCHAR},
  167. deleted_sign = #{deletedSign,jdbcType=INTEGER},
  168. lecture_url = #{lectureUrl,jdbcType=VARCHAR},
  169. hot = #{hot,jdbcType=INTEGER},
  170. dynamic = #{dynamic,jdbcType=INTEGER},
  171. end_time = #{endTime,jdbcType=TIMESTAMP}
  172. where id = #{id,jdbcType=VARCHAR}
  173. </update>
  174. <update id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  175. update lecture set deleted_sign = 1
  176. where id in
  177. <foreach item="item" index="index" collection="list" open="("
  178. separator="," close=")">
  179. #{item}
  180. </foreach>
  181. </update>
  182. <select id="findLectureListByPage" parameterType="String" resultType="com.goafanti.lecture.bo.LectureListBo">
  183. select
  184. l.id,
  185. l.uid,
  186. l.name,
  187. l.lecture_time as lectureTime,
  188. l.summary,
  189. l.lecture_url as lectureUrl,
  190. ui.username,
  191. l.hot,
  192. l.dynamic,
  193. l.end_time as endTime
  194. from lecture l
  195. left join user_identity ui on ui.uid = l.uid
  196. where
  197. l.deleted_sign = 0
  198. <if test="uid != null">
  199. and l.uid = #{uid,jdbcType=VARCHAR}
  200. </if>
  201. <if test="name != null">
  202. and l.name like CONCAT('%', #{name,jdbcType=VARCHAR}, '%')
  203. </if>
  204. <if test="username != null">
  205. and ui.username like CONCAT('%', #{username,jdbcType=VARCHAR}, '%')
  206. </if>
  207. <if test="startL != null">
  208. and l.lecture_time <![CDATA[ >= ]]> #{startL,jdbcType=TIMESTAPM}
  209. </if>
  210. <if test="endL != null">
  211. and l.lecture_time <![CDATA[ < ]]> #{endL,jdbcType=TIMESTAPM}
  212. </if>
  213. order by l.lecture_time desc
  214. <if test="page_sql!=null">
  215. ${page_sql}
  216. </if>
  217. </select>
  218. <select id="findLectureCount" parameterType="String" resultType="java.lang.Integer">
  219. select
  220. count(1)
  221. from lecture l
  222. left join user_identity ui on ui.uid = l.uid
  223. where
  224. l.deleted_sign = 0
  225. <if test="uid != null">
  226. and l.uid = #{uid,jdbcType=VARCHAR}
  227. </if>
  228. <if test="name != null">
  229. and l.name like CONCAT('%', #{name,jdbcType=VARCHAR}, '%')
  230. </if>
  231. <if test="username != null">
  232. and ui.username like CONCAT('%', #{username,jdbcType=VARCHAR}, '%')
  233. </if>
  234. <if test="startL != null">
  235. and l.lecture_time <![CDATA[ >= ]]> #{startL,jdbcType=TIMESTAMP}
  236. </if>
  237. <if test="endL != null">
  238. and l.lecture_time <![CDATA[ < ]]> #{endL,jdbcType=TIMESTAMP}
  239. </if>
  240. </select>
  241. <select id="countHotNum" resultType="java.lang.Integer">
  242. select
  243. count(1)
  244. from lecture
  245. where hot = 1
  246. and deleted_sign = 0
  247. </select>
  248. <select id="countDynamicNum" resultType="java.lang.Integer">
  249. select
  250. count(1)
  251. from lecture
  252. where dynamic = 1
  253. and deleted_sign = 0
  254. </select>
  255. <select id="listHot" resultType="com.goafanti.lecture.bo.LectureListBo">
  256. select
  257. l.id,
  258. l.uid,
  259. l.name,
  260. l.lecture_time as lectureTime,
  261. l.summary,
  262. l.lecture_url as lectureUrl,
  263. ui.username,
  264. l.hot,
  265. l.dynamic,
  266. l.end_time as endTime
  267. from lecture l
  268. left join user_identity ui on ui.uid = l.uid
  269. where
  270. l.deleted_sign = 0
  271. and l.hot = 1
  272. </select>
  273. <select id="listDynamic" resultType="com.goafanti.lecture.bo.LectureListBo">
  274. select
  275. l.id,
  276. l.uid,
  277. l.name,
  278. l.lecture_time as lectureTime,
  279. l.summary,
  280. l.lecture_url as lectureUrl,
  281. ui.username,
  282. l.hot,
  283. l.dynamic,
  284. l.end_time as endTime
  285. from lecture l
  286. left join user_identity ui on ui.uid = l.uid
  287. where
  288. l.deleted_sign = 0
  289. and l.dynamic = 1
  290. </select>
  291. <select id="listBigShotLecture" resultType="com.goafanti.lecture.bo.BigShotLectureListBo">
  292. select
  293. l.id,
  294. l.uid,
  295. l.name,
  296. l.lecture_time as lectureTime,
  297. l.summary,
  298. l.lecture_url as lectureUrl,
  299. ui.username,
  300. l.end_time as endTime
  301. from lecture l
  302. left join user_identity ui on ui.uid = l.uid
  303. where
  304. l.deleted_sign = 0
  305. and l.hot = 1
  306. </select>
  307. </mapper>