ProductMapper.xml 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  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="cn.reghao.tnb.content.app.mall.db.mapper.ProductMapper">
  4. <insert id="save" useGeneratedKeys="true" keyProperty="id">
  5. insert ignore into mall_product
  6. (`item_id`,`item_url`,`title`,`pic_url`,`price`,`month_sale`,`stock`,`shop_id`,`seller_id`)
  7. values
  8. (#{itemId},#{itemUrl},#{title},#{picUrl},#{price},#{monthSale},#{stock},#{shopId},#{sellerId})
  9. </insert>
  10. <update id="updateStockMinus">
  11. update mall_product
  12. set stock=stock-#{num}
  13. where item_id=#{itemId}
  14. </update>
  15. <update id="updateStockPlus">
  16. update mall_product
  17. set stock=stock+#{num}
  18. where item_id=#{itemId}
  19. </update>
  20. <select id="findAll" resultType="cn.reghao.tnb.content.app.mall.model.po.Product">
  21. select *
  22. from mall_product
  23. order by id desc
  24. limit 12
  25. </select>
  26. <select id="findByItemId" resultType="cn.reghao.tnb.content.app.mall.model.po.Product">
  27. select *
  28. from mall_product
  29. where item_id=#{itemId}
  30. </select>
  31. </mapper>