<?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.AdHtmlTemplateMapper">
    
    <resultMap type="AdHtmlTemplate" id="AdHtmlUrlResult">
        <result property="id"    column="id"    />
        <result property="no"    column="no"    />
        <result property="name"    column="name"    />
        <result property="images"    column="images"    />
        <result property="dataJson"    column="data_json"    />
        <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="selectAdHtmlUrlVo">
        select * from ad_html_template
    </sql>

    <select id="selectAdHtmlUrlList" parameterType="AdHtmlTemplate" resultType="AdHtmlTemplate">
        <include refid="selectAdHtmlUrlVo"/>
        <where>  
            <if test="no != null  and no != ''"> and no = #{no}</if>
            <if test="images != null  and images != ''"> and images = #{images}</if>
        </where>
    </select>
    
    <select id="selectAdHtmlUrlById" parameterType="Long" resultType="AdHtmlTemplate">
        <include refid="selectAdHtmlUrlVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertAdHtmlUrl" parameterType="AdHtmlTemplate" useGeneratedKeys="true" keyProperty="id">
        insert into ad_html_template
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="no != null">no,</if>
            <if test="images != null">images,</if>
            <if test="name != null">name,</if>
            <if test="url != null">url,</if>
            <if test="dataJson != null">data_json,</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="no != null">#{no},</if>
            <if test="images != null">#{images},</if>
            <if test="name != null">#{name},</if>
            <if test="url != null">#{url},</if>
            <if test="dataJson != null">#{dataJson},</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="updateAdHtmlUrl" parameterType="AdHtmlTemplate">
        update ad_html_template
        <trim prefix="SET" suffixOverrides=",">
            <if test="no != null">no = #{no},</if>
            <if test="images != null">images = #{images},</if>
            <if test="url != null">url = #{url},</if>
            <if test="dataJson != null">data_json = #{dataJson},</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="deleteAdHtmlUrlById" parameterType="Long">
        delete from ad_html_template where id = #{id}
    </delete>

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