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

    <resultMap type="com.ruixuan.launch.entity.KuaishouLaunchCreative" id="KuaishouLaunchCreativeResult">
        <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="creativeId" column="creative_id"/>
        <result property="creativeName" column="creative_name"/>
        <result property="coverUrl" column="cover_url"/>
        <result property="coverWidth" column="cover_width"/>
        <result property="coverHeight" column="cover_height"/>
        <result property="photoId" column="photo_id"/>
        <result property="statDate" column="stat_date"/>
        <result property="creativeMaterialType" column="creative_material_type"/>
        <result property="actionBar" column="action_bar"/>
        <result property="recommendation" column="recommendation"/>
        <result property="description" column="description"/>
        <result property="newExposeText" column="new_expose_text"/>
        <result property="newExposeUrl" column="new_expose_url"/>
        <result property="liveCreativeType" column="live_creative_type"/>
        <result property="putStatus" column="put_status"/>
        <result property="createTime" column="create_time"/>
        <result property="updateTime" column="update_time"/>
    </resultMap>

    <sql id="selectKuaishouLaunchCreativeVo">
        select id,
               account_id,
               campaign_id,
               unit_id creative_id,
               creative_name,
               cover_url,
               cover_width,
               cover_height,
               photo_id,
               stat_date,
               creative_material_type,
               action_bar,
               recommendation,
               description,
               new_expose_text,
               new_expose_url,
               live_creative_type,
               put_status,
               create_time,
               update_time
        from kuaishou_launch_creative
    </sql>

    <select id="selectKuaishouLaunchCreativeList" parameterType="com.ruixuan.launch.entity.KuaishouLaunchCreative"
            resultMap="KuaishouLaunchCreativeResult">
        <include refid="selectKuaishouLaunchCreativeVo"/>
        <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="creativeId != null ">and creative_id = #{creativeId}</if>
            <if test="creativeName != null  and creativeName != ''">and creative_name like concat('%', #{creativeName},
                '%')
            </if>
            <if test="coverUrl != null  and coverUrl != ''">and cover_url = #{coverUrl}</if>
            <if test="coverWidth != null ">and cover_width = #{coverWidth}</if>
            <if test="coverHeight != null ">and cover_height = #{coverHeight}</if>
            <if test="photoId != null  and photoId != ''">and photo_id = #{photoId}</if>
            <if test="statDate != null  and statDate != ''">and stat_date = #{statDate}</if>
            <if test="creativeMaterialType != null ">and creative_material_type = #{creativeMaterialType}</if>
            <if test="actionBar != null  and actionBar != ''">and action_bar = #{actionBar}</if>
            <if test="recommendation != null  and recommendation != ''">and recommendation = #{recommendation}</if>
            <if test="description != null  and description != ''">and description = #{description}</if>
            <if test="newExposeText != null  and newExposeText != ''">and new_expose_text = #{newExposeText}</if>
            <if test="newExposeUrl != null  and newExposeUrl != ''">and new_expose_url = #{newExposeUrl}</if>
            <if test="liveCreativeType != null ">and live_creative_type = #{liveCreativeType}</if>
            <if test="putStatus != null ">and put_status = #{putStatus}</if>
        </where>
    </select>

    <select id="selectKuaishouLaunchCreativeById" parameterType="String" resultMap="KuaishouLaunchCreativeResult">
        <include refid="selectKuaishouLaunchCreativeVo"/>
        where id = #{id}
    </select>

    <insert id="insertKuaishouLaunchCreative" parameterType="com.ruixuan.launch.entity.KuaishouLaunchCreative">
        insert into kuaishou_launch_creative
        <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="creativeId != null">creative_id,</if>
            <if test="creativeName != null">creative_name,</if>
            <if test="coverUrl != null">cover_url,</if>
            <if test="coverWidth != null">cover_width,</if>
            <if test="coverHeight != null">cover_height,</if>
            <if test="photoId != null">photo_id,</if>
            <if test="statDate != null">stat_date,</if>
            <if test="creativeMaterialType != null">creative_material_type,</if>
            <if test="actionBar != null">action_bar,</if>
            <if test="recommendation != null">recommendation,</if>
            <if test="description != null">description,</if>
            <if test="newExposeText != null">new_expose_text,</if>
            <if test="newExposeUrl != null">new_expose_url,</if>
            <if test="liveCreativeType != null">live_creative_type,</if>
            <if test="putStatus != null">put_status,</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="creativeId != null">#{creativeId},</if>
            <if test="creativeName != null">#{creativeName},</if>
            <if test="coverUrl != null">#{coverUrl},</if>
            <if test="coverWidth != null">#{coverWidth},</if>
            <if test="coverHeight != null">#{coverHeight},</if>
            <if test="photoId != null">#{photoId},</if>
            <if test="statDate != null">#{statDate},</if>
            <if test="creativeMaterialType != null">#{creativeMaterialType},</if>
            <if test="actionBar != null">#{actionBar},</if>
            <if test="recommendation != null">#{recommendation},</if>
            <if test="description != null">#{description},</if>
            <if test="newExposeText != null">#{newExposeText},</if>
            <if test="newExposeUrl != null">#{newExposeUrl},</if>
            <if test="liveCreativeType != null">#{liveCreativeType},</if>
            <if test="putStatus != null">#{putStatus},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
        </trim>
    </insert>

    <update id="updateKuaishouLaunchCreative" parameterType="com.ruixuan.launch.entity.KuaishouLaunchCreative">
        update kuaishou_launch_creative
        <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="creativeId != null">creative_id = #{creativeId},</if>
            <if test="creativeName != null">creative_name = #{creativeName},</if>
            <if test="coverUrl != null">cover_url = #{coverUrl},</if>
            <if test="coverWidth != null">cover_width = #{coverWidth},</if>
            <if test="coverHeight != null">cover_height = #{coverHeight},</if>
            <if test="photoId != null">photo_id = #{photoId},</if>
            <if test="statDate != null">stat_date = #{statDate},</if>
            <if test="creativeMaterialType != null">creative_material_type = #{creativeMaterialType},</if>
            <if test="actionBar != null">action_bar = #{actionBar},</if>
            <if test="recommendation != null">recommendation = #{recommendation},</if>
            <if test="description != null">description = #{description},</if>
            <if test="newExposeText != null">new_expose_text = #{newExposeText},</if>
            <if test="newExposeUrl != null">new_expose_url = #{newExposeUrl},</if>
            <if test="liveCreativeType != null">live_creative_type = #{liveCreativeType},</if>
            <if test="putStatus != null">put_status = #{putStatus},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteKuaishouLaunchCreativeById" parameterType="String">
        delete
        from kuaishou_launch_creative
        where id = #{id}
    </delete>

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