BrandDao.xml 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  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="name != null and name.trim() != ''">
  114. AND name LIKE concat('%',#{name},'%')
  115. </if>
  116. <choose>
  117. <when test="sidx != null and sidx.trim() != ''">
  118. order by ${sidx} ${order}
  119. </when>
  120. <otherwise>
  121. order by b.id desc
  122. </otherwise>
  123. </choose>
  124. <if test="offset != null and limit != null">
  125. limit #{offset}, #{limit}
  126. </if>
  127. </select>
  128. <select id="queryTotal" resultType="int">
  129. select count(*) from mall_brand b
  130. left join mall_store s on b.store_id = s.id
  131. left join mall_merch m on b.merch_sn = m.merch_sn
  132. LEFT JOIN mall_category cg ON b.category_id = cg.id
  133. WHERE 1=1
  134. <if test="categoryId != null and categoryId != ''">
  135. AND b.category_id = #{categoryId}
  136. </if>
  137. <if test="storeId != null and storeId != ''">
  138. AND b.store_id = #{storeId}
  139. </if>
  140. <if test="merchSn != null and merchSn.trim() != ''">
  141. AND b.merch_sn = #{merchSn}
  142. </if>
  143. <if test="name != null and name.trim() != ''">
  144. AND name LIKE concat('%',#{name},'%')
  145. </if>
  146. </select>
  147. <insert id="save" parameterType="com.kmall.admin.entity.BrandEntity" useGeneratedKeys="true" keyProperty="id">
  148. insert into mall_brand(
  149. `name`,
  150. `store_id`,
  151. `merch_sn`,
  152. `list_pic_url`,
  153. `simple_desc`,
  154. `pic_url`,
  155. `sort_order`,
  156. `is_show`,
  157. `floor_price`,
  158. `app_list_pic_url`,
  159. `is_new`,
  160. `new_pic_url`,
  161. `new_sort_order`,
  162. category_id)
  163. values(
  164. #{name},
  165. #{storeId},
  166. #{merchSn},
  167. #{listPicUrl},
  168. #{simpleDesc},
  169. #{picUrl},
  170. #{sortOrder},
  171. #{isShow},
  172. #{floorPrice},
  173. #{appListPicUrl},
  174. #{isNew},
  175. #{newPicUrl},
  176. #{newSortOrder},
  177. #{categoryId})
  178. </insert>
  179. <update id="update" parameterType="com.kmall.admin.entity.BrandEntity">
  180. update mall_brand
  181. <set>
  182. <if test="name != null">`name` = #{name},</if>
  183. <if test="storeId != null">`store_id` = #{storeId}, </if>
  184. <if test="merchSn != null">`merch_sn` = #{merchSn}, </if>
  185. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl},</if>
  186. <if test="simpleDesc != null">`simple_desc` = #{simpleDesc},</if>
  187. <if test="picUrl != null">`pic_url` = #{picUrl},</if>
  188. <if test="sortOrder != null">`sort_order` = #{sortOrder},</if>
  189. <if test="isShow != null">`is_show` = #{isShow},</if>
  190. <if test="floorPrice != null">`floor_price` = #{floorPrice},</if>
  191. <if test="appListPicUrl != null">`app_list_pic_url` = #{appListPicUrl},</if>
  192. <if test="isNew != null">`is_new` = #{isNew},</if>
  193. <if test="newPicUrl != null">`new_pic_url` = #{newPicUrl},</if>
  194. <if test="categoryId != null">`category_id` = #{categoryId},</if>
  195. <if test="newSortOrder != null">`new_sort_order` = #{newSortOrder}</if>
  196. </set>
  197. where id = #{id}
  198. </update>
  199. <delete id="delete">
  200. delete from mall_brand where id = #{value}
  201. </delete>
  202. <delete id="deleteBatch">
  203. delete from mall_brand where id in
  204. <foreach item="id" collection="array" open="(" separator="," close=")">
  205. #{id}
  206. </foreach>
  207. </delete>
  208. </mapper>