helpArticleReadMapper.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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.cms.HelpArticleReadMapper">
  4. <resultMap id="resultMap" type="com.slodon.b2b2c.seller.pojo.StoreCmsArticle">
  5. <id column="article_id" property="articleId" />
  6. <id column="web_site" property="webSite" />
  7. <result column="category_id" property="categoryId" />
  8. <result column="title" property="title" />
  9. <result column="out_url" property="outUrl" />
  10. <result column="state" property="state" />
  11. <result column="sort" property="sort" />
  12. <result column="create_id" property="createId" />
  13. <result column="create_time" property="createTime" />
  14. <result column="update_time" property="updateTime" />
  15. <result column="content" property="content" />
  16. </resultMap>
  17. <!--按照主键值进行操作-->
  18. <sql id="pkWhere">
  19. WHERE `article_id` = #{primaryKey}
  20. </sql>
  21. <!--操作条件-->
  22. <sql id="whereCondition">
  23. <if test="example != null">
  24. <trim prefix="WHERE" prefixOverrides="AND|OR">
  25. <if test="example.articleIdNotEquals != null">
  26. AND `article_id` != #{example.articleIdNotEquals}
  27. </if>
  28. <if test="example.articleIdIn != null">
  29. AND `article_id` in (${example.articleIdIn})
  30. </if>
  31. <if test="example.webSite != null">
  32. AND `web_site` = #{example.webSite}
  33. </if>
  34. <if test="example.categoryId != null">
  35. AND `category_id` = #{example.categoryId}
  36. </if>
  37. <if test="example.title != null">
  38. AND `title` = #{example.title}
  39. </if>
  40. <if test="example.titleLike != null">
  41. AND `title` like concat('%',#{example.titleLike},'%')
  42. </if>
  43. <if test="example.outUrl != null">
  44. AND `out_url` = #{example.outUrl}
  45. </if>
  46. <if test="example.state != null">
  47. AND `state` = #{example.state}
  48. </if>
  49. <if test="example.sort != null">
  50. AND `sort` = #{example.sort}
  51. </if>
  52. <if test="example.createId != null">
  53. AND `create_id` = #{example.createId}
  54. </if>
  55. <if test="example.createTimeAfter != null">
  56. AND `create_time` <![CDATA[ >= ]]> #{example.createTimeAfter}
  57. </if>
  58. <if test="example.createTimeBefore != null">
  59. AND `create_time` <![CDATA[ <= ]]> #{example.createTimeBefore}
  60. </if>
  61. <if test="example.updateTimeAfter != null">
  62. AND `update_time` <![CDATA[ >= ]]> #{example.updateTimeAfter}
  63. </if>
  64. <if test="example.updateTimeBefore != null">
  65. AND `update_time` <![CDATA[ <= ]]> #{example.updateTimeBefore}
  66. </if>
  67. <if test="example.content != null">
  68. AND `content` = #{example.content}
  69. </if>
  70. <if test="example.contentLike != null">
  71. AND `content` like concat('%',#{example.contentLike},'%')
  72. </if>
  73. <if test="example.searchWord != null">
  74. AND (`title` like concat('%',#{example.searchWord},'%') or `content` like concat('%',#{example.searchWord},'%'))
  75. </if>
  76. </trim>
  77. </if>
  78. </sql>
  79. <!--排序条件-->
  80. <sql id="orderBy">
  81. ORDER BY `sort`
  82. </sql>
  83. <sql id="orderByOther">
  84. order by ${example.orderBy}
  85. </sql>
  86. <!--分组条件-->
  87. <sql id="groupBy">
  88. group by ${example.groupBy}
  89. </sql>
  90. <!--分页条件-->
  91. <sql id="limit">
  92. <if test="size != null and size &gt; 0">
  93. limit #{startRow},#{size}
  94. </if>
  95. </sql>
  96. <!--查询符合条件的记录数-->
  97. <select id="countByExample" parameterType="com.slodon.b2b2c.cms.example.HelpArticleExample" resultType="java.lang.Integer">
  98. SELECT
  99. COUNT(*)
  100. FROM `store_cms_article`
  101. <include refid="whereCondition" />
  102. </select>
  103. <!--根据主键查询记录-->
  104. <select id="getByPrimaryKey" resultMap="resultMap">
  105. SELECT
  106. *
  107. FROM `store_cms_article`
  108. <include refid="pkWhere" />
  109. </select>
  110. <!--查询符合条件的记录(所有字段)-->
  111. <select id="listByExample" resultMap="resultMap">
  112. SELECT
  113. *
  114. FROM `store_cms_article`
  115. <include refid="whereCondition" />
  116. <if test="example.groupBy != null">
  117. <include refid="groupBy" />
  118. </if>
  119. <choose>
  120. <when test="example.orderBy != null">
  121. <include refid="orderByOther" />
  122. </when>
  123. <otherwise>
  124. <include refid="orderBy" />
  125. </otherwise>
  126. </choose>
  127. </select>
  128. <!--分页查询符合条件的记录(所有字段)-->
  129. <select id="listPageByExample" resultMap="resultMap">
  130. SELECT
  131. *
  132. FROM `store_cms_article`
  133. <include refid="whereCondition" />
  134. <if test="example.groupBy != null">
  135. <include refid="groupBy" />
  136. </if>
  137. <choose>
  138. <when test="example.orderBy != null">
  139. <include refid="orderByOther" />
  140. </when>
  141. <otherwise>
  142. <include refid="orderBy" />
  143. </otherwise>
  144. </choose>
  145. <include refid="limit" />
  146. </select>
  147. <!--查询符合条件的记录(指定字段)-->
  148. <select id="listFieldsByExample" resultMap="resultMap">
  149. SELECT
  150. ${fields}
  151. FROM `store_cms_article`
  152. <include refid="whereCondition" />
  153. <if test="example.groupBy != null">
  154. <include refid="groupBy" />
  155. </if>
  156. <choose>
  157. <when test="example.orderBy != null">
  158. <include refid="orderByOther" />
  159. </when>
  160. <otherwise>
  161. <include refid="orderBy" />
  162. </otherwise>
  163. </choose>
  164. </select>
  165. <!--分页查询符合条件的记录(指定字段)-->
  166. <select id="listFieldsPageByExample" resultMap="resultMap">
  167. SELECT
  168. ${fields}
  169. FROM `store_cms_article`
  170. <include refid="whereCondition" />
  171. <if test="example.groupBy != null">
  172. <include refid="groupBy" />
  173. </if>
  174. <choose>
  175. <when test="example.orderBy != null">
  176. <include refid="orderByOther" />
  177. </when>
  178. <otherwise>
  179. <include refid="orderBy" />
  180. </otherwise>
  181. </choose>
  182. <include refid="limit" />
  183. </select>
  184. </mapper>