BrandDao.xml 8.1 KB

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