ApiCategoryMapper.xml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. <choose>
  53. <when test="sidx != null and sidx.trim() != ''">
  54. order by ${sidx} ${order}
  55. </when>
  56. <otherwise>
  57. order by id asc
  58. </otherwise>
  59. </choose>
  60. <if test="offset != null and limit != null">
  61. limit #{offset}, #{limit}
  62. </if>
  63. </select>
  64. <select id="queryTotal" resultType="int">
  65. select count(*) from mall_category
  66. </select>
  67. <insert id="save" parameterType="com.kmall.api.entity.CategoryVo">
  68. insert into mall_category
  69. (
  70. `id`,
  71. `name`,
  72. `keywords`,
  73. `front_desc`,
  74. `parent_id`,
  75. `sort_order`,
  76. `show_index`,
  77. `is_show`,
  78. `banner_url`,
  79. `icon_url`,
  80. `img_url`,
  81. `wap_banner_url`,
  82. `level`,
  83. `type`,
  84. `front_name`
  85. )
  86. values
  87. (
  88. #{id},
  89. #{name},
  90. #{keywords},
  91. #{front_desc},
  92. #{parent_id},
  93. #{sort_order},
  94. #{show_index},
  95. #{is_show},
  96. #{banner_url},
  97. #{icon_url},
  98. #{img_url},
  99. #{wap_banner_url},
  100. #{level},
  101. #{type},
  102. #{front_name}
  103. )
  104. </insert>
  105. <update id="update" parameterType="com.kmall.api.entity.CategoryVo">
  106. update mall_category
  107. <set>
  108. <if test="name != null">`name` = #{name},</if>
  109. <if test="keywords != null">`keywords` = #{keywords},</if>
  110. <if test="front_desc != null">`front_desc` = #{front_desc},</if>
  111. <if test="parent_id != null">`parent_id` = #{parent_id},</if>
  112. <if test="sort_order != null">`sort_order` = #{sort_order},</if>
  113. <if test="show_index != null">`show_index` = #{show_index},</if>
  114. <if test="is_show != null">`is_show` = #{is_show},</if>
  115. <if test="banner_url != null">`banner_url` = #{banner_url},</if>
  116. <if test="icon_url != null">`icon_url` = #{icon_url},</if>
  117. <if test="img_url != null">`img_url` = #{img_url},</if>
  118. <if test="wap_banner_url != null">`wap_banner_url` = #{wap_banner_url},</if>
  119. <if test="level != null">`level` = #{level},</if>
  120. <if test="type != null">`type` = #{type},</if>
  121. <if test="front_name != null">`front_name` = #{front_name}</if>
  122. </set>
  123. where id = #{id}
  124. </update>
  125. <select id="queryListByParentId" resultMap="categoryMap">
  126. select
  127. <if test="fields != null and fields != ''">
  128. ${fields}
  129. </if>
  130. <if test="fields == null or fields == ''">
  131. *
  132. </if>
  133. from mall_category
  134. where 1 = 1 and is_show = 1
  135. <if test="parent_id != null and parent_id != null">
  136. and FIND_IN_SET(id, getCategoryChildLst(#{parent_id})) and id !=#{parent_id}
  137. </if>
  138. <if test="notName != null and notName != null">
  139. and 'name' != #{notName}
  140. </if>
  141. <if test="store_id != null and store_id != null">
  142. and store_id = #{store_id}
  143. </if>
  144. <if test="ids != null and ids.size > 0">
  145. and id in
  146. <foreach item="item" collection="ids" open="(" separator="," close=")">
  147. #{item}
  148. </foreach>
  149. </if>
  150. <choose>
  151. <when test="sidx != null and sidx.trim() != ''">
  152. order by ${sidx} ${order}
  153. </when>
  154. <otherwise>
  155. order by id asc
  156. </otherwise>
  157. </choose>
  158. <if test="offset != null and limit != null">
  159. limit #{offset}, #{limit}
  160. </if>
  161. </select>
  162. </mapper>