<?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.fjs.scenic.mapper.good.DateSurplusMapper">
  <resultMap id="BaseResultMap" type="com.fjs.scenic.entity.good.DateSurplus">
    <constructor>
    	<arg column="id" javaType="java.lang.Integer" jdbcType="INTEGER" />
      <arg column="price_rule_id" javaType="java.lang.Integer" jdbcType="INTEGER" />
      <arg column="start_time" javaType="java.lang.String" jdbcType="VARCHAR" />
      <arg column="end_time" javaType="java.lang.String" jdbcType="VARCHAR" />
      <arg column="surplus" javaType="java.lang.Integer" jdbcType="INTEGER" />
      <arg column="goods_id" javaType="java.lang.Integer" jdbcType="INTEGER" />
    </constructor>
  </resultMap>
  <insert id="insert" parameterType="com.fjs.scenic.entity.good.DateSurplus">
    insert into date_surplus (id,price_rule_id, start_time, end_time, 
      surplus,goods_id)
    values (#{id,jdbcType=INTEGER}, #{priceRuleId,jdbcType=INTEGER}, #{startTime,jdbcType=VARCHAR}, #{endTime,jdbcType=VARCHAR}, 
      #{surplus,jdbcType=INTEGER},#{goodsId,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.fjs.scenic.entity.good.DateSurplus">
    insert into date_surplus
    <trim prefix="(" suffix=")" suffixOverrides=",">
   	 <if test="id != null">
        id,
      </if>
      <if test="priceRuleId != null">
        price_rule_id,
      </if>
      <if test="startTime != null">
        start_time,
      </if>
      <if test="endTime != null">
        end_time,
      </if>
      <if test="surplus != null">
        surplus,
      </if>
      <if test="goodsId != null">
        goods_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="priceRuleId != null">
        #{priceRuleId,jdbcType=INTEGER},
      </if>
      <if test="startTime != null">
        #{startTime,jdbcType=VARCHAR},
      </if>
      <if test="endTime != null">
        #{endTime,jdbcType=VARCHAR},
      </if>
      <if test="surplus != null">
        #{surplus,jdbcType=INTEGER},
      </if>
       <if test="goodsId != null">
        #{goodsId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  
  <delete id="deleteByGoodsId" parameterType="java.lang.Integer">
    delete from date_surplus
    where goods_id = #{goodsId,jdbcType=INTEGER}
  </delete>
  
  <select id="getDateListByPriceRuleId" resultType="map">
  SELECT id,price_rule_id, start_time, end_time, surplus,goods_id FROM date_surplus WHERE price_rule_id=#{priceRuleId,jdbcType=INTEGER}
  </select>
  
</mapper>