CategoryDao.xml 5.9 KB

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