<?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.yx.face.dao.SystemLongTermDocumentsDao">
    <update id="updateListSn">
        UPDATE face_device SET state= '1' WHERE sn  = #{sn}
    </update>

    <select id="getList" resultType="com.yx.face.model.vo.SystemLongTermDocumentsVO">
        SELECT a.id,
        a.name,
        a.photo,
        a.id_number AS idNumber,
        a.create_time AS createTime,
        a.expire_time AS expireTime,
        a.phone,
        a.admin_id AS adminId,
        a.card_no   AS   cardNo,
        b.username
        FROM system_long_term_documents AS a
        LEFT JOIN admin AS b on a.admin_id = b.id
        <where>
            <if test="adminId != null ">
                and a.admin_id = #{adminId}
            </if>
            <if test="name != null and name != ''">
                and a.name like concat('%',#{name},'%')
            </if>
        </where>

    </select>

    <select id="getByIdNumber" resultType="com.yx.face.model.entity.SystemLongTermDocuments">
        SELECT id
        FROM system_long_term_documents
        where id_number=#{idNumber}
    </select>
    <select id="getIdByPhone" resultType="com.yx.face.model.entity.SystemLongTermDocuments">
        SELECT id
        FROM system_long_term_documents
        where photo=#{photo}
    </select>
    <select id="getIdByIdNumber" resultType="java.lang.Long">
        SELECT id
        FROM system_long_term_documents
        where id_number=#{idNumber}
    </select>
</mapper>

