BrandDao.xml 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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. b.`id`,
  47. b.`name`,
  48. b.`store_id`,
  49. b.`merch_sn`,
  50. b.`list_pic_url`,
  51. b.`simple_desc`,
  52. b.`pic_url`,
  53. b.`sort_order`,
  54. b.`is_show`,
  55. b.`floor_price`,
  56. b.`app_list_pic_url`,
  57. b.`is_new`,
  58. b.`new_pic_url`,
  59. b.`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. and category_id=#{categoryId}
  68. <if test="merchSn != null and merchSn.trim() != ''">
  69. AND b.merch_sn = #{merchSn}
  70. </if>
  71. </select>
  72. <select id="queryBrandByBrandNameAndStoreId" resultType="com.kmall.admin.entity.BrandEntity">
  73. select
  74. `id`,
  75. `name`,
  76. `store_id`,
  77. `merch_sn`,
  78. `list_pic_url`,
  79. `simple_desc`,
  80. `pic_url`,
  81. `sort_order`,
  82. `is_show`,
  83. `floor_price`,
  84. `app_list_pic_url`,
  85. `is_new`,
  86. `new_pic_url`,
  87. `new_sort_order`,
  88. b.category_id
  89. from mall_brand b
  90. where 1=1
  91. <if test="storeId != null and storeId != ''">
  92. AND b.store_id = #{storeId}
  93. </if>
  94. <if test="brandName != null">
  95. AND b.name = #{brandName}
  96. </if>
  97. </select>
  98. <select id="queryObjectByStoreId" resultType="com.kmall.admin.entity.BrandEntity">
  99. select *
  100. from mall_brand
  101. where store_id = #{storeId}
  102. </select>
  103. <select id="queryList" resultType="com.kmall.admin.entity.BrandEntity">
  104. select
  105. b.id,
  106. b.name,
  107. b.store_id,
  108. b.merch_sn,
  109. `list_pic_url`,
  110. `simple_desc`,
  111. `pic_url`,
  112. b.sort_order,
  113. b.is_show,
  114. `floor_price`,
  115. `app_list_pic_url`,
  116. b.is_new,
  117. `new_pic_url`,
  118. b.new_sort_order,
  119. m.merch_name merchName,
  120. cg.name categoryName,
  121. b.category_id
  122. from mall_brand b
  123. left join mall_merch m on b.merch_sn = m.merch_sn
  124. LEFT JOIN mall_category cg ON b.category_id = cg.id
  125. WHERE 1=1
  126. <if test="categoryId != null and categoryId != ''">
  127. AND b.category_id = #{categoryId}
  128. </if>
  129. <if test="storeId != null and storeId != ''">
  130. AND b.store_id = #{storeId}
  131. </if>
  132. <if test="merchSn != null and merchSn.trim() != ''">
  133. AND b.merch_sn = #{merchSn}
  134. </if>
  135. <if test="name != null and name.trim() != ''">
  136. AND b.name LIKE concat('%',#{name},'%')
  137. </if>
  138. <choose>
  139. <when test="sidx != null and sidx.trim() != ''">
  140. order by ${sidx} ${order}
  141. </when>
  142. <otherwise>
  143. order by b.id desc
  144. </otherwise>
  145. </choose>
  146. <if test="offset != null and limit != null">
  147. limit #{offset}, #{limit}
  148. </if>
  149. </select>
  150. <select id="queryTotal" resultType="int">
  151. select count(*) from mall_brand b
  152. left join mall_store s on b.store_id = s.id
  153. left join mall_merch m on b.merch_sn = m.merch_sn
  154. LEFT JOIN mall_category cg ON b.category_id = cg.id
  155. WHERE 1=1
  156. <if test="categoryId != null and categoryId != ''">
  157. AND b.category_id = #{categoryId}
  158. </if>
  159. <if test="storeId != null and storeId != ''">
  160. AND b.store_id = #{storeId}
  161. </if>
  162. <if test="merchSn != null and merchSn.trim() != ''">
  163. AND b.merch_sn = #{merchSn}
  164. </if>
  165. <if test="thirdPartyMerchCode != null and thirdPartyMerchCode.trim() != ''">
  166. AND s.third_party_merch_code = #{thirdPartyMerchCode}
  167. </if>
  168. <if test="name != null and name.trim() != ''">
  169. AND b.name LIKE concat('%',#{name},'%')
  170. </if>
  171. </select>
  172. <insert id="save" parameterType="com.kmall.admin.entity.BrandEntity" useGeneratedKeys="true" keyProperty="id">
  173. insert into mall_brand(
  174. `name`,
  175. `store_id`,
  176. `merch_sn`,
  177. `list_pic_url`,
  178. `simple_desc`,
  179. `pic_url`,
  180. `sort_order`,
  181. `is_show`,
  182. `floor_price`,
  183. `app_list_pic_url`,
  184. `is_new`,
  185. `new_pic_url`,
  186. `new_sort_order`,
  187. category_id)
  188. values(
  189. #{name},
  190. #{storeId},
  191. #{merchSn},
  192. #{listPicUrl},
  193. #{simpleDesc},
  194. #{picUrl},
  195. #{sortOrder},
  196. #{isShow},
  197. #{floorPrice},
  198. #{appListPicUrl},
  199. #{isNew},
  200. #{newPicUrl},
  201. #{newSortOrder},
  202. #{categoryId})
  203. </insert>
  204. <update id="update" parameterType="com.kmall.admin.entity.BrandEntity">
  205. update mall_brand
  206. <set>
  207. <if test="name != null">`name` = #{name},</if>
  208. <if test="storeId != null">`store_id` = #{storeId}, </if>
  209. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  210. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl},</if>
  211. <if test="simpleDesc != null">`simple_desc` = #{simpleDesc},</if>
  212. <if test="picUrl != null">`pic_url` = #{picUrl},</if>
  213. <if test="sortOrder != null">`sort_order` = #{sortOrder},</if>
  214. <if test="isShow != null">`is_show` = #{isShow},</if>
  215. <if test="floorPrice != null">`floor_price` = #{floorPrice},</if>
  216. <if test="appListPicUrl != null">`app_list_pic_url` = #{appListPicUrl},</if>
  217. <if test="isNew != null">`is_new` = #{isNew},</if>
  218. <if test="newPicUrl != null">`new_pic_url` = #{newPicUrl},</if>
  219. <if test="categoryId != null">`category_id` = #{categoryId},</if>
  220. <if test="newSortOrder != null">`new_sort_order` = #{newSortOrder}</if>
  221. </set>
  222. where id = #{id}
  223. </update>
  224. <delete id="delete">
  225. delete from mall_brand where id = #{value}
  226. </delete>
  227. <delete id="deleteBatch">
  228. delete from mall_brand where id in
  229. <foreach item="id" collection="array" open="(" separator="," close=")">
  230. #{id}
  231. </foreach>
  232. </delete>
  233. <select id="queryBrandName" resultType="java.lang.String">
  234. select brand.name
  235. from
  236. mall_brand brand
  237. left join mall_product_store_rela mr on brand.id = mr.brand_id
  238. left join mall_goods goods on mr.goods_id = goods.id
  239. where
  240. goods.prod_barcode = #{prodBarcode}
  241. and brand.store_id = #{storeId}
  242. </select>
  243. <select id="queryByCategoryIdAndBrandNameAndMerchSn" resultType="com.kmall.admin.entity.BrandEntity">
  244. select *
  245. from mall_brand
  246. where 1=1
  247. <if test="categoryId != null and categoryId != ''">
  248. AND category_id = #{categoryId}
  249. </if>
  250. <if test="merchSn != null and merchSn.trim() != ''">
  251. AND merch_sn = #{merchSn}
  252. </if>
  253. <if test="name != null and name.trim() != ''">
  254. AND `name` = #{name}
  255. </if>
  256. </select>
  257. <select id="queryExportList" resultType="com.kmall.admin.entity.BrandEntity">
  258. select
  259. b.id,
  260. b.name,
  261. b.store_id,
  262. b.merch_sn,
  263. `list_pic_url`,
  264. `simple_desc`,
  265. `pic_url`,
  266. b.sort_order,
  267. b.is_show,
  268. `floor_price`,
  269. `app_list_pic_url`,
  270. b.is_new,
  271. `new_pic_url`,
  272. b.new_sort_order,
  273. m.merch_name merchName,
  274. cg.name categoryName,
  275. b.category_id
  276. from mall_brand b
  277. left join mall_merch m on b.merch_sn = m.merch_sn
  278. LEFT JOIN mall_category cg ON b.category_id = cg.id
  279. WHERE 1=1
  280. <if test="name != null and name.trim() != ''">
  281. AND b.name LIKE concat('%',#{name},'%')
  282. </if>
  283. </select>
  284. </mapper>