<?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.ruoyi.base.mapper.RobotOpsWhitelistMapper">

    <resultMap type="RobotOpsWhitelist" id="RobotOpsWhitelistResult">
        <result property="id"    column="id"    />
        <result property="name"    column="name"    />
        <result property="mobile"    column="mobile"    />
        <result property="idCardNo"    column="id_card_no"    />
        <result property="faceImageUrl"    column="face_image_url"    />
        <result property="validStartTime"    column="valid_start_time"    />
        <result property="validEndTime"    column="valid_end_time"    />
        <result property="status"    column="status"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="whitelistType"    column="whitelist_type"    />
        <result property="sourceType"    column="source_type"    />
    </resultMap>

    <sql id="selectRobotOpsWhitelistVo">
        select id, name, mobile, id_card_no, face_image_url, valid_start_time, valid_end_time, status, remark, create_time, update_time, whitelist_type, source_type from robot_ops_whitelist
    </sql>

    <select id="selectRobotOpsWhitelistList" parameterType="RobotOpsWhitelist" resultMap="RobotOpsWhitelistResult">
        <include refid="selectRobotOpsWhitelistVo"/>
        <where>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="mobile != null  and mobile != ''"> and mobile = #{mobile}</if>
            <if test="idCardNo != null  and idCardNo != ''"> and id_card_no = #{idCardNo}</if>
            <if test="faceImageUrl != null  and faceImageUrl != ''"> and face_image_url = #{faceImageUrl}</if>
            <if test="validStartTime != null "> and valid_start_time = #{validStartTime}</if>
            <if test="validEndTime != null "> and valid_end_time = #{validEndTime}</if>
            <if test="status != null  and status != ''"> and status = #{status}</if>
            <if test="whitelistType != null "> and whitelist_type = #{whitelistType}</if>
            <if test="sourceType != null "> and source_type = #{sourceType}</if>
        </where>
    </select>

    <select id="selectRobotOpsWhitelistById" parameterType="Long" resultMap="RobotOpsWhitelistResult">
        <include refid="selectRobotOpsWhitelistVo"/>
        where id = #{id}
    </select>

    <insert id="insertRobotOpsWhitelist" parameterType="RobotOpsWhitelist" useGeneratedKeys="true" keyProperty="id">
        insert into robot_ops_whitelist
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">name,</if>
            <if test="mobile != null">mobile,</if>
            <if test="idCardNo != null">id_card_no,</if>
            <if test="faceImageUrl != null">face_image_url,</if>
            <if test="validStartTime != null">valid_start_time,</if>
            <if test="validEndTime != null">valid_end_time,</if>
            <if test="status != null and status != ''">status,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="whitelistType != null">whitelist_type,</if>
            <if test="sourceType != null">source_type,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="name != null and name != ''">#{name},</if>
            <if test="mobile != null">#{mobile},</if>
            <if test="idCardNo != null">#{idCardNo},</if>
            <if test="faceImageUrl != null">#{faceImageUrl},</if>
            <if test="validStartTime != null">#{validStartTime},</if>
            <if test="validEndTime != null">#{validEndTime},</if>
            <if test="status != null and status != ''">#{status},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="whitelistType != null">#{whitelistType},</if>
            <if test="sourceType != null">#{sourceType},</if>
        </trim>
    </insert>

    <update id="updateRobotOpsWhitelist" parameterType="RobotOpsWhitelist">
        update robot_ops_whitelist
        <trim prefix="SET" suffixOverrides=",">
            <if test="name != null and name != ''">name = #{name},</if>
            <if test="mobile != null">mobile = #{mobile},</if>
            <if test="idCardNo != null">id_card_no = #{idCardNo},</if>
            <if test="faceImageUrl != null">face_image_url = #{faceImageUrl},</if>
            <if test="validStartTime != null">valid_start_time = #{validStartTime},</if>
            <if test="validEndTime != null">valid_end_time = #{validEndTime},</if>
            <if test="status != null and status != ''">status = #{status},</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="whitelistType != null">whitelist_type = #{whitelistType},</if>
            <if test="sourceType != null">source_type = #{sourceType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteRobotOpsWhitelistById" parameterType="Long">
        delete from robot_ops_whitelist where id = #{id}
    </delete>

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