LectureMapper.xml 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  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. </resultMap>
  17. <sql id="Base_Column_List" >
  18. id, uid, lecture_time, create_time, last_update_time, name, summary, deleted_sign, lecture_url,
  19. hot, dynamic
  20. </sql>
  21. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
  22. select
  23. <include refid="Base_Column_List" />
  24. from lecture
  25. where id = #{id,jdbcType=VARCHAR}
  26. </select>
  27. <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
  28. delete from lecture
  29. where id = #{id,jdbcType=VARCHAR}
  30. </delete>
  31. <insert id="insert" parameterType="com.goafanti.common.model.Lecture" >
  32. insert into lecture (id, uid, lecture_time,
  33. create_time, last_update_time, name,
  34. summary, deleted_sign, lecture_url, hot, dynamic)
  35. values (#{id,jdbcType=VARCHAR}, #{uid,jdbcType=VARCHAR}, #{lectureTime,jdbcType=TIMESTAMP},
  36. #{createTime,jdbcType=TIMESTAMP}, #{lastUpdateTime,jdbcType=TIMESTAMP}, #{name,jdbcType=VARCHAR},
  37. #{summary,jdbcType=VARCHAR}, #{deletedSign,jdbcType=INTEGER}, #{lectureUrl,jdbcType=VARCHAR},
  38. #{hot,jdbcType=INTEGER}, #{dynamic,jdbcType=INTEGER})
  39. </insert>
  40. <insert id="insertSelective" parameterType="com.goafanti.common.model.Lecture" >
  41. insert into lecture
  42. <trim prefix="(" suffix=")" suffixOverrides="," >
  43. <if test="id != null" >
  44. id,
  45. </if>
  46. <if test="uid != null" >
  47. uid,
  48. </if>
  49. <if test="lectureTime != null" >
  50. lecture_time,
  51. </if>
  52. <if test="createTime != null" >
  53. create_time,
  54. </if>
  55. <if test="lastUpdateTime != null" >
  56. last_update_time,
  57. </if>
  58. <if test="name != null" >
  59. name,
  60. </if>
  61. <if test="summary != null" >
  62. summary,
  63. </if>
  64. <if test="deletedSign != null" >
  65. deleted_sign,
  66. </if>
  67. <if test="lectureUrl != null" >
  68. lecture_url,
  69. </if>
  70. <if test="hot != null" >
  71. hot,
  72. </if>
  73. <if test="dynamic != null" >
  74. dynamic,
  75. </if>
  76. </trim>
  77. <trim prefix="values (" suffix=")" suffixOverrides="," >
  78. <if test="id != null" >
  79. #{id,jdbcType=VARCHAR},
  80. </if>
  81. <if test="uid != null" >
  82. #{uid,jdbcType=VARCHAR},
  83. </if>
  84. <if test="lectureTime != null" >
  85. #{lectureTime,jdbcType=TIMESTAMP},
  86. </if>
  87. <if test="createTime != null" >
  88. #{createTime,jdbcType=TIMESTAMP},
  89. </if>
  90. <if test="lastUpdateTime != null" >
  91. #{lastUpdateTime,jdbcType=TIMESTAMP},
  92. </if>
  93. <if test="name != null" >
  94. #{name,jdbcType=VARCHAR},
  95. </if>
  96. <if test="summary != null" >
  97. #{summary,jdbcType=VARCHAR},
  98. </if>
  99. <if test="deletedSign != null" >
  100. #{deletedSign,jdbcType=INTEGER},
  101. </if>
  102. <if test="lectureUrl != null" >
  103. #{lectureUrl,jdbcType=VARCHAR},
  104. </if>
  105. <if test="hot != null" >
  106. #{hot,jdbcType=INTEGER},
  107. </if>
  108. <if test="dynamic != null" >
  109. #{dynamic,jdbcType=INTEGER},
  110. </if>
  111. </trim>
  112. </insert>
  113. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.Lecture" >
  114. update lecture
  115. <set >
  116. <if test="uid != null" >
  117. uid = #{uid,jdbcType=VARCHAR},
  118. </if>
  119. <if test="lectureTime != null" >
  120. lecture_time = #{lectureTime,jdbcType=TIMESTAMP},
  121. </if>
  122. <if test="createTime != null" >
  123. create_time = #{createTime,jdbcType=TIMESTAMP},
  124. </if>
  125. <if test="lastUpdateTime != null" >
  126. last_update_time = #{lastUpdateTime,jdbcType=TIMESTAMP},
  127. </if>
  128. <if test="name != null" >
  129. name = #{name,jdbcType=VARCHAR},
  130. </if>
  131. <if test="summary != null" >
  132. summary = #{summary,jdbcType=VARCHAR},
  133. </if>
  134. <if test="deletedSign != null" >
  135. deleted_sign = #{deletedSign,jdbcType=INTEGER},
  136. </if>
  137. <if test="lectureUrl != null" >
  138. lecture_url = #{lectureUrl,jdbcType=VARCHAR},
  139. </if>
  140. <if test="hot != null" >
  141. hot = #{hot,jdbcType=INTEGER},
  142. </if>
  143. <if test="dynamic != null" >
  144. dynamic = #{dynamic,jdbcType=INTEGER},
  145. </if>
  146. </set>
  147. where id = #{id,jdbcType=VARCHAR}
  148. </update>
  149. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.Lecture" >
  150. update lecture
  151. set uid = #{uid,jdbcType=VARCHAR},
  152. lecture_time = #{lectureTime,jdbcType=TIMESTAMP},
  153. create_time = #{createTime,jdbcType=TIMESTAMP},
  154. last_update_time = #{lastUpdateTime,jdbcType=TIMESTAMP},
  155. name = #{name,jdbcType=VARCHAR},
  156. summary = #{summary,jdbcType=VARCHAR},
  157. deleted_sign = #{deletedSign,jdbcType=INTEGER},
  158. lecture_url = #{lectureUrl,jdbcType=VARCHAR},
  159. hot = #{hot,jdbcType=INTEGER},
  160. dynamic = #{dynamic,jdbcType=INTEGER}
  161. where id = #{id,jdbcType=VARCHAR}
  162. </update>
  163. <update id="batchDeleteByPrimaryKey" parameterType="java.util.List">
  164. update lecture set deleted_sign = 1
  165. where id in
  166. <foreach item="item" index="index" collection="list" open="("
  167. separator="," close=")">
  168. #{item}
  169. </foreach>
  170. </update>
  171. <select id="findLectureListByPage" parameterType="String" resultType="com.goafanti.lecture.bo.LectureListBo">
  172. select
  173. l.id,
  174. l.uid,
  175. l.name,
  176. l.lecture_time as lectureTime,
  177. l.summary,
  178. l.lecture_url as lectureUrl,
  179. ui.username
  180. from lecture l
  181. left join user_identity ui on ui.uid = l.uid
  182. where
  183. l.deleted_sign = 0
  184. <if test="uid != null">
  185. and l.uid = #{uid,jdbcType=VARCHAR}
  186. </if>
  187. <if test="name != null">
  188. and l.name like CONCAT('%', #{name,jdbcType=VARCHAR}, '%')
  189. </if>
  190. <if test="username != null">
  191. and ui.username like CONCAT('%', #{username,jdbcType=VARCHAR}, '%')
  192. </if>
  193. <if test="startL != null">
  194. and l.lecture_time <![CDATA[ >= ]]> #{startL,jdbcType=TIMESTAPM}
  195. </if>
  196. <if test="endL != null">
  197. and l.lecture_time <![CDATA[ < ]]> #{endL,jdbcType=TIMESTAPM}
  198. </if>
  199. order by l.lecture_time desc
  200. <if test="page_sql!=null">
  201. ${page_sql}
  202. </if>
  203. </select>
  204. <select id="findLectureCount" parameterType="String" resultType="java.lang.Integer">
  205. select
  206. count(1)
  207. from lecture l
  208. left join user_identity ui on ui.uid = l.uid
  209. where
  210. l.deleted_sign = 0
  211. <if test="uid != null">
  212. and l.uid = #{uid,jdbcType=VARCHAR}
  213. </if>
  214. <if test="name != null">
  215. and l.name like CONCAT('%', #{name,jdbcType=VARCHAR}, '%')
  216. </if>
  217. <if test="username != null">
  218. and ui.username like CONCAT('%', #{username,jdbcType=VARCHAR}, '%')
  219. </if>
  220. <if test="startL != null">
  221. and l.lecture_time <![CDATA[ >= ]]> #{startL,jdbcType=TIMESTAMP}
  222. </if>
  223. <if test="endL != null">
  224. and l.lecture_time <![CDATA[ < ]]> #{endL,jdbcType=TIMESTAMP}
  225. </if>
  226. </select>
  227. </mapper>