CategoryDao.xml 4.8 KB

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