<?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.FsStoreOrderNoticeMapper">
    
    <resultMap type="FsStoreOrderNotice" id="FsStoreOrderNoticeResult">
        <result property="id"    column="id"    />
        <result property="nickName"    column="nick_name"    />
        <result property="openId"    column="open_id"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="isEnable"    column="is_enable"    />
    </resultMap>

    <sql id="selectFsStoreOrderNoticeVo">
        select id, nick_name, open_id, remark, create_time, update_time, is_del, is_enable from fs_store_order_notice
    </sql>

    <select id="selectFsStoreOrderNoticeList" parameterType="FsStoreOrderNotice" resultMap="FsStoreOrderNoticeResult">
        <include refid="selectFsStoreOrderNoticeVo"/>
        <where>  
            <if test="nickName != null  and nickName != ''"> and nick_name like concat('%', #{nickName}, '%')</if>
            <if test="openId != null  and openId != ''"> and open_id = #{openId}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
            <if test="isEnable != null "> and is_enable = #{isEnable}</if>
        </where>
    </select>
    
    <select id="selectFsStoreOrderNoticeById" parameterType="Long" resultMap="FsStoreOrderNoticeResult">
        <include refid="selectFsStoreOrderNoticeVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsStoreOrderNotice" parameterType="FsStoreOrderNotice" useGeneratedKeys="true" keyProperty="id">
        insert into fs_store_order_notice
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="nickName != null">nick_name,</if>
            <if test="openId != null">open_id,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="isEnable != null">is_enable,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="nickName != null">#{nickName},</if>
            <if test="openId != null">#{openId},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="isEnable != null">#{isEnable},</if>
         </trim>
    </insert>

    <update id="updateFsStoreOrderNotice" parameterType="FsStoreOrderNotice">
        update fs_store_order_notice
        <trim prefix="SET" suffixOverrides=",">
            <if test="nickName != null">nick_name = #{nickName},</if>
            <if test="openId != null">open_id = #{openId},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="isEnable != null">is_enable = #{isEnable},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsStoreOrderNoticeById" parameterType="Long">
        delete from fs_store_order_notice where id = #{id}
    </delete>

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