CategoryDao.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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="name != null and name.trim() != ''">
  111. AND b.name LIKE concat('%',#{name},'%')
  112. </if>
  113. <if test="parentId != null and parentId != ''">
  114. AND `parent_id` = #{parentId}
  115. </if>
  116. <if test="isShow != null and isShow != ''">
  117. AND b.is_show = #{isShow}
  118. </if>
  119. <if test="isL2 != null and isL2 != ''">
  120. AND `parent_id` != #{isL2}
  121. </if>
  122. <choose>
  123. <when test="sidx != null and sidx.trim() != ''">
  124. order by ${sidx} ${order}
  125. </when>
  126. <otherwise>
  127. order by b.sort_order
  128. </otherwise>
  129. </choose>
  130. <if test="offset != null and limit != null">
  131. limit #{offset}, #{limit}
  132. </if>
  133. </select>
  134. <select id="queryTotal" resultType="int">
  135. select count(*) from mall_category
  136. WHERE 1=1
  137. <if test="storeId != null and storeId != ''">
  138. AND store_id = #{storeId}
  139. </if>
  140. <if test="merchSn != null and merchSn.trim() != ''">
  141. AND merch_sn = #{merchSn}
  142. </if>
  143. <if test="name != null and name.trim() != ''">
  144. AND `name` LIKE concat('%',#{name},'%')
  145. </if>
  146. <if test="parentId != null and parentId != ''">
  147. AND `parent_id` = #{parentId}
  148. </if>
  149. <if test="isShow != null and isShow != ''">
  150. AND `is_show` = #{isShow}
  151. </if>
  152. <if test="isL2 != null and isL2 != ''">
  153. AND `parent_id` != #{isL2}
  154. </if>
  155. </select>
  156. <insert id="save" parameterType="com.kmall.admin.entity.CategoryEntity">
  157. insert into mall_category(
  158. `id`,
  159. `name`,
  160. `store_id`,
  161. `merch_sn`,
  162. `keywords`,
  163. `front_desc`,
  164. `parent_id`,
  165. `sort_order`,
  166. `show_index`,
  167. `is_show`,
  168. `banner_url`,
  169. `icon_url`,
  170. `img_url`,
  171. `wap_banner_url`,
  172. `level`,
  173. `type`,
  174. `front_name`)
  175. values(
  176. #{id},
  177. #{name},
  178. #{storeId},
  179. #{merchSn},
  180. #{keywords},
  181. #{frontDesc},
  182. #{parentId},
  183. #{sortOrder},
  184. #{showIndex},
  185. #{isShow},
  186. #{bannerUrl},
  187. #{iconUrl},
  188. #{imgUrl},
  189. #{wapBannerUrl},
  190. #{level},
  191. #{type},
  192. #{frontName})
  193. </insert>
  194. <update id="update" parameterType="com.kmall.admin.entity.CategoryEntity">
  195. update mall_category
  196. <set>
  197. <if test="name != null">`name` = #{name}, </if>
  198. <if test="storeId != null">`store_id` = #{storeId}, </if>
  199. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  200. <if test="keywords != null">`keywords` = #{keywords}, </if>
  201. <if test="frontDesc != null">`front_desc` = #{frontDesc}, </if>
  202. <if test="parentId != null">`parent_id` = #{parentId}, </if>
  203. <if test="sortOrder != null">`sort_order` = #{sortOrder}, </if>
  204. <if test="showIndex != null">`show_index` = #{showIndex}, </if>
  205. <if test="isShow != null">`is_show` = #{isShow}, </if>
  206. <if test="bannerUrl != null">`banner_url` = #{bannerUrl}, </if>
  207. <if test="iconUrl != null">`icon_url` = #{iconUrl}, </if>
  208. <if test="imgUrl != null">`img_url` = #{imgUrl}, </if>
  209. <if test="wapBannerUrl != null">`wap_banner_url` = #{wapBannerUrl}, </if>
  210. <if test="level != null">`level` = #{level}, </if>
  211. <if test="type != null">`type` = #{type}, </if>
  212. <if test="frontName != null">`front_name` = #{frontName}</if>
  213. </set>
  214. where id = #{id}
  215. </update>
  216. <delete id="delete">
  217. delete from mall_category where id = #{value}
  218. </delete>
  219. <delete id="deleteBatch">
  220. delete from mall_category where id in
  221. <foreach item="id" collection="array" open="(" separator="," close=")">
  222. #{id}
  223. </foreach>
  224. </delete>
  225. </mapper>