1
0

CategoryDao.xml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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}
  68. <if test="merchSn != null and merchSn.trim() != ''">
  69. AND merch_sn = #{merchSn}
  70. </if> and is_show = 1
  71. </select>
  72. <select id="queryList" resultType="com.kmall.admin.entity.CategoryEntity">
  73. select
  74. `id`,
  75. `name`,
  76. `store_id`,
  77. `merch_sn`,
  78. `keywords`,
  79. `front_desc`,
  80. `parent_id`,
  81. `sort_order`,
  82. `show_index`,
  83. `is_show`,
  84. `banner_url`,
  85. `icon_url`,
  86. `img_url`,
  87. `wap_banner_url`,
  88. `level`,
  89. `type`,
  90. `front_name`,
  91. `is_show` as `show`
  92. from mall_category
  93. WHERE 1=1
  94. <if test="storeId != null and storeId != ''">
  95. AND store_id = #{storeId}
  96. </if>
  97. <if test="merchSn != null and merchSn.trim() != ''">
  98. AND merch_sn = #{merchSn}
  99. </if>
  100. <if test="name != null and name.trim() != ''">
  101. AND `name` LIKE concat('%',#{name},'%')
  102. </if>
  103. <if test="parentId != null and parentId != ''">
  104. AND `parent_id` = #{parentId}
  105. </if>
  106. <if test="isShow != null and isShow != ''">
  107. AND `is_show` = #{isShow}
  108. </if>
  109. <if test="isL2 != null and isL2 != ''">
  110. AND `parent_id` != #{isL2}
  111. </if>
  112. <choose>
  113. <when test="sidx != null and sidx.trim() != ''">
  114. order by ${sidx} ${order}
  115. </when>
  116. <otherwise>
  117. order by sort_order
  118. </otherwise>
  119. </choose>
  120. <if test="offset != null and limit != null">
  121. limit #{offset}, #{limit}
  122. </if>
  123. </select>
  124. <select id="queryTotal" resultType="int">
  125. select count(*) from mall_category
  126. WHERE 1=1
  127. <if test="storeId != null and storeId != ''">
  128. AND store_id = #{storeId}
  129. </if>
  130. <if test="merchSn != null and merchSn.trim() != ''">
  131. AND merch_sn = #{merchSn}
  132. </if>
  133. <if test="name != null and name.trim() != ''">
  134. AND `name` LIKE concat('%',#{name},'%')
  135. </if>
  136. <if test="parentId != null and parentId != ''">
  137. AND `parent_id` = #{parentId}
  138. </if>
  139. <if test="isShow != null and isShow != ''">
  140. AND `is_show` = #{isShow}
  141. </if>
  142. <if test="isL2 != null and isL2 != ''">
  143. AND `parent_id` != #{isL2}
  144. </if>
  145. </select>
  146. <insert id="save" parameterType="com.kmall.admin.entity.CategoryEntity">
  147. insert into mall_category(
  148. `id`,
  149. `name`,
  150. `store_id`,
  151. `merch_sn`,
  152. `keywords`,
  153. `front_desc`,
  154. `parent_id`,
  155. `sort_order`,
  156. `show_index`,
  157. `is_show`,
  158. `banner_url`,
  159. `icon_url`,
  160. `img_url`,
  161. `wap_banner_url`,
  162. `level`,
  163. `type`,
  164. `front_name`)
  165. values(
  166. #{id},
  167. #{name},
  168. #{storeId},
  169. #{merchSn},
  170. #{keywords},
  171. #{frontDesc},
  172. #{parentId},
  173. #{sortOrder},
  174. #{showIndex},
  175. #{isShow},
  176. #{bannerUrl},
  177. #{iconUrl},
  178. #{imgUrl},
  179. #{wapBannerUrl},
  180. #{level},
  181. #{type},
  182. #{frontName})
  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. </set>
  204. where id = #{id}
  205. </update>
  206. <delete id="delete">
  207. delete from mall_category where id = #{value}
  208. </delete>
  209. <delete id="deleteBatch">
  210. delete from mall_category where id in
  211. <foreach item="id" collection="array" open="(" separator="," close=")">
  212. #{id}
  213. </foreach>
  214. </delete>
  215. </mapper>