DemoStudentMapper.xml 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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.idea.demo.mapper.DemoStudentMapper">
  4. <resultMap id="BaseResultMap" type="com.idea.demo.model.DemoStudent">
  5. <id column="id" jdbcType="VARCHAR" property="id" />
  6. <result column="name" jdbcType="VARCHAR" property="name" />
  7. <result column="gender" jdbcType="VARCHAR" property="gender" />
  8. <result column="birthday" jdbcType="TIMESTAMP" property="birthday" />
  9. <result column="comment" jdbcType="VARCHAR" property="comment" />
  10. <result column="created_at" jdbcType="TIMESTAMP" property="createdAt" />
  11. <result column="created_by" jdbcType="VARCHAR" property="createdBy" />
  12. </resultMap>
  13. <sql id="Example_Where_Clause">
  14. <where>
  15. <foreach collection="oredCriteria" item="criteria" separator="or">
  16. <if test="criteria.valid">
  17. <trim prefix="(" prefixOverrides="and" suffix=")">
  18. <foreach collection="criteria.criteria" item="criterion">
  19. <choose>
  20. <when test="criterion.noValue">
  21. and ${criterion.condition}
  22. </when>
  23. <when test="criterion.singleValue">
  24. and ${criterion.condition} #{criterion.value}
  25. </when>
  26. <when test="criterion.betweenValue">
  27. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  28. </when>
  29. <when test="criterion.listValue">
  30. and ${criterion.condition}
  31. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  32. #{listItem}
  33. </foreach>
  34. </when>
  35. </choose>
  36. </foreach>
  37. </trim>
  38. </if>
  39. </foreach>
  40. </where>
  41. </sql>
  42. <sql id="Update_By_Example_Where_Clause">
  43. <where>
  44. <foreach collection="example.oredCriteria" item="criteria" separator="or">
  45. <if test="criteria.valid">
  46. <trim prefix="(" prefixOverrides="and" suffix=")">
  47. <foreach collection="criteria.criteria" item="criterion">
  48. <choose>
  49. <when test="criterion.noValue">
  50. and ${criterion.condition}
  51. </when>
  52. <when test="criterion.singleValue">
  53. and ${criterion.condition} #{criterion.value}
  54. </when>
  55. <when test="criterion.betweenValue">
  56. and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
  57. </when>
  58. <when test="criterion.listValue">
  59. and ${criterion.condition}
  60. <foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
  61. #{listItem}
  62. </foreach>
  63. </when>
  64. </choose>
  65. </foreach>
  66. </trim>
  67. </if>
  68. </foreach>
  69. </where>
  70. </sql>
  71. <sql id="Base_Column_List">
  72. id, name, gender, birthday, comment, created_at, created_by
  73. </sql>
  74. <select id="selectByExample" parameterType="com.idea.demo.model.DemoStudentExample" resultMap="BaseResultMap">
  75. select
  76. <if test="distinct">
  77. distinct
  78. </if>
  79. <include refid="Base_Column_List" />
  80. from demo_student
  81. <if test="_parameter != null">
  82. <include refid="Example_Where_Clause" />
  83. </if>
  84. <if test="orderByClause != null">
  85. order by ${orderByClause}
  86. </if>
  87. </select>
  88. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  89. select
  90. <include refid="Base_Column_List" />
  91. from demo_student
  92. where id = #{id,jdbcType=VARCHAR}
  93. </select>
  94. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  95. delete from demo_student
  96. where id = #{id,jdbcType=VARCHAR}
  97. </delete>
  98. <delete id="deleteByExample" parameterType="com.idea.demo.model.DemoStudentExample">
  99. delete from demo_student
  100. <if test="_parameter != null">
  101. <include refid="Example_Where_Clause" />
  102. </if>
  103. </delete>
  104. <insert id="insert" parameterType="com.idea.demo.model.DemoStudent">
  105. <selectKey keyProperty="id" order="AFTER" resultType="java.lang.String">
  106. SELECT LAST_INSERT_ID()
  107. </selectKey>
  108. insert into demo_student (id, name, gender, birthday,
  109. comment, created_at, created_by
  110. )
  111. values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{gender,jdbcType=VARCHAR}, #{birthday,jdbcType=TIMESTAMP},
  112. #{comment,jdbcType=VARCHAR}, #{createdAt,jdbcType=TIMESTAMP}, #{createdBy,jdbcType=VARCHAR}
  113. )
  114. </insert>
  115. <insert id="insertSelective" parameterType="com.idea.demo.model.DemoStudent">
  116. <selectKey keyProperty="id" order="AFTER" resultType="java.lang.String">
  117. SELECT LAST_INSERT_ID()
  118. </selectKey>
  119. insert into demo_student
  120. <trim prefix="(" suffix=")" suffixOverrides=",">
  121. <if test="id != null">
  122. id,
  123. </if>
  124. <if test="name != null">
  125. name,
  126. </if>
  127. <if test="gender != null">
  128. gender,
  129. </if>
  130. <if test="birthday != null">
  131. birthday,
  132. </if>
  133. <if test="comment != null">
  134. comment,
  135. </if>
  136. <if test="createdAt != null">
  137. created_at,
  138. </if>
  139. <if test="createdBy != null">
  140. created_by,
  141. </if>
  142. </trim>
  143. <trim prefix="values (" suffix=")" suffixOverrides=",">
  144. <if test="id != null">
  145. #{id,jdbcType=VARCHAR},
  146. </if>
  147. <if test="name != null">
  148. #{name,jdbcType=VARCHAR},
  149. </if>
  150. <if test="gender != null">
  151. #{gender,jdbcType=VARCHAR},
  152. </if>
  153. <if test="birthday != null">
  154. #{birthday,jdbcType=TIMESTAMP},
  155. </if>
  156. <if test="comment != null">
  157. #{comment,jdbcType=VARCHAR},
  158. </if>
  159. <if test="createdAt != null">
  160. #{createdAt,jdbcType=TIMESTAMP},
  161. </if>
  162. <if test="createdBy != null">
  163. #{createdBy,jdbcType=VARCHAR},
  164. </if>
  165. </trim>
  166. </insert>
  167. <select id="countByExample" parameterType="com.idea.demo.model.DemoStudentExample" resultType="java.lang.Long">
  168. select count(*) from demo_student
  169. <if test="_parameter != null">
  170. <include refid="Example_Where_Clause" />
  171. </if>
  172. </select>
  173. <update id="updateByExampleSelective" parameterType="map">
  174. update demo_student
  175. <set>
  176. <if test="record.id != null">
  177. id = #{record.id,jdbcType=VARCHAR},
  178. </if>
  179. <if test="record.name != null">
  180. name = #{record.name,jdbcType=VARCHAR},
  181. </if>
  182. <if test="record.gender != null">
  183. gender = #{record.gender,jdbcType=VARCHAR},
  184. </if>
  185. <if test="record.birthday != null">
  186. birthday = #{record.birthday,jdbcType=TIMESTAMP},
  187. </if>
  188. <if test="record.comment != null">
  189. comment = #{record.comment,jdbcType=VARCHAR},
  190. </if>
  191. <if test="record.createdAt != null">
  192. created_at = #{record.createdAt,jdbcType=TIMESTAMP},
  193. </if>
  194. <if test="record.createdBy != null">
  195. created_by = #{record.createdBy,jdbcType=VARCHAR},
  196. </if>
  197. </set>
  198. <if test="_parameter != null">
  199. <include refid="Update_By_Example_Where_Clause" />
  200. </if>
  201. </update>
  202. <update id="updateByExample" parameterType="map">
  203. update demo_student
  204. set id = #{record.id,jdbcType=VARCHAR},
  205. name = #{record.name,jdbcType=VARCHAR},
  206. gender = #{record.gender,jdbcType=VARCHAR},
  207. birthday = #{record.birthday,jdbcType=TIMESTAMP},
  208. comment = #{record.comment,jdbcType=VARCHAR},
  209. created_at = #{record.createdAt,jdbcType=TIMESTAMP},
  210. created_by = #{record.createdBy,jdbcType=VARCHAR}
  211. <if test="_parameter != null">
  212. <include refid="Update_By_Example_Where_Clause" />
  213. </if>
  214. </update>
  215. <update id="updateByPrimaryKeySelective" parameterType="com.idea.demo.model.DemoStudent">
  216. update demo_student
  217. <set>
  218. <if test="name != null">
  219. name = #{name,jdbcType=VARCHAR},
  220. </if>
  221. <if test="gender != null">
  222. gender = #{gender,jdbcType=VARCHAR},
  223. </if>
  224. <if test="birthday != null">
  225. birthday = #{birthday,jdbcType=TIMESTAMP},
  226. </if>
  227. <if test="comment != null">
  228. comment = #{comment,jdbcType=VARCHAR},
  229. </if>
  230. <if test="createdAt != null">
  231. created_at = #{createdAt,jdbcType=TIMESTAMP},
  232. </if>
  233. <if test="createdBy != null">
  234. created_by = #{createdBy,jdbcType=VARCHAR},
  235. </if>
  236. </set>
  237. where id = #{id,jdbcType=VARCHAR}
  238. </update>
  239. <update id="updateByPrimaryKey" parameterType="com.idea.demo.model.DemoStudent">
  240. update demo_student
  241. set name = #{name,jdbcType=VARCHAR},
  242. gender = #{gender,jdbcType=VARCHAR},
  243. birthday = #{birthday,jdbcType=TIMESTAMP},
  244. comment = #{comment,jdbcType=VARCHAR},
  245. created_at = #{createdAt,jdbcType=TIMESTAMP},
  246. created_by = #{createdBy,jdbcType=VARCHAR}
  247. where id = #{id,jdbcType=VARCHAR}
  248. </update>
  249. </mapper>