1
0

GoodsDao.xml 12 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.GoodsDao">
  4. <resultMap type="com.kmall.admin.entity.GoodsEntity" id="goodsMap">
  5. <result property="id" column="id"/>
  6. <result property="categoryId" column="category_id"/>
  7. <result property="goodsSn" column="goods_sn"/>
  8. <result property="name" column="name"/>
  9. <result property="brandId" column="brand_id"/>
  10. <result property="goodsNumber" column="goods_number"/>
  11. <result property="keywords" column="keywords"/>
  12. <result property="goodsBrief" column="goods_brief"/>
  13. <result property="goodsDesc" column="goods_desc"/>
  14. <result property="isOnSale" column="is_on_sale"/>
  15. <result property="addTime" column="add_time"/>
  16. <result property="sortOrder" column="sort_order"/>
  17. <result property="isDelete" column="is_delete"/>
  18. <result property="attributeCategory" column="attribute_category"/>
  19. <result property="counterPrice" column="counter_price"/>
  20. <result property="extraPrice" column="extra_price"/>
  21. <result property="isNew" column="is_new"/>
  22. <result property="goodsUnit" column="goods_unit"/>
  23. <result property="primaryPicUrl" column="primary_pic_url"/>
  24. <result property="listPicUrl" column="list_pic_url"/>
  25. <result property="retailPrice" column="retail_price"/>
  26. <result property="sellVolume" column="sell_volume"/>
  27. <result property="primaryProductId" column="primary_product_id"/>
  28. <result property="unitPrice" column="unit_price"/>
  29. <result property="promotionDesc" column="promotion_desc"/>
  30. <result property="promotionTag" column="promotion_tag"/>
  31. <result property="appExclusivePrice" column="app_exclusive_price"/>
  32. <result property="isAppExclusive" column="is_app_exclusive"/>
  33. <result property="isLimited" column="is_limited"/>
  34. <result property="isHot" column="is_hot"/>
  35. <result property="marketPrice" column="market_price"/>
  36. <result property="goodsType" column="goodsType"/>
  37. <result property="sku" column="sku"/>
  38. <result property="goodsBizType" column="goods_biz_type"/>
  39. <result column="creater_sn" property="createrSn" jdbcType="VARCHAR" />
  40. <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
  41. <result column="moder_sn" property="moderSn" jdbcType="VARCHAR" />
  42. <result column="mod_time" property="modTime" jdbcType="TIMESTAMP" />
  43. <result column="tstm" property="tstm" jdbcType="TIMESTAMP" />
  44. </resultMap>
  45. <select id="queryObject" resultType="com.kmall.admin.entity.GoodsEntity">
  46. SELECT
  47. a.*, CASE
  48. when g.id > 0 then 2 else 0 end as goodsType
  49. FROM
  50. mall_goods a
  51. LEFT JOIN mall_goods_group g ON g.goods_id = a.id
  52. AND g.open_status != 3
  53. WHERE a.id = #{value}
  54. </select>
  55. <select id="queryObjectBySn" resultType="com.kmall.admin.entity.GoodsEntity">
  56. SELECT
  57. a.*, CASE
  58. when g.id > 0 then 2 else 0 end as goodsType
  59. FROM
  60. mall_goods a
  61. LEFT JOIN mall_goods_group g ON g.goods_id = a.id
  62. AND g.open_status != 3
  63. where a.goods_sn = #{goodsSn}
  64. </select>
  65. <select id="queryList" resultType="com.kmall.admin.entity.GoodsEntity">
  66. select
  67. mall_goods.id,
  68. mall_goods.category_id,
  69. mall_goods.goods_sn,
  70. mall_goods.name,
  71. mall_goods.brand_id,
  72. mall_goods.goods_number,
  73. mall_goods.keywords,
  74. mall_goods.goods_brief,
  75. mall_goods.is_on_sale,
  76. mall_goods.add_time,
  77. mall_goods.sort_order,
  78. mall_goods.is_delete,
  79. mall_goods.attribute_category,
  80. mall_goods.counter_price,
  81. mall_goods.extra_price,
  82. mall_goods.is_new,
  83. mall_goods.goods_unit,
  84. mall_goods.primary_pic_url,
  85. mall_goods.list_pic_url,
  86. mall_goods.retail_price,
  87. mall_goods.sell_volume,
  88. mall_goods.primary_product_id,
  89. mall_goods.unit_price,
  90. mall_goods.promotion_desc,
  91. mall_goods.promotion_tag,
  92. mall_goods.app_exclusive_price,
  93. mall_goods.is_app_exclusive,
  94. mall_goods.is_limited,
  95. mall_goods.is_hot,
  96. mall_goods.market_price,
  97. mall_category.name category_name,
  98. mall_attribute_category.name attribute_category_name,
  99. mall_brand.name brand_name,
  100. case when mall_goods_group.id > 0 then 2 else 0 end as goodsType
  101. from mall_goods
  102. LEFT JOIN mall_category
  103. ON mall_goods.category_id = mall_category.id
  104. LEFT JOIN mall_attribute_category ON mall_goods.attribute_category = mall_attribute_category.id
  105. LEFT JOIN mall_brand ON mall_brand.id = mall_goods.brand_id
  106. left join mall_goods_group on mall_goods_group.goods_id = mall_goods.id and mall_goods_group.open_status != 3
  107. WHERE 1=1
  108. <!-- 数据过滤 -->
  109. ${filterSql}
  110. <if test="goodsSn != null and goodsSn != ''">
  111. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  112. </if>
  113. <if test="name != null and name != ''">
  114. AND mall_goods.name LIKE concat('%',#{name},'%')
  115. </if>
  116. <if test="category != null and category != ''">
  117. AND mall_goods.category_id IN (select id from mall_category where parent_id = #{category})
  118. </if>
  119. <if test="categoryTwo != null and categoryTwo != ''">
  120. AND mall_goods.category_id = #{categoryTwo}
  121. </if>
  122. AND mall_goods.is_Delete = #{isDelete}
  123. <choose>
  124. <when test="sidx != null and sidx.trim() != ''">
  125. order by ${sidx} ${order}
  126. </when>
  127. <otherwise>
  128. order by mall_goods.id desc
  129. </otherwise>
  130. </choose>
  131. <if test="offset != null and limit != null">
  132. limit #{offset}, #{limit}
  133. </if>
  134. </select>
  135. <select id="queryTotal" resultType="int">
  136. select count(*) from mall_goods WHERE 1=1
  137. <!-- 数据过滤 -->
  138. ${filterSql}
  139. <if test="goodsSn != null and goodsSn != ''">
  140. AND mall_goods.goods_sn like concat('%',#{goodsSn},'%')
  141. </if>
  142. <if test="name != null and name != ''">
  143. AND name LIKE concat('%',#{name},'%')
  144. </if>
  145. AND mall_goods.is_Delete = #{isDelete}
  146. </select>
  147. <insert id="save" parameterType="com.kmall.admin.entity.GoodsEntity">
  148. insert into mall_goods
  149. (
  150. `id`,
  151. `category_id`,
  152. `goods_sn`,
  153. `name`,
  154. `brand_id`,
  155. `goods_number`,
  156. `keywords`,
  157. `goods_brief`,
  158. `goods_desc`,
  159. `is_on_sale`,
  160. `add_time`,
  161. `sort_order`,
  162. `is_delete`,
  163. `attribute_category`,
  164. `counter_price`,
  165. `extra_price`,
  166. `is_new`,
  167. `goods_unit`,
  168. `primary_pic_url`,
  169. `list_pic_url`,
  170. `retail_price`,
  171. `sell_volume`,
  172. `primary_product_id`,
  173. `unit_price`,
  174. `promotion_desc`,
  175. `promotion_tag`,
  176. `app_exclusive_price`,
  177. `is_app_exclusive`,
  178. `is_limited`,
  179. `is_hot`,
  180. `market_price`,
  181. `sku`,
  182. `goods_biz_type`,
  183. `create_sn`,
  184. `create_time`,
  185. `moder_sn`,
  186. `mod_time`,
  187. `tstm`
  188. )
  189. values
  190. (
  191. #{id},
  192. #{categoryId},
  193. #{goodsSn},
  194. #{name},
  195. #{brandId},
  196. #{goodsNumber},
  197. #{keywords},
  198. #{goodsBrief},
  199. #{goodsDesc},
  200. #{isOnSale},
  201. #{addTime},
  202. #{sortOrder},
  203. #{isDelete},
  204. #{attributeCategory},
  205. #{counterPrice},
  206. #{extraPrice},
  207. #{isNew},
  208. #{goodsUnit},
  209. #{primaryPicUrl},
  210. #{listPicUrl},
  211. #{retailPrice},
  212. #{sellVolume},
  213. #{primaryProductId},
  214. #{unitPrice},
  215. #{promotionDesc},
  216. #{promotionTag},
  217. #{appExclusivePrice},
  218. #{isAppExclusive},
  219. #{isLimited},
  220. #{isHot},
  221. #{marketPrice},
  222. #{sku},
  223. #{goodsBizType},
  224. #{createrSn},
  225. #{createTime},
  226. #{moderSn},
  227. #{modTime},
  228. #{tstm}
  229. )
  230. </insert>
  231. <update id="update" parameterType="com.kmall.admin.entity.GoodsEntity">
  232. update mall_goods
  233. <set>
  234. <if test="categoryId != null">`category_id` = #{categoryId},</if>
  235. <if test="goodsSn != null">`goods_sn` = #{goodsSn},</if>
  236. <if test="name != null">`name` = #{name},</if>
  237. <if test="brandId != null">`brand_id` = #{brandId},</if>
  238. <if test="goodsNumber != null">`goods_number` = #{goodsNumber},</if>
  239. <if test="keywords != null">`keywords` = #{keywords},</if>
  240. <if test="goodsBrief != null">`goods_brief` = #{goodsBrief},</if>
  241. <if test="goodsDesc != null">`goods_desc` = #{goodsDesc},</if>
  242. <if test="isOnSale != null">`is_on_sale` = #{isOnSale},</if>
  243. <if test="addTime != null">`add_time` = #{addTime},</if>
  244. <if test="sortOrder != null">`sort_order` = #{sortOrder},</if>
  245. <if test="isDelete != null">`is_delete` = #{isDelete},</if>
  246. <if test="attributeCategory != null">`attribute_category` = #{attributeCategory},</if>
  247. <if test="counterPrice != null">`counter_price` = #{counterPrice},</if>
  248. <if test="extraPrice != null">`extra_price` = #{extraPrice},</if>
  249. <if test="isNew != null">`is_new` = #{isNew},</if>
  250. <if test="goodsUnit != null">`goods_unit` = #{goodsUnit},</if>
  251. <if test="primaryPicUrl != null">`primary_pic_url` = #{primaryPicUrl},</if>
  252. <if test="listPicUrl != null">`list_pic_url` = #{listPicUrl},</if>
  253. <if test="retailPrice != null">`retail_price` = #{retailPrice},</if>
  254. <if test="sellVolume != null">`sell_volume` = #{sellVolume},</if>
  255. <if test="primaryProductId != null">`primary_product_id` = #{primaryProductId},</if>
  256. <if test="unitPrice != null">`unit_price` = #{unitPrice},</if>
  257. <if test="promotionDesc != null">`promotion_desc` = #{promotionDesc},</if>
  258. <if test="promotionTag != null">`promotion_tag` = #{promotionTag},</if>
  259. <if test="appExclusivePrice != null">`app_exclusive_price` = #{appExclusivePrice},</if>
  260. <if test="isAppExclusive != null">`is_app_exclusive` = #{isAppExclusive},</if>
  261. <if test="isLimited != null">`is_limited` = #{isLimited},</if>
  262. <if test="isHot != null">`is_hot` = #{isHot},</if>
  263. <if test="marketPrice != null">`market_price` = #{marketPrice},</if>
  264. <if test="sku != null" >
  265. sku = #{sku,jdbcType=VARCHAR},
  266. </if>
  267. <if test="goodsBizType != null" >
  268. goods_biz_type = #{goodsBizType,jdbcType=CHAR},
  269. </if>
  270. <if test="createrSn != null" >
  271. creater_sn = #{createrSn,jdbcType=VARCHAR},
  272. </if>
  273. <if test="createTime != null" >
  274. create_time = #{createTime,jdbcType=TIMESTAMP},
  275. </if>
  276. <if test="moderSn != null" >
  277. moder_sn = #{moderSn,jdbcType=VARCHAR},
  278. </if>
  279. <if test="modTime != null" >
  280. mod_time = #{modTime,jdbcType=TIMESTAMP},
  281. </if>
  282. <if test="tstm != null" >
  283. tstm = #{tstm,jdbcType=TIMESTAMP},
  284. </if>
  285. </set>
  286. where id = #{id}
  287. </update>
  288. <delete id="delete">
  289. delete from mall_goods where id = #{value}
  290. </delete>
  291. <delete id="deleteBatch">
  292. delete from mall_goods where id in
  293. <foreach item="id" collection="array" open="(" separator="," close=")">
  294. #{id}
  295. </foreach>
  296. </delete>
  297. <select id="queryMaxId" resultType="java.lang.Long" parameterType="map">
  298. SELECT MAX(id) FROM mall_goods
  299. </select>
  300. </mapper>