ProductMapper.xml 1.1 KB

1234567891011121314151617181920212223242526272829
  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. <select id="findAll" resultType="cn.reghao.tnb.content.app.mall.model.po.Product">
  16. select *
  17. from mall_product
  18. order by id desc
  19. limit 12
  20. </select>
  21. <select id="findByItemId" resultType="cn.reghao.tnb.content.app.mall.model.po.Product">
  22. select *
  23. from mall_product
  24. where item_id=#{itemId}
  25. </select>
  26. </mapper>