ApiCategoryMapper.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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.kmall.api.dao.ApiCategoryMapper">
  4. <!-- 可根据自己的需求,是否要使用 -->
  5. <resultMap type="com.kmall.api.entity.CategoryVo" id="categoryMap">
  6. <result property="id" column="id"/>
  7. <result property="name" column="name"/>
  8. <result property="keywords" column="keywords"/>
  9. <result property="front_desc" column="front_desc"/>
  10. <result property="parent_id" column="parent_id"/>
  11. <result property="sort_order" column="sort_order"/>
  12. <result property="show_index" column="show_index"/>
  13. <result property="is_show" column="is_show"/>
  14. <result property="banner_url" column="banner_url"/>
  15. <result property="icon_url" column="icon_url"/>
  16. <result property="img_url" column="img_url"/>
  17. <result property="wap_banner_url" column="wap_banner_url"/>
  18. <result property="level" column="level"/>
  19. <result property="type" column="type"/>
  20. <result property="front_name" column="front_name"/>
  21. <result property="merchSn" column="merch_sn"/>
  22. <result property="storeId" column="store_id"/>
  23. </resultMap>
  24. <select id="queryObject" resultMap="categoryMap">
  25. select * from mall_category where id = #{value}
  26. </select>
  27. <select id="queryList" resultMap="categoryMap">
  28. select
  29. <if test="fields != null and fields != ''">
  30. ${fields}
  31. </if>
  32. <if test="fields == null or fields == ''">
  33. *
  34. </if>
  35. from mall_category
  36. where 1 = 1 and (is_show = 1
  37. <if test="parent_id != null and parent_id != null">
  38. and parent_id = #{parent_id}
  39. </if>
  40. <if test="store_id != null and store_id != null">
  41. and store_id = #{store_id}
  42. </if>
  43. <if test="notName != null and notName != null">
  44. and 'name' != #{notName}
  45. </if>
  46. <if test="ids != null and ids.size > 0">
  47. and id in
  48. <foreach item="item" collection="ids" open="(" separator="," close=")">
  49. #{item}
  50. </foreach>
  51. </if>
  52. )
  53. <choose>
  54. <when test="sidx != null and sidx.trim() != ''">
  55. order by ${sidx} ${order}
  56. </when>
  57. <otherwise>
  58. order by id asc
  59. </otherwise>
  60. </choose>
  61. <if test="offset != null and limit != null">
  62. limit #{offset}, #{limit}
  63. </if>
  64. </select>
  65. <select id="queryTotal" resultType="int">
  66. select count(*) from mall_category
  67. </select>
  68. <insert id="save" parameterType="com.kmall.api.entity.CategoryVo">
  69. insert into mall_category
  70. (
  71. `id`,
  72. `name`,
  73. `keywords`,
  74. `front_desc`,
  75. `parent_id`,
  76. `sort_order`,
  77. `show_index`,
  78. `is_show`,
  79. `banner_url`,
  80. `icon_url`,
  81. `img_url`,
  82. `wap_banner_url`,
  83. `level`,
  84. `type`,
  85. `front_name`
  86. )
  87. values
  88. (
  89. #{id},
  90. #{name},
  91. #{keywords},
  92. #{front_desc},
  93. #{parent_id},
  94. #{sort_order},
  95. #{show_index},
  96. #{is_show},
  97. #{banner_url},
  98. #{icon_url},
  99. #{img_url},
  100. #{wap_banner_url},
  101. #{level},
  102. #{type},
  103. #{front_name}
  104. )
  105. </insert>
  106. <update id="update" parameterType="com.kmall.api.entity.CategoryVo">
  107. update mall_category
  108. <set>
  109. <if test="name != null">`name` = #{name},</if>
  110. <if test="keywords != null">`keywords` = #{keywords},</if>
  111. <if test="front_desc != null">`front_desc` = #{front_desc},</if>
  112. <if test="parent_id != null">`parent_id` = #{parent_id},</if>
  113. <if test="sort_order != null">`sort_order` = #{sort_order},</if>
  114. <if test="show_index != null">`show_index` = #{show_index},</if>
  115. <if test="is_show != null">`is_show` = #{is_show},</if>
  116. <if test="banner_url != null">`banner_url` = #{banner_url},</if>
  117. <if test="icon_url != null">`icon_url` = #{icon_url},</if>
  118. <if test="img_url != null">`img_url` = #{img_url},</if>
  119. <if test="wap_banner_url != null">`wap_banner_url` = #{wap_banner_url},</if>
  120. <if test="level != null">`level` = #{level},</if>
  121. <if test="type != null">`type` = #{type},</if>
  122. <if test="front_name != null">`front_name` = #{front_name}</if>
  123. </set>
  124. where id = #{id}
  125. </update>
  126. <select id="queryListByParentId" resultMap="categoryMap">
  127. select
  128. <if test="fields != null and fields != ''">
  129. ${fields}
  130. </if>
  131. <if test="fields == null or fields == ''">
  132. *
  133. </if>
  134. from mall_category
  135. where 1 = 1 and is_show = 1
  136. <if test="parent_id != null and parent_id != null">
  137. and FIND_IN_SET(id, getCategoryChildLst(#{parent_id})) and id !=#{parent_id}
  138. </if>
  139. <if test="notName != null and notName != null">
  140. and 'name' != #{notName}
  141. </if>
  142. <if test="store_id != null and store_id != null">
  143. and store_id = #{store_id}
  144. </if>
  145. <if test="ids != null and ids.size > 0">
  146. and id in
  147. <foreach item="item" collection="ids" open="(" separator="," close=")">
  148. #{item}
  149. </foreach>
  150. </if>
  151. <choose>
  152. <when test="sidx != null and sidx.trim() != ''">
  153. order by ${sidx} ${order}
  154. </when>
  155. <otherwise>
  156. order by id asc
  157. </otherwise>
  158. </choose>
  159. <if test="offset != null and limit != null">
  160. limit #{offset}, #{limit}
  161. </if>
  162. </select>
  163. </mapper>