<?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.KuaishouLaunchGroupMapper">

    <resultMap type="com.ruixuan.launch.entity.KuaishouLaunchGroup" id="KuaishouLaunchGroupResult">
        <result property="id" column="id"/>
        <result property="accountId" column="account_id"/>
        <result property="campaignId" column="campaign_id"/>
        <result property="unitId" column="unit_id"/>
        <result property="unitName" column="unit_name"/>
        <result property="putStatus" column="put_status"/>
        <result property="cpaBid" column="cpa_bid"/>
        <result property="bidType" column="bid_type"/>
        <result property="ocpxActionType" column="ocpx_action_type"/>
        <result property="roiRatio" column="roi_ratio"/>
        <result property="sceneId" column="scene_id"/>
        <result property="unitType" column="unit_type"/>
        <result property="beginTimeStr" column="begin_time_str"/>
        <result property="endTimeStr" column="end_time_str"/>
        <result property="scheduleTime" column="schedule_time"/>
        <result property="dayBudget" column="day_budget"/>
        <result property="supportType" column="support_type"/>
        <result property="showMode" column="show_mode"/>
        <result property="speed" column="speed"/>
        <result property="statDate" column="stat_date"/>
        <result property="itemId" column="item_id"/>
        <result property="merchantItemPutType" column="merchant_item_put_type"/>
        <result property="shoppingCarProductId" column="shopping_car_product_id"/>
        <result property="liveUserId" column="live_user_id"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectKuaishouLaunchGroupVo">
        select id,
               account_id,
               campaign_id,
               unit_id,
               unit_name,
               put_status,
               cpa_bid,
               bid_type,
               ocpx_action_type,
               roi_ratio,
               scene_id,
               unit_type,
               begin_time_str,
               end_time_str,
               schedule_time,
               day_budget,
               support_type,
               show_mode,
               speed,
               stat_date,
               item_id,
               merchant_item_put_type,
               shopping_car_product_id,
               live_user_id,
               create_time,
               update_time
        from kuaishou_launch_group
    </sql>

    <select id="selectKuaishouLaunchGroupList" parameterType="com.ruixuan.launch.entity.KuaishouLaunchGroup"
            resultMap="KuaishouLaunchGroupResult">
        <include refid="selectKuaishouLaunchGroupVo"/>
        <where>
            <if test="accountId != null ">and account_id = #{accountId}</if>
            <if test="campaignId != null ">and campaign_id = #{campaignId}</if>
            <if test="unitId != null ">and unit_id = #{unitId}</if>
            <if test="unitName != null  and unitName != ''">and unit_name like concat('%', #{unitName}, '%')</if>
            <if test="putStatus != null ">and put_status = #{putStatus}</if>
            <if test="cpaBid != null ">and cpa_bid = #{cpaBid}</if>
            <if test="bidType != null ">and bid_type = #{bidType}</if>
            <if test="ocpxActionType != null ">and ocpx_action_type = #{ocpxActionType}</if>
            <if test="roiRatio != null ">and roi_ratio = #{roiRatio}</if>
            <if test="sceneId != null  and sceneId != ''">and scene_id = #{sceneId}</if>
            <if test="unitType != null ">and unit_type = #{unitType}</if>
            <if test="beginTimeStr != null  and beginTimeStr != ''">and begin_time_str = #{beginTimeStr}
            </if>
            <if test="endTimeStr != null  and endTimeStr != ''">and end_time_str = #{endTimeStr}</if>
            <if test="scheduleTime != null  and scheduleTime != ''">and schedule_time = #{scheduleTime}</if>
            <if test="dayBudget != null ">and day_budget = #{dayBudget}</if>
            <if test="supportType != null ">and support_type = #{supportType}</if>
            <if test="showMode != null ">and show_mode = #{showMode}</if>
            <if test="speed != null ">and speed = #{speed}</if>
            <if test="statDate != null ">and stat_date = #{statDate}</if>
            <if test="itemId != null ">and item_id = #{itemId}</if>
            <if test="merchantItemPutType != null ">and merchant_item_put_type = #{merchantItemPutType}</if>
            <if test="shoppingCarProductId != null ">and shopping_car_product_id = #{shoppingCarProductId}</if>
            <if test="liveUserId != null ">and live_user_id = #{liveUserId}</if>
        </where>
    </select>


    <select id="selectKuaishouLaunchGroupById" parameterType="String" resultMap="KuaishouLaunchGroupResult">
        <include refid="selectKuaishouLaunchGroupVo"/>
        where id = #{id}
    </select>

    <insert id="insertKuaishouLaunchGroup" parameterType="com.ruixuan.launch.entity.KuaishouLaunchGroup">
        insert into kuaishou_launch_group
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="accountId != null">account_id,</if>
            <if test="campaignId != null">campaign_id,</if>
            <if test="unitId != null">unit_id,</if>
            <if test="unitName != null">unit_name,</if>
            <if test="putStatus != null">put_status,</if>
            <if test="cpaBid != null">cpa_bid,</if>
            <if test="bidType != null">bid_type,</if>
            <if test="ocpxActionType != null">ocpx_action_type,</if>
            <if test="roiRatio != null">roi_ratio,</if>
            <if test="sceneId != null">scene_id,</if>
            <if test="unitType != null">unit_type,</if>
            <if test="beginTimeStr != null">begin_time_str,</if>
            <if test="endTimeStr != null">end_time_str,</if>
            <if test="scheduleTime != null">schedule_time,</if>
            <if test="dayBudget != null">day_budget,</if>
            <if test="supportType != null">support_type,</if>
            <if test="showMode != null">show_mode,</if>
            <if test="speed != null">speed,</if>
            <if test="statDate != null">stat_date,</if>
            <if test="itemId != null">item_id,</if>
            <if test="merchantItemPutType != null">merchant_item_put_type,</if>
            <if test="shoppingCarProductId != null">shopping_car_product_id,</if>
            <if test="liveUserId != null">live_user_id,</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="campaignId != null">#{campaignId},</if>
            <if test="unitId != null">#{unitId},</if>
            <if test="unitName != null">#{unitName},</if>
            <if test="putStatus != null">#{putStatus},</if>
            <if test="cpaBid != null">#{cpaBid},</if>
            <if test="bidType != null">#{bidType},</if>
            <if test="ocpxActionType != null">#{ocpxActionType},</if>
            <if test="roiRatio != null">#{roiRatio},</if>
            <if test="sceneId != null">#{sceneId},</if>
            <if test="unitType != null">#{unitType},</if>
            <if test="beginTimeStr != null">#{beginTimeStr},</if>
            <if test="endTimeStr != null">#{endTimeStr},</if>
            <if test="scheduleTime != null">#{scheduleTime},</if>
            <if test="dayBudget != null">#{dayBudget},</if>
            <if test="supportType != null">#{supportType},</if>
            <if test="showMode != null">#{showMode},</if>
            <if test="speed != null">#{speed},</if>
            <if test="statDate != null">#{statDate},</if>
            <if test="itemId != null">#{itemId},</if>
            <if test="merchantItemPutType != null">#{merchantItemPutType},</if>
            <if test="shoppingCarProductId != null">#{shoppingCarProductId},</if>
            <if test="liveUserId != null">#{liveUserId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateKuaishouLaunchGroup" parameterType="com.ruixuan.launch.entity.KuaishouLaunchGroup">
        update kuaishou_launch_group
        <trim prefix="SET" suffixOverrides=",">
            <if test="accountId != null">account_id = #{accountId},</if>
            <if test="campaignId != null">campaign_id = #{campaignId},</if>
            <if test="unitId != null">unit_id = #{unitId},</if>
            <if test="unitName != null">unit_name = #{unitName},</if>
            <if test="putStatus != null">put_status = #{putStatus},</if>
            <if test="cpaBid != null">cpa_bid = #{cpaBid},</if>
            <if test="bidType != null">bid_type = #{bidType},</if>
            <if test="ocpxActionType != null">ocpx_action_type = #{ocpxActionType},</if>
            <if test="roiRatio != null">roi_ratio = #{roiRatio},</if>
            <if test="sceneId != null">scene_id = #{sceneId},</if>
            <if test="unitType != null">unit_type = #{unitType},</if>
            <if test="beginTimeStr != null">begin_time_str = #{beginTimeStr},</if>
            <if test="endTimeStr != null">end_time_str = #{endTimeStr},</if>
            <if test="scheduleTime != null">schedule_time = #{scheduleTime},</if>
            <if test="dayBudget != null">day_budget = #{dayBudget},</if>
            <if test="supportType != null">support_type = #{supportType},</if>
            <if test="showMode != null">show_mode = #{showMode},</if>
            <if test="speed != null">speed = #{speed},</if>
            <if test="statDate != null">stat_date = #{statDate},</if>
            <if test="itemId != null">item_id = #{itemId},</if>
            <if test="merchantItemPutType != null">merchant_item_put_type = #{merchantItemPutType},</if>
            <if test="shoppingCarProductId != null">shopping_car_product_id = #{shoppingCarProductId},</if>
            <if test="liveUserId != null">live_user_id = #{liveUserId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteKuaishouLaunchGroupById" parameterType="String">
        delete
        from kuaishou_launch_group
        where id = #{id}
    </delete>

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