LectureMapper.xml 12 KB

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