<?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.FsStoreShopMapper">
    
    <resultMap type="FsStoreShop" id="FsStoreShopResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="introduction"    column="introduction"    />
        <result property="phone"    column="phone"    />
        <result property="address"    column="address"    />
        <result property="detailedAddress"    column="detailed_address"    />
        <result property="image"    column="image"    />
        <result property="latitude"    column="latitude"    />
        <result property="longitude"    column="longitude"    />
        <result property="validTime"    column="valid_time"    />
        <result property="dayTime"    column="day_time"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isShow"    column="is_show"    />
        <result property="isDel"    column="is_del"    />
        <result property="dayTimeEnd"    column="day_time_end"    />
        <result property="dayTimeStart"    column="day_time_start"    />
        <result property="validTimeEnd"    column="valid_time_end"    />
        <result property="validTimeStart"    column="valid_time_start"    />
    </resultMap>

    <sql id="selectFsStoreShopVo">
        select id, name, introduction, phone, address, detailed_address, image, latitude, longitude, valid_time, day_time, create_time, update_time, is_show, is_del, day_time_end, day_time_start, valid_time_end, valid_time_start from fs_store_shop
    </sql>

    <select id="selectFsStoreShopList" parameterType="FsStoreShop" resultMap="FsStoreShopResult">
        <include refid="selectFsStoreShopVo"/>
        <where>  
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="introduction != null  and introduction != ''"> and introduction = #{introduction}</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="address != null  and address != ''"> and address = #{address}</if>
            <if test="detailedAddress != null  and detailedAddress != ''"> and detailed_address = #{detailedAddress}</if>
            <if test="image != null  and image != ''"> and image = #{image}</if>
            <if test="latitude != null  and latitude != ''"> and latitude = #{latitude}</if>
            <if test="longitude != null  and longitude != ''"> and longitude = #{longitude}</if>
            <if test="validTime != null  and validTime != ''"> and valid_time = #{validTime}</if>
            <if test="dayTime != null  and dayTime != ''"> and day_time = #{dayTime}</if>
            <if test="isShow != null "> and is_show = #{isShow}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
            <if test="dayTimeEnd != null "> and day_time_end = #{dayTimeEnd}</if>
            <if test="dayTimeStart != null "> and day_time_start = #{dayTimeStart}</if>
            <if test="validTimeEnd != null "> and valid_time_end = #{validTimeEnd}</if>
            <if test="validTimeStart != null "> and valid_time_start = #{validTimeStart}</if>
        </where>
    </select>
    
    <select id="selectFsStoreShopById" parameterType="Long" resultMap="FsStoreShopResult">
        <include refid="selectFsStoreShopVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsStoreShop" parameterType="FsStoreShop" useGeneratedKeys="true" keyProperty="id">
        insert into fs_store_shop
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,</if>
            <if test="introduction != null and introduction != ''">introduction,</if>
            <if test="phone != null and phone != ''">phone,</if>
            <if test="address != null and address != ''">address,</if>
            <if test="detailedAddress != null and detailedAddress != ''">detailed_address,</if>
            <if test="image != null and image != ''">image,</if>
            <if test="latitude != null and latitude != ''">latitude,</if>
            <if test="longitude != null and longitude != ''">longitude,</if>
            <if test="validTime != null and validTime != ''">valid_time,</if>
            <if test="dayTime != null and dayTime != ''">day_time,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isShow != null">is_show,</if>
            <if test="isDel != null">is_del,</if>
            <if test="dayTimeEnd != null">day_time_end,</if>
            <if test="dayTimeStart != null">day_time_start,</if>
            <if test="validTimeEnd != null">valid_time_end,</if>
            <if test="validTimeStart != null">valid_time_start,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">#{name},</if>
            <if test="introduction != null and introduction != ''">#{introduction},</if>
            <if test="phone != null and phone != ''">#{phone},</if>
            <if test="address != null and address != ''">#{address},</if>
            <if test="detailedAddress != null and detailedAddress != ''">#{detailedAddress},</if>
            <if test="image != null and image != ''">#{image},</if>
            <if test="latitude != null and latitude != ''">#{latitude},</if>
            <if test="longitude != null and longitude != ''">#{longitude},</if>
            <if test="validTime != null and validTime != ''">#{validTime},</if>
            <if test="dayTime != null and dayTime != ''">#{dayTime},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isShow != null">#{isShow},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="dayTimeEnd != null">#{dayTimeEnd},</if>
            <if test="dayTimeStart != null">#{dayTimeStart},</if>
            <if test="validTimeEnd != null">#{validTimeEnd},</if>
            <if test="validTimeStart != null">#{validTimeStart},</if>
         </trim>
    </insert>

    <update id="updateFsStoreShop" parameterType="FsStoreShop">
        update fs_store_shop
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="introduction != null and introduction != ''">introduction = #{introduction},</if>
            <if test="phone != null and phone != ''">phone = #{phone},</if>
            <if test="address != null and address != ''">address = #{address},</if>
            <if test="detailedAddress != null and detailedAddress != ''">detailed_address = #{detailedAddress},</if>
            <if test="image != null and image != ''">image = #{image},</if>
            <if test="latitude != null and latitude != ''">latitude = #{latitude},</if>
            <if test="longitude != null and longitude != ''">longitude = #{longitude},</if>
            <if test="validTime != null and validTime != ''">valid_time = #{validTime},</if>
            <if test="dayTime != null and dayTime != ''">day_time = #{dayTime},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isShow != null">is_show = #{isShow},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="dayTimeEnd != null">day_time_end = #{dayTimeEnd},</if>
            <if test="dayTimeStart != null">day_time_start = #{dayTimeStart},</if>
            <if test="validTimeEnd != null">valid_time_end = #{validTimeEnd},</if>
            <if test="validTimeStart != null">valid_time_start = #{validTimeStart},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsStoreShopById" parameterType="Long">
        delete from fs_store_shop where id = #{id}
    </delete>

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