CategoryDao.xml 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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. from mall_category b
  100. WHERE 1=1
  101. <if test="categoryName != null and categoryName.trim() != ''">
  102. AND b.name LIKE concat('%',#{categoryName},'%')
  103. </if>
  104. <if test="parentId != null and parentId != ''">
  105. AND `parent_id` = #{parentId}
  106. </if>
  107. <if test="isShow != null and isShow != ''">
  108. AND b.is_show = #{isShow}
  109. </if>
  110. <if test="isL2 != null and isL2 != ''">
  111. AND `parent_id` != #{isL2}
  112. </if>
  113. <if test="share != null and share != ''">
  114. AND `share` = #{share}
  115. </if>
  116. <choose>
  117. <when test="sidx != null and sidx.trim() != ''">
  118. order by ${sidx} ${order}
  119. </when>
  120. <otherwise>
  121. order by b.sort_order
  122. </otherwise>
  123. </choose>
  124. <if test="offset != null and limit != null">
  125. limit #{offset}, #{limit}
  126. </if>
  127. </select>
  128. <select id="queryTotal" resultType="int">
  129. select count(*) from mall_category b
  130. WHERE 1=1
  131. <if test="categoryName != null and categoryName.trim() != ''">
  132. AND b.name LIKE concat('%',#{categoryName},'%')
  133. </if>
  134. <if test="parentId != null and parentId != ''">
  135. AND b.`parent_id` = #{parentId}
  136. </if>
  137. <if test="isShow != null and isShow != ''">
  138. AND b.`is_show` = #{isShow}
  139. </if>
  140. <if test="isL2 != null and isL2 != ''">
  141. AND b.`parent_id` != #{isL2}
  142. </if>
  143. </select>
  144. <insert id="save" parameterType="com.kmall.admin.entity.CategoryEntity" useGeneratedKeys="true" keyProperty="id">
  145. insert into mall_category(
  146. `id`,
  147. `name`,
  148. `store_id`,
  149. `merch_sn`,
  150. `keywords`,
  151. `front_desc`,
  152. `parent_id`,
  153. `sort_order`,
  154. `show_index`,
  155. `is_show`,
  156. `banner_url`,
  157. `icon_url`,
  158. `img_url`,
  159. `wap_banner_url`,
  160. `level`,
  161. `type`,
  162. `front_name`,
  163. `share`)
  164. values(
  165. #{id},
  166. #{name},
  167. #{storeId},
  168. #{merchSn},
  169. #{keywords},
  170. #{frontDesc},
  171. #{parentId},
  172. #{sortOrder},
  173. #{showIndex},
  174. #{isShow},
  175. #{bannerUrl},
  176. #{iconUrl},
  177. #{imgUrl},
  178. #{wapBannerUrl},
  179. #{level},
  180. #{type},
  181. #{frontName},
  182. #{share})
  183. </insert>
  184. <update id="update" parameterType="com.kmall.admin.entity.CategoryEntity">
  185. update mall_category
  186. <set>
  187. <if test="name != null">`name` = #{name}, </if>
  188. <if test="storeId != null">`store_id` = #{storeId}, </if>
  189. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  190. <if test="keywords != null">`keywords` = #{keywords}, </if>
  191. <if test="frontDesc != null">`front_desc` = #{frontDesc}, </if>
  192. <if test="parentId != null">`parent_id` = #{parentId}, </if>
  193. <if test="sortOrder != null">`sort_order` = #{sortOrder}, </if>
  194. <if test="showIndex != null">`show_index` = #{showIndex}, </if>
  195. <if test="isShow != null">`is_show` = #{isShow}, </if>
  196. <if test="bannerUrl != null">`banner_url` = #{bannerUrl}, </if>
  197. <if test="iconUrl != null">`icon_url` = #{iconUrl}, </if>
  198. <if test="imgUrl != null">`img_url` = #{imgUrl}, </if>
  199. <if test="wapBannerUrl != null">`wap_banner_url` = #{wapBannerUrl}, </if>
  200. <if test="level != null">`level` = #{level}, </if>
  201. <if test="type != null">`type` = #{type}, </if>
  202. <if test="frontName != null">`front_name` = #{frontName}</if>
  203. <if test="share != null">`share` = #{share}</if>
  204. </set>
  205. where id = #{id}
  206. </update>
  207. <delete id="delete">
  208. delete from mall_category where id = #{value}
  209. </delete>
  210. <delete id="deleteBatch">
  211. delete from mall_category where id in
  212. <foreach item="id" collection="array" open="(" separator="," close=")">
  213. #{id}
  214. </foreach>
  215. </delete>
  216. <select id="queryByName" resultType="com.kmall.admin.entity.CategoryEntity">
  217. select
  218. `id`,
  219. `name`,
  220. `store_id`,
  221. `merch_sn`,
  222. `keywords`,
  223. `front_desc`,
  224. `parent_id`,
  225. `sort_order`,
  226. `show_index`,
  227. `is_show`,
  228. `banner_url`,
  229. `icon_url`,
  230. `img_url`,
  231. `wap_banner_url`,
  232. `level`,
  233. `type`,
  234. `front_name`,
  235. `is_show` as `show`
  236. from mall_category
  237. where name = #{categoryName}
  238. and is_show = 1
  239. </select>
  240. <select id="queryCategoryRulesDetil" parameterType="java.lang.Long" resultType="com.kmall.admin.entity.vip.Mall2DetilEntity">
  241. select
  242. mc.id,
  243. mc.name as rulesName
  244. from mall_category mc
  245. where mc.is_show = 1 AND mc.points_rules_id = #{id}
  246. </select>
  247. <select id="queryCategoryDetilTotal" parameterType="java.lang.Long" resultType="java.lang.Integer">
  248. select count(*) from mall_category
  249. where is_show = 1 AND points_rules_id = #{id}
  250. </select>
  251. <update id="updateCategoryRulesDetil">
  252. update mall_category set points_rules_id=null where id in
  253. <foreach item="id" collection="array" open="(" separator="," close=")">
  254. #{id}
  255. </foreach>
  256. </update>
  257. <select id="queryObjectCategoryByName" parameterType="java.lang.String" resultType="java.lang.Long">
  258. select
  259. mc.id
  260. from mall_category mc
  261. where mc.is_show = 1 AND mc.name = #{trim}
  262. </select>
  263. <!--批量修改-->
  264. <update id="updateObjectCategory" parameterType="list">
  265. update mall_category
  266. <trim prefix="set" suffixOverrides=",">
  267. <trim prefix="points_rules_id =case" suffix="end,">
  268. <foreach collection="list" item="item" index="index">
  269. <if test="item.mkaId!=null">
  270. when id=#{item.rulesId}
  271. then #{item.mkaId}
  272. </if>
  273. </foreach>
  274. </trim>
  275. </trim>
  276. where id in
  277. <foreach collection="list" item="item" index="index" separator="," open="(" close=")">
  278. #{item.rulesId}
  279. </foreach>
  280. </update>
  281. <!-- 根据父id查询子对象 -->
  282. <select id="queryListByParentId" resultType="com.kmall.admin.entity.CategoryEntity">
  283. select
  284. `id`,
  285. `name`,
  286. `store_id`,
  287. `merch_sn`,
  288. `keywords`,
  289. `front_desc`,
  290. `parent_id`,
  291. `sort_order`,
  292. `show_index`,
  293. `banner_url`,
  294. `icon_url`,
  295. `img_url`,
  296. `wap_banner_url`,
  297. `level`,
  298. `type`,
  299. `front_name`,
  300. `is_show` as `show`
  301. from mall_category
  302. where `parent_id` in
  303. <foreach collection="list" item="id" index="index" open="(" close=")" separator=",">
  304. #{id}
  305. </foreach>
  306. </select>
  307. <select id="queryExistByNameAndLevel" resultType="com.kmall.admin.dto.CategoryDto">
  308. select
  309. id
  310. from mall_category
  311. where `name` = #{name} and `level` = #{level}
  312. limit 1
  313. </select>
  314. </mapper>