<?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.dcsoft.system.visitor.mapper.VisVisitorExamineMapper">

    <resultMap type="VisVisitorExamine" id="VisVisitorExamineResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="phone"    column="phone"    />
        <result property="visitorId"    column="visitor_id"    />
        <result property="admittanceStart"    column="admittance_start"    />
        <result property="admittanceEnd"    column="admittance_end"    />
        <result property="spaceId"    column="space_id"    />
        <result property="pointId"    column="point_id"    />
        <result property="type"    column="type"    />
        <result property="permission"    column="permission"    />
        <result property="remark"    column="remark"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="examine"    column="examine"    />
        <result property="ruleId"    column="rule_id"    />

    </resultMap>

    <sql id="selectVisVisitorExamineVo">
        select id, name, phone, visitor_id, admittance_start, admittance_end, space_id, point_id, type, permission, remark, create_by, create_time, update_by, update_time,examine,rule_id from vis_visitor_examine
    </sql>

    <select id="selectVisVisitorExamineList" parameterType="VisVisitorExamine" resultMap="VisVisitorExamineResult">
        <include refid="selectVisVisitorExamineVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="phone != null  and phone != ''"> and phone = #{phone}</if>
            <if test="visitorId != null "> and visitor_id = #{visitorId}</if>
            <if test="admittanceStart != null  and admittanceStart != ''"> and admittance_start = #{admittanceStart}</if>
            <if test="admittanceEnd != null  and admittanceEnd != ''"> and admittance_end = #{admittanceEnd}</if>
            <if test="spaceId != null "> and space_id = #{spaceId}</if>
            <if test="pointId != null  and pointId != ''"> and point_id = #{pointId}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="permission != null  and permission != ''"> and permission = #{permission}</if>
        </where>
    </select>

    <select id="selectVisVisitorExamineById" parameterType="Long" resultMap="VisVisitorExamineResult">
        <include refid="selectVisVisitorExamineVo"/>
        where id = #{id}
    </select>

    <insert id="insertVisVisitorExamine" parameterType="VisVisitorExamine" useGeneratedKeys="true" keyProperty="id">
        insert into vis_visitor_examine
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,</if>
            <if test="phone != null">phone,</if>
            <if test="visitorId != null">visitor_id,</if>
            <if test="admittanceStart != null">admittance_start,</if>
            <if test="admittanceEnd != null">admittance_end,</if>
            <if test="spaceId != null">space_id,</if>
            <if test="pointId != null">point_id,</if>
            <if test="type != null">type,</if>
            <if test="permission != null">permission,</if>
            <if test="remark != null">remark,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="examine != null">examine,</if>
            <if test="ruleId != null">rule_id,</if>

        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">#{name},</if>
            <if test="phone != null">#{phone},</if>
            <if test="visitorId != null">#{visitorId},</if>
            <if test="admittanceStart != null">#{admittanceStart},</if>
            <if test="admittanceEnd != null">#{admittanceEnd},</if>
            <if test="spaceId != null">#{spaceId},</if>
            <if test="pointId != null">#{pointId},</if>
            <if test="type != null">#{type},</if>
            <if test="permission != null">#{permission},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="examine != null">#{examine},</if>
            <if test="ruleId != null">#{ruleId},</if>

        </trim>
    </insert>

    <update id="updateVisVisitorExamine" parameterType="VisVisitorExamine">
        update vis_visitor_examine
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="phone != null">phone = #{phone},</if>
            <if test="visitorId != null">visitor_id = #{visitorId},</if>
            <if test="admittanceStart != null">admittance_start = #{admittanceStart},</if>
            <if test="admittanceEnd != null">admittance_end = #{admittanceEnd},</if>
            <if test="spaceId != null">space_id = #{spaceId},</if>
            <if test="pointId != null">point_id = #{pointId},</if>
            <if test="type != null">type = #{type},</if>
            <if test="permission != null">permission = #{permission},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="examine != null">examine = #{examine},</if>
            <if test="ruleId != null">rule_id = #{ruleId},</if>

        </trim>
        where id = #{id}
    </update>

    <delete id="deleteVisVisitorExamineById" parameterType="Long">
        delete from vis_visitor_examine where id = #{id}
    </delete>

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

    <delete id="deleteVisVisitorExamineByVisitorId" parameterType="Long">
        delete from vis_visitor_examine where visitor_id = #{visitorId}
    </delete>
</mapper>
