1
0

BrandDao.xml 7.3 KB

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