<?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.ruixuan.launch.mapper.KuaishouLaunchCampaignRecordMapper">

    <resultMap type="com.ruixuan.launch.entity.KuaishouLaunchCampaignRecord" id="KuaishouLaunchCampaignRecordResult">
        <result property="id" column="id"/>
        <result property="accountId" column="account_id"/>
        <result property="strategyId" column="strategy_id"/>
        <result property="campaignId" column="campaign_id"/>
        <result property="campaignName" column="campaign_name"/>
        <result property="campaignType" column="campaign_type"/>
        <result property="statDate" column="stat_date"/>
        <result property="promotionType" column="promotion_type"/>
        <result property="dayBudget" column="day_budget"/>
        <result property="budgetSchedule" column="budget_schedule"/>
        <result property="message" column="message"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectKuaishouLaunchCampaignRecordVo">
        select id,
               account_id,
               strategy_id,
               campaign_id,
               campaign_name,
               campaign_type,
               stat_date,
               promotion_type,
               day_budget,
               budget_schedule,
               message,
               create_time,
               update_time
        from kuaishou_launch_campaign_record
    </sql>

    <select id="selectKuaishouLaunchCampaignRecordList"
            parameterType="com.ruixuan.launch.entity.KuaishouLaunchCampaignRecord"
            resultMap="KuaishouLaunchCampaignRecordResult">
        <include refid="selectKuaishouLaunchCampaignRecordVo"/>
        <where>
            <if test="accountId != null ">and account_id = #{accountId}</if>
            <if test="strategyId != null ">and strategy_id = #{strategyId}</if>
            <if test="campaignId != null ">and campaign_id = #{campaignId}</if>
            <if test="campaignName != null  and campaignName != ''">and campaign_name like concat('%', #{campaignName},
                '%')
            </if>
            <if test="campaignType != null ">and campaign_type = #{campaignType}</if>
            <if test="statDate != null  and statDate != ''">and stat_date = #{statDate}</if>
            <if test="promotionType != null ">and promotion_type = #{promotionType}</if>
            <if test="dayBudget != null ">and day_budget = #{dayBudget}</if>
            <if test="budgetSchedule != null  and budgetSchedule != ''">and budget_schedule = #{budgetSchedule}</if>
            <if test="message != null  and message != ''">and message = #{message}</if>
        </where>
    </select>

    <select id="selectKuaishouLaunchCampaignRecordById" parameterType="String"
            resultMap="KuaishouLaunchCampaignRecordResult">
        <include refid="selectKuaishouLaunchCampaignRecordVo"/>
        where id = #{id}
    </select>

    <insert id="insertKuaishouLaunchCampaignRecord"
            parameterType="com.ruixuan.launch.entity.KuaishouLaunchCampaignRecord">
        insert into kuaishou_launch_campaign_record
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="accountId != null">account_id,</if>
            <if test="strategyId != null">strategy_id,</if>
            <if test="campaignId != null">campaign_id,</if>
            <if test="campaignName != null and campaignName != ''">campaign_name,</if>
            <if test="campaignType != null">campaign_type,</if>
            <if test="statDate != null">stat_date,</if>
            <if test="promotionType != null">promotion_type,</if>
            <if test="dayBudget != null">day_budget,</if>
            <if test="budgetSchedule != null">budget_schedule,</if>
            <if test="message != null">message,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="accountId != null">#{accountId},</if>
            <if test="strategyId != null">#{strategyId},</if>
            <if test="campaignId != null">#{campaignId},</if>
            <if test="campaignName != null and campaignName != ''">#{campaignName},</if>
            <if test="campaignType != null">#{campaignType},</if>
            <if test="statDate != null">#{statDate},</if>
            <if test="promotionType != null">#{promotionType},</if>
            <if test="dayBudget != null">#{dayBudget},</if>
            <if test="budgetSchedule != null">#{budgetSchedule},</if>
            <if test="message != null">#{message},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateKuaishouLaunchCampaignRecord"
            parameterType="com.ruixuan.launch.entity.KuaishouLaunchCampaignRecord">
        update kuaishou_launch_campaign_record
        <trim prefix="SET" suffixOverrides=",">
            <if test="accountId != null">account_id = #{accountId},</if>
            <if test="strategyId != null">strategy_id = #{strategyId},</if>
            <if test="campaignId != null">campaign_id = #{campaignId},</if>
            <if test="campaignName != null and campaignName != ''">campaign_name = #{campaignName},</if>
            <if test="campaignType != null">campaign_type = #{campaignType},</if>
            <if test="statDate != null">stat_date = #{statDate},</if>
            <if test="promotionType != null">promotion_type = #{promotionType},</if>
            <if test="dayBudget != null">day_budget = #{dayBudget},</if>
            <if test="budgetSchedule != null">budget_schedule = #{budgetSchedule},</if>
            <if test="message != null">message = #{message},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteKuaishouLaunchCampaignRecordById" parameterType="String">
        delete
        from kuaishou_launch_campaign_record
        where id = #{id}
    </delete>

    <delete id="deleteKuaishouLaunchCampaignRecordByIds" parameterType="String">
        delete from kuaishou_launch_campaign_record where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>