<?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.store.mapper.FsAdvMapper">

    <resultMap type="FsAdv" id="FsAdvResult">
        <result property="advId"    column="adv_id"    />
        <result property="advTitle"    column="adv_title"    />
        <result property="urlType"    column="url_type"    />
        <result property="imageUrl"    column="image_url"    />
        <result property="advUrl"    column="adv_url"    />
        <result property="content"    column="content"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="status"    column="status"    />
        <result property="sort"    column="sort"    />
        <result property="advType"    column="adv_type"    />
        <result property="showType"    column="show_type"    />
    </resultMap>

    <sql id="selectFsAdvVo">
        select adv_id, adv_title,url_type, image_url, adv_url, content, create_time, update_time, status, sort, adv_type, show_type from fs_adv
    </sql>

    <select id="selectFsAdvList" parameterType="FsAdv" resultMap="FsAdvResult">
        <include refid="selectFsAdvVo"/>
        <where>
            <if test="advTitle != null  and advTitle != ''"> and adv_title = #{advTitle}</if>
            <if test="imageUrl != null  and imageUrl != ''"> and image_url = #{imageUrl}</if>
            <if test="advUrl != null  and advUrl != ''"> and adv_url = #{advUrl}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="advType != null "> and adv_type = #{advType}</if>
            <if test="showType != null "> and show_type = #{showType}</if>
            <if test="urlType != null "> and url_type = #{urlType}</if>
        </where>
    </select>

    <select id="selectFsAdvById" parameterType="Long" resultMap="FsAdvResult">
        <include refid="selectFsAdvVo"/>
        where adv_id = #{advId}
    </select>

    <insert id="insertFsAdv" parameterType="FsAdv" useGeneratedKeys="true" keyProperty="advId">
        insert into fs_adv
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="advTitle != null and advTitle != ''">adv_title,</if>
            <if test="imageUrl != null">image_url,</if>
            <if test="urlType != null">url_type,</if>
            <if test="advUrl != null">adv_url,</if>
            <if test="content != null">content,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="status != null">status,</if>
            <if test="sort != null">sort,</if>
            <if test="advType != null">adv_type,</if>
            <if test="showType != null">show_type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="advTitle != null and advTitle != ''">#{advTitle},</if>
            <if test="imageUrl != null">#{imageUrl},</if>
            <if test="urlType != null">#{urlType},</if>
            <if test="advUrl != null">#{advUrl},</if>
            <if test="content != null">#{content},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="status != null">#{status},</if>
            <if test="sort != null">#{sort},</if>
            <if test="advType != null">#{advType},</if>
            <if test="showType != null">#{showType},</if>
         </trim>
    </insert>

    <update id="updateFsAdv" parameterType="FsAdv">
        update fs_adv
        <trim prefix="SET" suffixOverrides=",">
            <if test="advTitle != null and advTitle != ''">adv_title = #{advTitle},</if>
            <if test="imageUrl != null">image_url = #{imageUrl},</if>
            <if test="urlType != null">url_type = #{urlType},</if>
            <if test="advUrl != null">adv_url = #{advUrl},</if>
            <if test="content != null">content = #{content},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="advType != null">adv_type = #{advType},</if>
            <if test="showType != null">show_type = #{showType},</if>
        </trim>
        where adv_id = #{advId}
    </update>

    <delete id="deleteFsAdvById" parameterType="Long">
        delete from fs_adv where adv_id = #{advId}
    </delete>

    <delete id="deleteFsAdvByIds" parameterType="String">
        delete from fs_adv where adv_id in
        <foreach item="advId" collection="array" open="(" separator="," close=")">
            #{advId}
        </foreach>
    </delete>

</mapper>
