<?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.ics.admin.mapper.meeting.StaffOpenMapper">
    
    <resultMap type="com.ics.admin.domain.meeting.StaffOpen" id="StaffOpenResult">
        <result property="id"    column="id"    />
        <result property="openid"    column="openid"    />
        <result property="staffId"    column="staff_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="deleteFlag"    column="delete_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="tenantId"    column="tenant_id"    />
        <result property="parkId"    column="park_id"    />
    </resultMap>

    <sql id="selectStaffOpenVo">
        SELECT id, openid, staff_id, create_time, delete_flag, create_by, tenant_id, park_id FROM tb_staff_open
    </sql>

    <select id="selectStaffOpenList" parameterType="StaffOpen" resultMap="StaffOpenResult">
        <include refid="selectStaffOpenVo"/>
        <where>  
        </where>
    </select>
    
    <select id="selectStaffOpenById" parameterType="Long" resultMap="StaffOpenResult">
        <include refid="selectStaffOpenVo"/>
        WHERE id = #{id}
    </select>
    <select id="selectStaffOpenByOpenId" resultType="com.ics.admin.domain.meeting.StaffOpen">
        SELECT * FROM tb_staff_open WHERE openid = #{openid}
    </select>

    <select id="selectStaffOpenByStaffIdAndOpenId" resultType="com.ics.admin.domain.meeting.StaffOpen">
        SELECT * FROM tb_staff_open WHERE staff_id = #{staffId} AND openid = #{openid}
    </select>

    <insert id="insertStaffOpen" parameterType="StaffOpen" useGeneratedKeys="true" keyProperty="id">
        INSERT INTO tb_staff_open
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="openid != null  and openid != ''">openid,</if>
            <if test="staffId != null ">staff_id,</if>
            <if test="createTime != null ">create_time,</if>
            <if test="deleteFlag != null  and deleteFlag != ''">delete_flag,</if>
            <if test="createBy != null  and createBy != ''">create_by,</if>
            <if test="tenantId != null ">tenant_id,</if>
            <if test="parkId != null ">park_id,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="openid != null  and openid != ''">#{openid},</if>
            <if test="staffId != null ">#{staffId},</if>
            <if test="createTime != null ">#{createTime},</if>
            <if test="deleteFlag != null  and deleteFlag != ''">#{deleteFlag},</if>
            <if test="createBy != null  and createBy != ''">#{createBy},</if>
            <if test="tenantId != null ">#{tenantId},</if>
            <if test="parkId != null ">#{parkId},</if>
         </trim>
    </insert>

    <update id="updateStaffOpen" parameterType="StaffOpen">
        UPDATE tb_staff_open
        <trim prefix="SET" suffixOverrides=",">
            <if test="openid != null  and openid != ''">openid = #{openid},</if>
            <if test="staffId != null ">staff_id = #{staffId},</if>
            <if test="createTime != null ">create_time = #{createTime},</if>
            <if test="deleteFlag != null  and deleteFlag != ''">delete_flag = #{deleteFlag},</if>
            <if test="createBy != null  and createBy != ''">create_by = #{createBy},</if>
            <if test="tenantId != null ">tenant_id = #{tenantId},</if>
            <if test="parkId != null ">park_id = #{parkId},</if>
        </trim>
        WHERE id = #{id}
    </update>

    <delete id="deleteStaffOpenById" parameterType="Long">
        DELETE FROM tb_staff_open WHERE id = #{id}
    </delete>

    <delete id="deleteStaffOpenByIds" parameterType="String">
        DELETE FROM tb_staff_open where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    
</mapper>