CouponMapper.xml 10.1 KB
<?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.yohoufo.dal.promotion.CouponMapper">
  <resultMap id="BaseResultMap" type="com.yohoufo.dal.promotion.model.Coupon">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="coupon_token" jdbcType="VARCHAR" property="couponToken" />
    <result column="coupon_name" jdbcType="VARCHAR" property="couponName" />
    <result column="coupon_amount" jdbcType="DECIMAL" property="couponAmount" />
      <result column="coupon_type" jdbcType="INTEGER" property="couponType" />
    <result column="coupon_num" jdbcType="INTEGER" property="couponNum" />
    <result column="use_num" jdbcType="SMALLINT" property="useNum" />
    <result column="send_num" jdbcType="INTEGER" property="sendNum" />
    <result column="use_limit_type" jdbcType="TINYINT" property="useLimitType" />
    <result column="use_limit_value" jdbcType="SMALLINT" property="useLimitValue" />
    <result column="product_limit_type" jdbcType="TINYINT" property="productLimitType" />
    <result column="product_limit_value" jdbcType="VARCHAR" property="productLimitValue" />
    <result column="start_time" jdbcType="INTEGER" property="startTime" />
    <result column="end_time" jdbcType="INTEGER" property="endTime" />
    <result column="status" jdbcType="TINYINT" property="status" />
    <result column="create_time" jdbcType="INTEGER" property="createTime" />
    <result column="pid" jdbcType="INTEGER" property="pid" />
    <result column="remark" jdbcType="VARCHAR" property="remark" />
    <result column="skup_forbid_type" jdbcType="VARCHAR" property="skupForbidType" />
  </resultMap>
  <sql id="Base_Column_List">
    id, coupon_token, coupon_name, coupon_amount, coupon_type, coupon_num, use_num, send_num, 
    use_limit_type, use_limit_value, product_limit_type, product_limit_value, start_time, 
    end_time, status, create_time, pid, remark,skup_forbid_type
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from coupon
    where id = #{id,jdbcType=INTEGER}
  </select>


  <select id="selectByCouponToken" parameterType="java.lang.String" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from coupon
    where coupon_token = #{couponToken,jdbcType=VARCHAR}
  </select>

  <update id="updateCouponSendNum" >
    update coupon set send_num=#{sendNum} where coupon_token=#{couponToken}
  </update>

  <select id="selectByCouponIds" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from coupon
    where 1=1
    AND id IN
    <foreach item="id" index="index" collection="ids"
             open="(" separator="," close=")">
      #{id}
    </foreach>
  </select>

  <select id="selectByCouponTokens" parameterType="java.lang.String" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from coupon
    where 1=1
    AND coupon_token IN
    <foreach item="token" index="index" collection="list"
             open="(" separator="," close=")">
      #{token}
    </foreach>
  </select>


  <insert id="insert" parameterType="com.yohoufo.dal.promotion.model.Coupon">
    insert into coupon (id, coupon_token, coupon_name, 
      coupon_amount, coupon_type, coupon_num, 
      use_num, send_num, use_limit_type, 
      use_limit_value, product_limit_type, product_limit_value, 
      start_time, end_time, status, 
      create_time, pid, remark
      )
    values (#{id,jdbcType=INTEGER}, #{couponToken,jdbcType=VARCHAR}, #{couponName,jdbcType=VARCHAR}, 
      #{couponAmount,jdbcType=DECIMAL}, #{couponType,jdbcType=TINYINT}, #{couponNum,jdbcType=INTEGER}, 
      #{useNum,jdbcType=SMALLINT}, #{sendNum,jdbcType=INTEGER}, #{useLimitType,jdbcType=TINYINT}, 
      #{useLimitValue,jdbcType=SMALLINT}, #{productLimitType,jdbcType=TINYINT}, #{productLimitValue,jdbcType=VARCHAR}, 
      #{startTime,jdbcType=INTEGER}, #{endTime,jdbcType=INTEGER}, #{status,jdbcType=TINYINT}, 
      #{createTime,jdbcType=INTEGER}, #{pid,jdbcType=INTEGER}, #{remark,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.yohoufo.dal.promotion.model.Coupon">
    insert into coupon
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="couponToken != null">
        coupon_token,
      </if>
      <if test="couponName != null">
        coupon_name,
      </if>
      <if test="couponAmount != null">
        coupon_amount,
      </if>
      <if test="couponType != null">
        coupon_type,
      </if>
      <if test="couponNum != null">
        coupon_num,
      </if>
      <if test="useNum != null">
        use_num,
      </if>
      <if test="sendNum != null">
        send_num,
      </if>
      <if test="useLimitType != null">
        use_limit_type,
      </if>
      <if test="useLimitValue != null">
        use_limit_value,
      </if>
      <if test="productLimitType != null">
        product_limit_type,
      </if>
      <if test="productLimitValue != null">
        product_limit_value,
      </if>
      <if test="startTime != null">
        start_time,
      </if>
      <if test="endTime != null">
        end_time,
      </if>
      <if test="status != null">
        status,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="pid != null">
        pid,
      </if>
      <if test="remark != null">
        remark,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="couponToken != null">
        #{couponToken,jdbcType=VARCHAR},
      </if>
      <if test="couponName != null">
        #{couponName,jdbcType=VARCHAR},
      </if>
      <if test="couponAmount != null">
        #{couponAmount,jdbcType=DECIMAL},
      </if>
      <if test="couponType != null">
        #{couponType,jdbcType=TINYINT},
      </if>
      <if test="couponNum != null">
        #{couponNum,jdbcType=INTEGER},
      </if>
      <if test="useNum != null">
        #{useNum,jdbcType=SMALLINT},
      </if>
      <if test="sendNum != null">
        #{sendNum,jdbcType=INTEGER},
      </if>
      <if test="useLimitType != null">
        #{useLimitType,jdbcType=TINYINT},
      </if>
      <if test="useLimitValue != null">
        #{useLimitValue,jdbcType=SMALLINT},
      </if>
      <if test="productLimitType != null">
        #{productLimitType,jdbcType=TINYINT},
      </if>
      <if test="productLimitValue != null">
        #{productLimitValue,jdbcType=VARCHAR},
      </if>
      <if test="startTime != null">
        #{startTime,jdbcType=INTEGER},
      </if>
      <if test="endTime != null">
        #{endTime,jdbcType=INTEGER},
      </if>
      <if test="status != null">
        #{status,jdbcType=TINYINT},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=INTEGER},
      </if>
      <if test="pid != null">
        #{pid,jdbcType=INTEGER},
      </if>
      <if test="remark != null">
        #{remark,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.yohoufo.dal.promotion.model.Coupon">
    update coupon
    <set>
      <if test="couponToken != null">
        coupon_token = #{couponToken,jdbcType=VARCHAR},
      </if>
      <if test="couponName != null">
        coupon_name = #{couponName,jdbcType=VARCHAR},
      </if>
      <if test="couponAmount != null">
        coupon_amount = #{couponAmount,jdbcType=DECIMAL},
      </if>
      <if test="couponType != null">
        coupon_type = #{couponType,jdbcType=TINYINT},
      </if>
      <if test="couponNum != null">
        coupon_num = #{couponNum,jdbcType=INTEGER},
      </if>
      <if test="useNum != null">
        use_num = #{useNum,jdbcType=SMALLINT},
      </if>
      <if test="sendNum != null">
        send_num = #{sendNum,jdbcType=INTEGER},
      </if>
      <if test="useLimitType != null">
        use_limit_type = #{useLimitType,jdbcType=TINYINT},
      </if>
      <if test="useLimitValue != null">
        use_limit_value = #{useLimitValue,jdbcType=SMALLINT},
      </if>
      <if test="productLimitType != null">
        product_limit_type = #{productLimitType,jdbcType=TINYINT},
      </if>
      <if test="productLimitValue != null">
        product_limit_value = #{productLimitValue,jdbcType=VARCHAR},
      </if>
      <if test="startTime != null">
        start_time = #{startTime,jdbcType=INTEGER},
      </if>
      <if test="endTime != null">
        end_time = #{endTime,jdbcType=INTEGER},
      </if>
      <if test="status != null">
        status = #{status,jdbcType=TINYINT},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=INTEGER},
      </if>
      <if test="pid != null">
        pid = #{pid,jdbcType=INTEGER},
      </if>
      <if test="remark != null">
        remark = #{remark,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.yohoufo.dal.promotion.model.Coupon">
    update coupon
    set coupon_token = #{couponToken,jdbcType=VARCHAR},
      coupon_name = #{couponName,jdbcType=VARCHAR},
      coupon_amount = #{couponAmount,jdbcType=DECIMAL},
      coupon_type = #{couponType,jdbcType=TINYINT},
      coupon_num = #{couponNum,jdbcType=INTEGER},
      use_num = #{useNum,jdbcType=SMALLINT},
      send_num = #{sendNum,jdbcType=INTEGER},
      use_limit_type = #{useLimitType,jdbcType=TINYINT},
      use_limit_value = #{useLimitValue,jdbcType=SMALLINT},
      product_limit_type = #{productLimitType,jdbcType=TINYINT},
      product_limit_value = #{productLimitValue,jdbcType=VARCHAR},
      start_time = #{startTime,jdbcType=INTEGER},
      end_time = #{endTime,jdbcType=INTEGER},
      status = #{status,jdbcType=TINYINT},
      create_time = #{createTime,jdbcType=INTEGER},
      pid = #{pid,jdbcType=INTEGER},
      remark = #{remark,jdbcType=VARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>

</mapper>