GoodsLabelWriteMapper.xml 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305
  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.slodon.b2b2c.dao.write.goods.GoodsLabelWriteMapper">
  4. <resultMap id="resultMap" type="com.slodon.b2b2c.goods.pojo.GoodsLabel">
  5. <id column="label_id" property="labelId" />
  6. <result column="web_site" property="webSite" />
  7. <result column="label_name" property="labelName" />
  8. <result column="description" property="description" />
  9. <result column="sort" property="sort" />
  10. <result column="create_time" property="createTime" />
  11. <result column="create_admin_id" property="createAdminId" />
  12. <result column="update_time" property="updateTime" />
  13. <result column="update_admin_id" property="updateAdminId" />
  14. </resultMap>
  15. <!--除主键外的所有字段,用于插入操作-->
  16. <sql id="columns">
  17. <trim suffixOverrides=",">
  18. <if test="webSite != null">
  19. `web_site`,
  20. </if>
  21. <if test="labelName != null">
  22. `label_name`,
  23. </if>
  24. <if test="description != null">
  25. `description`,
  26. </if>
  27. <if test="sort != null">
  28. `sort`,
  29. </if>
  30. <if test="createTime != null">
  31. `create_time`,
  32. </if>
  33. <if test="createAdminId != null">
  34. `create_admin_id`,
  35. </if>
  36. <if test="updateTime != null">
  37. `update_time`,
  38. </if>
  39. <if test="updateAdminId != null">
  40. `update_admin_id`,
  41. </if>
  42. </trim>
  43. </sql>
  44. <!--按照主键值进行操作-->
  45. <sql id="pkWhere">
  46. WHERE `label_id` = #{primaryKey}
  47. </sql>
  48. <!--操作条件-->
  49. <sql id="whereCondition">
  50. <if test="example != null">
  51. <trim prefix="WHERE" prefixOverrides="AND|OR">
  52. <if test="example.labelIdNotEquals != null">
  53. AND `label_id` != #{example.labelIdNotEquals}
  54. </if>
  55. <if test="example.labelIdIn != null">
  56. AND `label_id` in (${example.labelIdIn})
  57. </if>
  58. <if test="example.webSite != null">
  59. AND `web_site` = #{example.webSite}
  60. </if>
  61. <if test="example.labelName != null">
  62. AND `label_name` = #{example.labelName}
  63. </if>
  64. <if test="example.labelNameLike != null">
  65. AND `label_name` like concat('%',#{example.labelNameLike},'%')
  66. </if>
  67. <if test="example.description != null">
  68. AND `description` = #{example.description}
  69. </if>
  70. <if test="example.sort != null">
  71. AND `sort` = #{example.sort}
  72. </if>
  73. <if test="example.createTimeAfter != null">
  74. AND `create_time` <![CDATA[ >= ]]> #{example.createTimeAfter}
  75. </if>
  76. <if test="example.createTimeBefore != null">
  77. AND `create_time` <![CDATA[ <= ]]> #{example.createTimeBefore}
  78. </if>
  79. <if test="example.createAdminId != null">
  80. AND `create_admin_id` = #{example.createAdminId}
  81. </if>
  82. <if test="example.updateTimeAfter != null">
  83. AND `update_time` <![CDATA[ >= ]]> #{example.updateTimeAfter}
  84. </if>
  85. <if test="example.updateTimeBefore != null">
  86. AND `update_time` <![CDATA[ <= ]]> #{example.updateTimeBefore}
  87. </if>
  88. <if test="example.updateAdminId != null">
  89. AND `update_admin_id` = #{example.updateAdminId}
  90. </if>
  91. </trim>
  92. </if>
  93. </sql>
  94. <!--排序条件-->
  95. <sql id="orderBy">
  96. ORDER BY `label_id` DESC
  97. </sql>
  98. <sql id="orderByOther">
  99. order by ${example.orderBy}
  100. </sql>
  101. <!--分组条件-->
  102. <sql id="groupBy">
  103. group by ${example.groupBy}
  104. </sql>
  105. <!--分页条件-->
  106. <sql id="limit">
  107. <if test="size != null and size &gt; 0">
  108. limit #{startRow},#{size}
  109. </if>
  110. </sql>
  111. <!--查询符合条件的记录数-->
  112. <select id="countByExample" parameterType="com.slodon.b2b2c.goods.example.GoodsLabelExample" resultType="java.lang.Integer">
  113. SELECT
  114. COUNT(*)
  115. FROM `goods_label`
  116. <include refid="whereCondition" />
  117. </select>
  118. <!--根据主键查询记录-->
  119. <select id="getByPrimaryKey" resultMap="resultMap">
  120. SELECT
  121. *
  122. FROM `goods_label`
  123. <include refid="pkWhere" />
  124. </select>
  125. <!--查询符合条件的记录(所有字段)-->
  126. <select id="listByExample" resultMap="resultMap">
  127. SELECT
  128. *
  129. FROM `goods_label`
  130. <include refid="whereCondition" />
  131. <if test="example.groupBy != null">
  132. <include refid="groupBy" />
  133. </if>
  134. <choose>
  135. <when test="example.orderBy != null">
  136. <include refid="orderByOther" />
  137. </when>
  138. <otherwise>
  139. <include refid="orderBy" />
  140. </otherwise>
  141. </choose>
  142. </select>
  143. <!--分页查询符合条件的记录(所有字段)-->
  144. <select id="listPageByExample" resultMap="resultMap">
  145. SELECT
  146. *
  147. FROM `goods_label`
  148. <include refid="whereCondition" />
  149. <if test="example.groupBy != null">
  150. <include refid="groupBy" />
  151. </if>
  152. <choose>
  153. <when test="example.orderBy != null">
  154. <include refid="orderByOther" />
  155. </when>
  156. <otherwise>
  157. <include refid="orderBy" />
  158. </otherwise>
  159. </choose>
  160. <include refid="limit" />
  161. </select>
  162. <!--查询符合条件的记录(指定字段)-->
  163. <select id="listFieldsByExample" resultMap="resultMap">
  164. SELECT
  165. ${fields}
  166. FROM `goods_label`
  167. <include refid="whereCondition" />
  168. <if test="example.groupBy != null">
  169. <include refid="groupBy" />
  170. </if>
  171. <choose>
  172. <when test="example.orderBy != null">
  173. <include refid="orderByOther" />
  174. </when>
  175. <otherwise>
  176. <include refid="orderBy" />
  177. </otherwise>
  178. </choose>
  179. </select>
  180. <!--分页查询符合条件的记录(指定字段)-->
  181. <select id="listFieldsPageByExample" resultMap="resultMap">
  182. SELECT
  183. ${fields}
  184. FROM `goods_label`
  185. <include refid="whereCondition" />
  186. <if test="example.groupBy != null">
  187. <include refid="groupBy" />
  188. </if>
  189. <choose>
  190. <when test="example.orderBy != null">
  191. <include refid="orderByOther" />
  192. </when>
  193. <otherwise>
  194. <include refid="orderBy" />
  195. </otherwise>
  196. </choose>
  197. <include refid="limit" />
  198. </select>
  199. <!--根据条件删除记录,可多条删除-->
  200. <delete id="deleteByExample">
  201. DELETE FROM `goods_label`
  202. <include refid="whereCondition" />
  203. </delete>
  204. <!--根据主键删除记录-->
  205. <delete id="deleteByPrimaryKey">
  206. DELETE FROM `goods_label`
  207. <include refid="pkWhere" />
  208. </delete>
  209. <!--插入一条记录-->
  210. <insert id="insert" keyColumn="label_id" keyProperty="labelId" parameterType="com.slodon.b2b2c.goods.pojo.GoodsLabel" useGeneratedKeys="true">
  211. INSERT INTO `goods_label`(
  212. <include refid="columns" />
  213. )
  214. VALUES(
  215. <trim suffixOverrides=",">
  216. <if test="webSite != null">
  217. #{webSite},
  218. </if>
  219. <if test="labelName != null">
  220. #{labelName},
  221. </if>
  222. <if test="description != null">
  223. #{description},
  224. </if>
  225. <if test="sort != null">
  226. #{sort},
  227. </if>
  228. <if test="createTime != null">
  229. #{createTime},
  230. </if>
  231. <if test="createAdminId != null">
  232. #{createAdminId},
  233. </if>
  234. <if test="updateTime != null">
  235. #{updateTime},
  236. </if>
  237. <if test="updateAdminId != null">
  238. #{updateAdminId},
  239. </if>
  240. </trim>
  241. )
  242. </insert>
  243. <!--按条件更新记录中不为空的字段-->
  244. <update id="updateByExampleSelective">
  245. UPDATE `goods_label`
  246. <trim prefix="SET" suffixOverrides=",">
  247. <if test="record.webSite != null">
  248. `web_site` = #{record.webSite},
  249. </if>
  250. <if test="record.labelName != null">
  251. `label_name` = #{record.labelName},
  252. </if>
  253. <if test="record.description != null">
  254. `description` = #{record.description},
  255. </if>
  256. <if test="record.sort != null">
  257. `sort` = #{record.sort},
  258. </if>
  259. <if test="record.createTime != null">
  260. `create_time` = #{record.createTime},
  261. </if>
  262. <if test="record.createAdminId != null">
  263. `create_admin_id` = #{record.createAdminId},
  264. </if>
  265. <if test="record.updateTime != null">
  266. `update_time` = #{record.updateTime},
  267. </if>
  268. <if test="record.updateAdminId != null">
  269. `update_admin_id` = #{record.updateAdminId},
  270. </if>
  271. </trim>
  272. <include refid="whereCondition" />
  273. </update>
  274. <!--按照主键更新记录中不为空的字段-->
  275. <update id="updateByPrimaryKeySelective">
  276. UPDATE `goods_label`
  277. <trim prefix="SET" suffixOverrides=",">
  278. <if test="webSite != null">
  279. `web_site` = #{webSite},
  280. </if>
  281. <if test="labelName != null">
  282. `label_name` = #{labelName},
  283. </if>
  284. <if test="description != null">
  285. `description` = #{description},
  286. </if>
  287. <if test="sort != null">
  288. `sort` = #{sort},
  289. </if>
  290. <if test="createTime != null">
  291. `create_time` = #{createTime},
  292. </if>
  293. <if test="createAdminId != null">
  294. `create_admin_id` = #{createAdminId},
  295. </if>
  296. <if test="updateTime != null">
  297. `update_time` = #{updateTime},
  298. </if>
  299. <if test="updateAdminId != null">
  300. `update_admin_id` = #{updateAdminId},
  301. </if>
  302. </trim>
  303. WHERE `label_id` = #{labelId}
  304. </update>
  305. </mapper>