<?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.AdHtmlClickLogMapper">
    
    <resultMap type="AdHtmlClickLog" id="AdHtmlClickLogResult">
        <result property="id"    column="id"    />
        <result property="url"    column="url"    />
        <result property="htmlNo"    column="html_no"    />
        <result property="vid"    column="vid"    />
        <result property="clickType"    column="click_type"    />
        <result property="isUpload"    column="is_upload"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectAdHtmlClickLogVo">
        select * from ad_html_click_log
    </sql>

    <select id="selectAdHtmlClickLogList" parameterType="AdHtmlClickLog" resultMap="AdHtmlClickLogResult">
        <include refid="selectAdHtmlClickLogVo"/>
        <where>  
            <if test="url != null  and url != ''"> and url = #{url}</if>
            <if test="htmlNo != null  and htmlNo != ''"> and html_no = #{htmlNo}</if>
            <if test="vid != null  and vid != ''"> and vid = #{vid}</if>
            <if test="clickType != null "> and click_type = #{clickType}</if>
            <if test="isUpload != null "> and is_upload = #{isUpload}</if>
        </where>
    </select>
    
    <select id="selectAdHtmlClickLogById" parameterType="Long" resultMap="AdHtmlClickLogResult">
        <include refid="selectAdHtmlClickLogVo"/>
        where id = #{id}
    </select>
    <select id="staticData" resultType="com.fs.ad.domain.AdHtmlClickLog">
        select a.* from
        ad_html_click_log a
        inner join qw_external_contact b on a.vid = b.state
        where a.type = 0 and a.upload_type is not null
        and uid in <foreach collection="uidList" item="item" open="(" separator="," close=")">#{item}</foreach>
    </select>

    <insert id="insertAdHtmlClickLog" parameterType="AdHtmlClickLog" useGeneratedKeys="true" keyProperty="id">
        insert into ad_html_click_log
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="url != null">url,</if>
            <if test="htmlNo != null">html_no,</if>
            <if test="vid != null">vid,</if>
            <if test="clickType != null">click_type,</if>
            <if test="isUpload != null">is_upload,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null">create_by,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="url != null">#{url},</if>
            <if test="htmlNo != null">#{htmlNo},</if>
            <if test="vid != null">#{vid},</if>
            <if test="clickType != null">#{clickType},</if>
            <if test="isUpload != null">#{isUpload},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateAdHtmlClickLog" parameterType="AdHtmlClickLog">
        update ad_html_click_log
        <trim prefix="SET" suffixOverrides=",">
            <if test="url != null">url = #{url},</if>
            <if test="htmlNo != null">html_no = #{htmlNo},</if>
            <if test="vid != null">vid = #{vid},</if>
            <if test="clickType != null">click_type = #{clickType},</if>
            <if test="isUpload != null">is_upload = #{isUpload},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAdHtmlClickLogById" parameterType="Long">
        delete from ad_html_click_log where id = #{id}
    </delete>

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