GoodsRelatedTemplateWriteMapper.xml 8.6 KB

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