<?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.ProductMapper">
    <select id="selectById" resultType="com.orangesale.cn.entity.OrangeProduct">
        select id,name,img_url,price,add_time from orange_product where id=#{productId}
    </select>
    <select id="selectAll" resultType="com.orangesale.cn.entity.OrangeProduct">
        select id,name,img_url,price,add_time from orange_product
    </select>
    <update id="updateProduct">
        update orange_product set
        <trim suffixOverrides=",">
            name =#{name},
            img_url=#{imgUrl},
            price=#{price}
        </trim>
        where id=#{id}
    </update>
    <insert id="addProduct" parameterType="com.orangesale.cn.entity.OrangeProduct">
        insert into orange_product(name,img_url,price,add_time) values (#{name},#{imgUrl},#{price},#{addTime})
    </insert>
    <delete id="deleteProduct">
        delete from orange_product where id=#{id}
    </delete>
</mapper>