<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.orangesale.cn.mapper.SaleMapper">
    <select id="getBySalesNum" resultType="com.orangesale.cn.entity.OrangeSale">
        select product_id,sales_num from orange_sale order by  sales_num desc
    </select>
    <select id="selectAll" resultType="com.orangesale.cn.entity.OrangeSale">
        select product_id from orange_sale
    </select>
    <update id="updateSalesNum" parameterType="com.orangesale.cn.entity.OrangeSale">
        update orange_sale sales_num=#{salesNum} where product_id=#{productId}
    </update>
    <insert id="addSalesNum">
        insert into orange_sale(product_id,sales_num) values (#{productId},#{salesNum})
    </insert>
</mapper>