<?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.fs.ad.mapper.AdUploadLogMapper">
    
    <resultMap type="AdUploadLog" id="AdUploadLogResult">
        <result property="id"    column="id"    />
        <result property="siteId"    column="site_id"    />
        <result property="type"    column="type"    />
        <result property="templateId"    column="template_id"    />
        <result property="accountId"    column="account_id"    />
        <result property="domainId"    column="domain_id"    />
        <result property="url"    column="url"    />
        <result property="uploadType"    column="upload_type"    />
        <result property="vid"    column="vid"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectAdUploadLogVo">
        select id, site_id, type, template_id, account_id, domain_id, url, upload_type, vid, create_time from ad_upload_log
    </sql>

    <select id="selectAdUploadLogList" parameterType="AdUploadLog" resultMap="AdUploadLogResult">
        <include refid="selectAdUploadLogVo"/>
        <where>  
            <if test="siteId != null "> and site_id = #{siteId}</if>
            <if test="type != null "> and type = #{type}</if>
            <if test="templateId != null "> and template_id = #{templateId}</if>
            <if test="accountId != null "> and account_id = #{accountId}</if>
            <if test="domainId != null "> and domain_id = #{domainId}</if>
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="uploadType != null  and uploadType != ''"> and upload_type = #{uploadType}</if>
            <if test="vid != null  and vid != ''"> and vid = #{vid}</if>
        </where>
    </select>
    
    <select id="selectAdUploadLogById" parameterType="Long" resultMap="AdUploadLogResult">
        <include refid="selectAdUploadLogVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAdUploadLog" parameterType="AdUploadLog" useGeneratedKeys="true" keyProperty="id">
        insert into ad_upload_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="siteId != null">site_id,</if>
            <if test="type != null">type,</if>
            <if test="templateId != null">template_id,</if>
            <if test="accountId != null">account_id,</if>
            <if test="domainId != null">domain_id,</if>
            <if test="url != null">url,</if>
            <if test="uploadType != null">upload_type,</if>
            <if test="vid != null">vid,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="siteId != null">#{siteId},</if>
            <if test="type != null">#{type},</if>
            <if test="templateId != null">#{templateId},</if>
            <if test="accountId != null">#{accountId},</if>
            <if test="domainId != null">#{domainId},</if>
            <if test="url != null">#{url},</if>
            <if test="uploadType != null">#{uploadType},</if>
            <if test="vid != null">#{vid},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateAdUploadLog" parameterType="AdUploadLog">
        update ad_upload_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="siteId != null">site_id = #{siteId},</if>
            <if test="type != null">type = #{type},</if>
            <if test="templateId != null">template_id = #{templateId},</if>
            <if test="accountId != null">account_id = #{accountId},</if>
            <if test="domainId != null">domain_id = #{domainId},</if>
            <if test="url != null">url = #{url},</if>
            <if test="uploadType != null">upload_type = #{uploadType},</if>
            <if test="vid != null">vid = #{vid},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAdUploadLogById" parameterType="Long">
        delete from ad_upload_log where id = #{id}
    </delete>

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