CategoryDao.xml 7.0 KB

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