1
0

BrandDao.xml 9.7 KB

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