<?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.FsStoreShopStaffMapper">
    
    <resultMap type="FsStoreShopStaff" id="FsStoreShopStaffResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="nickname"    column="nickname"    />
        <result property="avatar"    column="avatar"    />
        <result property="storeId"    column="store_id"    />
        <result property="storeName"    column="store_name"    />
        <result property="staffName"    column="staff_name"    />
        <result property="phone"    column="phone"    />
        <result property="verifyStatus"    column="verify_status"    />
        <result property="status"    column="status"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="isDel"    column="is_del"    />
    </resultMap>

    <sql id="selectFsStoreShopStaffVo">
        select id, user_id, nickname, avatar, store_id, store_name, staff_name, phone, verify_status, status, create_time, update_time, is_del from fs_store_shop_staff
    </sql>

    <select id="selectFsStoreShopStaffList" parameterType="FsStoreShopStaff" resultMap="FsStoreShopStaffResult">
        <include refid="selectFsStoreShopStaffVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="nickname != null  and nickname != ''"> and nickname like concat('%', #{nickname}, '%')</if>
            <if test="avatar != null  and avatar != ''"> and avatar = #{avatar}</if>
            <if test="storeId != null "> and store_id = #{storeId}</if>
            <if test="storeName != null  and storeName != ''"> and store_name like concat('%', #{storeName}, '%')</if>
            <if test="staffName != null  and staffName != ''"> and staff_name like concat('%', #{staffName}, '%')</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="verifyStatus != null "> and verify_status = #{verifyStatus}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
        </where>
    </select>
    
    <select id="selectFsStoreShopStaffById" parameterType="Long" resultMap="FsStoreShopStaffResult">
        <include refid="selectFsStoreShopStaffVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsStoreShopStaff" parameterType="FsStoreShopStaff" useGeneratedKeys="true" keyProperty="id">
        insert into fs_store_shop_staff
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="nickname != null and nickname != ''">nickname,</if>
            <if test="avatar != null and avatar != ''">avatar,</if>
            <if test="storeId != null">store_id,</if>
            <if test="storeName != null">store_name,</if>
            <if test="staffName != null">staff_name,</if>
            <if test="phone != null">phone,</if>
            <if test="verifyStatus != null">verify_status,</if>
            <if test="status != null">status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="isDel != null">is_del,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="nickname != null and nickname != ''">#{nickname},</if>
            <if test="avatar != null and avatar != ''">#{avatar},</if>
            <if test="storeId != null">#{storeId},</if>
            <if test="storeName != null">#{storeName},</if>
            <if test="staffName != null">#{staffName},</if>
            <if test="phone != null">#{phone},</if>
            <if test="verifyStatus != null">#{verifyStatus},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="isDel != null">#{isDel},</if>
         </trim>
    </insert>

    <update id="updateFsStoreShopStaff" parameterType="FsStoreShopStaff">
        update fs_store_shop_staff
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="nickname != null and nickname != ''">nickname = #{nickname},</if>
            <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
            <if test="storeId != null">store_id = #{storeId},</if>
            <if test="storeName != null">store_name = #{storeName},</if>
            <if test="staffName != null">staff_name = #{staffName},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="verifyStatus != null">verify_status = #{verifyStatus},</if>
            <if test="status != null">status = #{status},</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>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteFsStoreShopStaffById" parameterType="Long">
        delete from fs_store_shop_staff where id = #{id}
    </delete>

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