BrandDao.xml 7.8 KB

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