<?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.app.mapper.NFIDReaderMapper">
    
    <resultMap type="NFIDReader" id="NFIDReaderResult">
    	<id     property="id"      column="id"      />
        <result property="deviceSerial"    column="device_serial"    />
        <result property="deviceName"     column="device_name"     />
        <result property="deviceSpot"     column="device_spot"     />
        <result property="lastActiveTime"     column="last_active_time"     />
        <result property="status"     column="status"     />
    </resultMap>


    <select id="selectNFIDReaderList" resultMap="NFIDReaderResult">
        select id, device_serial,device_name, device_spot,last_active_time,status
        from nfid_reader
    </select>
    
    <select id="selectNFIDReaderByDeviceSerial" parameterType="String" resultMap="NFIDReaderResult">
        select id, device_serial,device_name, device_spot,last_active_time,status
        from nfid_reader
        where device_serial = #{deviceSerial}
    </select>

    <insert id="insertNFIDReader" parameterType="NFIDReader" useGeneratedKeys="true" keyProperty="id">
        insert into nfid_reader
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deviceSerial != null">device_serial,</if>
            <if test="deviceName != null">device_name,</if>
            <if test="deviceSpot != null">device_spot,</if>
            <if test="lastActiveTime != null">last_active_time,</if>
            <if test="status != null">status,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deviceSerial != null">#{deviceSerial},</if>
            <if test="deviceName != null">#{deviceName},</if>
            <if test="deviceSpot != null">#{deviceSpot},</if>
            <if test="lastActiveTime != null">#{lastActiveTime},</if>
            <if test="status != null">#{status},</if>
        </trim>
    </insert>

    <update id="updateNFIDReaderBySerial" parameterType="NFIDReader">
        update nfid_reader
        <trim prefix="SET" suffixOverrides=",">
            <if test="lastActiveTime != null">last_active_time = #{lastActiveTime},</if>
            <if test="status != null">status = #{status},</if>
        </trim>
        where device_serial = #{deviceSerial}
    </update>
    
</mapper>