<?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.bonus.bracelet.mapper.TemporarilyPersonMapper">
    <update id="updateBracelet">
        UPDATE tb_bracelet SET peopel_type = null,bid_id = null,bid_time = null,face_status = null WHERE id = #{id}
    </update>
    <!--删除临时人员-->
    <delete id="delTemporarilyPerson">
        DELETE FROM tb_ls_user WHERE id = #{id}
    </delete>

    <!--临时人员列表-->
    <select id="getTemporarilyPersons" resultType="com.bonus.common.entity.bracelet.vo.PersonVo">
        SELECT tls.id,
        tls.name,
        tls.sex,
        tls.id_card AS idCard,
        tls.phone,
        sfs.file_path AS filePath,
        sfs.id AS fileId,
        twt.team_name AS teamName
        FROM tb_ls_user tls
        LEFT JOIN t_work_team twt ON tls.team_id = twt.team_id AND twt.del_flag = 0
        LEFT JOIN sys_file_source sfs ON tls.id = sfs.source_id AND sfs.source_type = #{sourceType} AND sfs.del_flag = 0
        <where>
            <if test="keyWord != null and keyWord!=''">
                (
                INSTR(tls.name,#{keyWord}) > 0 OR
                INSTR(twt.team_name,#{keyWord}) > 0
                )
            </if>
        </where>
    </select>
    <!--查询临时人员绑定的手环设备-->
    <select id="getBraceletByTemporarilyPerson" resultType="java.lang.Long">
        SELECT id FROM tb_bracelet WHERE bid_id = #{id} AND peopel_type = 1
    </select>
</mapper>