CategoryDao.xml 4.5 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.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. <choose>
  72. <when test="sidx != null and sidx.trim() != ''">
  73. order by ${sidx} ${order}
  74. </when>
  75. <otherwise>
  76. order by sort_order
  77. </otherwise>
  78. </choose>
  79. <if test="offset != null and limit != null">
  80. limit #{offset}, #{limit}
  81. </if>
  82. </select>
  83. <select id="queryTotal" resultType="int">
  84. select count(*) from mall_category
  85. WHERE 1=1
  86. <if test="name != null and name.trim() != ''">
  87. AND name LIKE concat('%',#{name},'%')
  88. </if>
  89. </select>
  90. <insert id="save" parameterType="com.kmall.admin.entity.CategoryEntity">
  91. insert into mall_category(
  92. `id`,
  93. `name`,
  94. `keywords`,
  95. `front_desc`,
  96. `parent_id`,
  97. `sort_order`,
  98. `show_index`,
  99. `is_show`,
  100. `banner_url`,
  101. `icon_url`,
  102. `img_url`,
  103. `wap_banner_url`,
  104. `level`,
  105. `type`,
  106. `front_name`)
  107. values(
  108. #{id},
  109. #{name},
  110. #{keywords},
  111. #{frontDesc},
  112. #{parentId},
  113. #{sortOrder},
  114. #{showIndex},
  115. #{isShow},
  116. #{bannerUrl},
  117. #{iconUrl},
  118. #{imgUrl},
  119. #{wapBannerUrl},
  120. #{level},
  121. #{type},
  122. #{frontName})
  123. </insert>
  124. <update id="update" parameterType="com.kmall.admin.entity.CategoryEntity">
  125. update mall_category
  126. <set>
  127. <if test="name != null">`name` = #{name}, </if>
  128. <if test="keywords != null">`keywords` = #{keywords}, </if>
  129. <if test="frontDesc != null">`front_desc` = #{frontDesc}, </if>
  130. <if test="parentId != null">`parent_id` = #{parentId}, </if>
  131. <if test="sortOrder != null">`sort_order` = #{sortOrder}, </if>
  132. <if test="showIndex != null">`show_index` = #{showIndex}, </if>
  133. <if test="isShow != null">`is_show` = #{isShow}, </if>
  134. <if test="bannerUrl != null">`banner_url` = #{bannerUrl}, </if>
  135. <if test="iconUrl != null">`icon_url` = #{iconUrl}, </if>
  136. <if test="imgUrl != null">`img_url` = #{imgUrl}, </if>
  137. <if test="wapBannerUrl != null">`wap_banner_url` = #{wapBannerUrl}, </if>
  138. <if test="level != null">`level` = #{level}, </if>
  139. <if test="type != null">`type` = #{type}, </if>
  140. <if test="frontName != null">`front_name` = #{frontName}</if>
  141. </set>
  142. where id = #{id}
  143. </update>
  144. <delete id="delete">
  145. delete from mall_category where id = #{value}
  146. </delete>
  147. <delete id="deleteBatch">
  148. delete from mall_category where id in
  149. <foreach item="id" collection="array" open="(" separator="," close=")">
  150. #{id}
  151. </foreach>
  152. </delete>
  153. </mapper>