<?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.ylx.massage.mapper.CouponMapper">

    <resultMap type="com.ylx.massage.domain.Coupon" id="CouponMap">
        <result property="id" column="id" jdbcType="VARCHAR"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="type" column="type" jdbcType="INTEGER"/>
        <result property="discountType" column="discount_type" jdbcType="INTEGER"/>
        <result property="discountValue" column="discount_value" jdbcType="NUMERIC"/>
        <result property="thresholdAmount" column="threshold_amount" jdbcType="NUMERIC"/>
        <result property="obtainWay" column="obtain_way" jdbcType="INTEGER"/>
        <result property="termDays" column="term_days" jdbcType="INTEGER"/>
        <result property="status" column="status" jdbcType="INTEGER"/>
        <result property="usedNum" column="used_num" jdbcType="INTEGER"/>
        <result property="userLimit" column="user_limit" jdbcType="INTEGER"/>
        <result property="extParam" column="ext_param" jdbcType="VARCHAR"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="isDelete" column="is_delete" jdbcType="INTEGER"/>
    </resultMap>

    <!-- 批量插入 -->
    <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
        insert into
        ry-vue.coupon(nametypediscount_typediscount_valuethreshold_amountobtain_wayterm_daysstatusused_numuser_limitext_paramcreate_timeupdate_timeis_delete)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.name}#{entity.type}#{entity.discountType}#{entity.discountValue}#{entity.thresholdAmount}#{entity.obtainWay}#{entity.termDays}#{entity.status}#{entity.usedNum}#{entity.userLimit}#{entity.extParam}#{entity.createTime}#{entity.updateTime}#{entity.isDelete})
        </foreach>
    </insert>
    <!-- 批量插入或按主键更新 -->
    <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
        insert into
        ry-vue.coupon(nametypediscount_typediscount_valuethreshold_amountobtain_wayterm_daysstatusused_numuser_limitext_paramcreate_timeupdate_timeis_delete)
        values
        <foreach collection="entities" item="entity" separator=",">
            (#{entity.name}#{entity.type}#{entity.discountType}#{entity.discountValue}#{entity.thresholdAmount}#{entity.obtainWay}#{entity.termDays}#{entity.status}#{entity.usedNum}#{entity.userLimit}#{entity.extParam}#{entity.createTime}#{entity.updateTime}#{entity.isDelete})
        </foreach>
        on duplicate key update
        name = values(name) type = values(type) discount_type = values(discount_type) discount_value =
        values(discount_value) threshold_amount = values(threshold_amount) obtain_way = values(obtain_way) term_days =
        values(term_days) status = values(status) used_num = values(used_num) user_limit = values(user_limit) ext_param
        = values(ext_param) create_time = values(create_time) update_time = values(update_time) is_delete =
        values(is_delete)
    </insert>

</mapper>

