1
0

CategoryDao.xml 6.8 KB

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