<?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="jnpf.attendance.mapper.AttendanceUserFaceMapper" >

    <!-- 人脸列表 -->
    <select id="getUserFaceList" resultType="jnpf.model.attendance.vo.UserFaceDetailVo">
        select t.*, uf.F_Id as faceId, uf.F_FaceDataThumbnail as faceDataThumbnail, uf.F_SyncStatus syncStatus, uf.F_LastModifyTime as creatorTime
        from (
        values
        <foreach collection="list" item="item" separator=",">
            row(#{item.userId}, #{item.realName}, #{item.groupName}, #{item.bindingMachine}, #{item.orgName}, #{item.positionName}, #{item.workStatus})
        </foreach>
        ) as t(userId, userName, groupName, bindingMachine, orgName, postName, workStatus)
        left join ftb_attendance_user_face uf on t.userId = uf.F_UserId and uf.F_DeleteMark = 0
        where 1 = 1
        <if test="null != queryDto.userName and '' != queryDto.userName">
            and instr(t.userName, #{queryDto.userName}) > 0
        </if>
        <if test="null != queryDto.setCheck and 1 == queryDto.setCheck">
            and uf.F_FaceData is not null
        </if>
        <if test="null != queryDto.setCheck and 2 == queryDto.setCheck">
            and uf.F_FaceData is null
        </if>
        <if test="0 == queryDto.syncStatus or 1 == queryDto.syncStatus">
            and uf.F_SyncStatus = #{queryDto.syncStatus}
        </if>
        order by uf.F_LastModifyTime desc
    </select>
    <select id="getNoThumbnail" resultType="jnpf.model.attendance.vo.UserFaceDetailVo">
        SELECT F_Id faceId , F_FaceData faceData
        FROM ftb_attendance_user_face
        WHERE F_DeleteMark = 0 AND F_FaceDataThumbnail IS NULL
    </select>
    <update id="updateUserFaceThumbnail">
        UPDATE ftb_attendance_user_face
        SET F_FaceDataThumbnail = #{userFaceDetailVos.faceDataThumbnail}
        WHERE F_Id = #{userFaceDetailVos.faceId}
    </update>
</mapper>