GoodsRelatedTemplateReadMapper.xml 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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.read.goods.GoodsRelatedTemplateReadMapper">
  4. <resultMap id="resultMap" type="com.slodon.b2b2c.goods.pojo.GoodsRelatedTemplate">
  5. <id column="template_id" property="templateId" />
  6. <result column="channel" property="channel" />
  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="pkWhere">
  15. WHERE `template_id` = #{primaryKey}
  16. </sql>
  17. <!--操作条件-->
  18. <sql id="whereCondition">
  19. <if test="example != null">
  20. <trim prefix="WHERE" prefixOverrides="AND|OR">
  21. <if test="example.templateIdNotEquals != null">
  22. AND `template_id` != #{example.templateIdNotEquals}
  23. </if>
  24. <if test="example.templateIdIn != null">
  25. AND `template_id` in (${example.templateIdIn})
  26. </if>
  27. <if test="example.channel != null">
  28. AND `channel` = #{example.channel}
  29. </if>
  30. <if test="example.templateName != null">
  31. AND `template_name` = #{example.templateName}
  32. </if>
  33. <if test="example.templateNameLike != null">
  34. AND `template_name` like concat('%',#{example.templateNameLike},'%')
  35. </if>
  36. <if test="example.templatePosition != null">
  37. AND `template_position` = #{example.templatePosition}
  38. </if>
  39. <if test="example.storeId != null">
  40. AND `store_id` = #{example.storeId}
  41. </if>
  42. <if test="example.createVendorId != null">
  43. AND `create_vendor_id` = #{example.createVendorId}
  44. </if>
  45. <if test="example.templateContent != null">
  46. AND `template_content` = #{example.templateContent}
  47. </if>
  48. <if test="example.templateContentLike != null">
  49. AND `template_content` like concat('%',#{example.templateContentLike},'%')
  50. </if>
  51. </trim>
  52. </if>
  53. </sql>
  54. <!--排序条件-->
  55. <sql id="orderBy">
  56. ORDER BY `template_id` DESC
  57. </sql>
  58. <sql id="orderByOther">
  59. order by ${example.orderBy}
  60. </sql>
  61. <!--分组条件-->
  62. <sql id="groupBy">
  63. group by ${example.groupBy}
  64. </sql>
  65. <!--分页条件-->
  66. <sql id="limit">
  67. <if test="size != null and size &gt; 0">
  68. limit #{startRow},#{size}
  69. </if>
  70. </sql>
  71. <!--查询符合条件的记录数-->
  72. <select id="countByExample" parameterType="com.slodon.b2b2c.goods.example.GoodsRelatedTemplateExample" resultType="java.lang.Integer">
  73. SELECT
  74. COUNT(*)
  75. FROM `goods_related_template`
  76. <include refid="whereCondition" />
  77. </select>
  78. <!--根据主键查询记录-->
  79. <select id="getByPrimaryKey" resultMap="resultMap">
  80. SELECT
  81. *
  82. FROM `goods_related_template`
  83. <include refid="pkWhere" />
  84. </select>
  85. <!--查询符合条件的记录(所有字段)-->
  86. <select id="listByExample" resultMap="resultMap">
  87. SELECT
  88. *
  89. FROM `goods_related_template`
  90. <include refid="whereCondition" />
  91. <if test="example.groupBy != null">
  92. <include refid="groupBy" />
  93. </if>
  94. <choose>
  95. <when test="example.orderBy != null">
  96. <include refid="orderByOther" />
  97. </when>
  98. <otherwise>
  99. <include refid="orderBy" />
  100. </otherwise>
  101. </choose>
  102. </select>
  103. <!--分页查询符合条件的记录(所有字段)-->
  104. <select id="listPageByExample" resultMap="resultMap">
  105. SELECT
  106. *
  107. FROM `goods_related_template`
  108. <include refid="whereCondition" />
  109. <if test="example.groupBy != null">
  110. <include refid="groupBy" />
  111. </if>
  112. <choose>
  113. <when test="example.orderBy != null">
  114. <include refid="orderByOther" />
  115. </when>
  116. <otherwise>
  117. <include refid="orderBy" />
  118. </otherwise>
  119. </choose>
  120. <include refid="limit" />
  121. </select>
  122. <!--查询符合条件的记录(指定字段)-->
  123. <select id="listFieldsByExample" resultMap="resultMap">
  124. SELECT
  125. ${fields}
  126. FROM `goods_related_template`
  127. <include refid="whereCondition" />
  128. <if test="example.groupBy != null">
  129. <include refid="groupBy" />
  130. </if>
  131. <choose>
  132. <when test="example.orderBy != null">
  133. <include refid="orderByOther" />
  134. </when>
  135. <otherwise>
  136. <include refid="orderBy" />
  137. </otherwise>
  138. </choose>
  139. </select>
  140. <!--分页查询符合条件的记录(指定字段)-->
  141. <select id="listFieldsPageByExample" resultMap="resultMap">
  142. SELECT
  143. ${fields}
  144. FROM `goods_related_template`
  145. <include refid="whereCondition" />
  146. <if test="example.groupBy != null">
  147. <include refid="groupBy" />
  148. </if>
  149. <choose>
  150. <when test="example.orderBy != null">
  151. <include refid="orderByOther" />
  152. </when>
  153. <otherwise>
  154. <include refid="orderBy" />
  155. </otherwise>
  156. </choose>
  157. <include refid="limit" />
  158. </select>
  159. </mapper>