ApiCategoryMapper.xml 5.3 KB

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