<?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.xjrsoft.module.teacher.mapper.XjrUserMapper">
    <select id="getUserIdByClassId" parameterType="java.lang.Long"
            resultType="java.lang.Long">
        SELECT
            t.id
        FROM xjr_user t
                 LEFT JOIN base_student_school_roll t1 ON (t1.user_id = t.id)
        WHERE t.delete_mark = 0 and t1.class_id = #{classId}
        order by t.id;
    </select>

    <select id="getTeacherDeptInfo" parameterType="com.xjrsoft.module.concat.dto.ConcatTreeDto" resultType="com.xjrsoft.module.teacher.entity.XjrUser">
        SELECT t1.id, t1.name,t1.mobile,t2.dept_id as parent_id,t1.gender FROM xjr_user t1
        INNER JOIN xjr_user_dept_relation t2 ON t1.id = t2.user_id
        inner join xjr_department t4 on t2.dept_id = t4.id
        INNER JOIN base_teacher t3 ON t1.id = t3.user_id
        WHERE t1.delete_mark = 0 and t4.delete_mark = 0
        <if test="dto.name != null and dto.name != ''">
            and t1.name like concat('%', #{dto.name}, '%')
        </if>
        <if test="dto.mobile != null and dto.mobile != ''">
            and t1.mobile like concat('%', #{dto.mobile}, '%')
        </if>
    </select>

    <select id="getAttendanceTeacherUser" parameterType="com.xjrsoft.module.attendance.dto.AddAttendanceRuleCategoryDto" resultType="com.xjrsoft.module.concat.vo.ConcatTreeVo">
        SELECT t.id, t.user_name, t.name, t.code, t.nick_name, t.password, t.gender, t.mobile, t.avatar, t.email, t.address,
        t.longitude, t.latitude, t.sort_code, t.remark, t.credential_type, t.credential_number, t.create_user_id, t.create_date,
        t.modify_user_id, t.modify_date, t.delete_mark, t.enabled_mark, t.open_id, t.union_id, t.sign_folder_id, t.sign_password FROM xjr_user t
        LEFT JOIN base_teacher t1 ON (t1.user_id = t.id)
        LEFT JOIN xjr_user_dept_relation t2 ON (t2.user_id = t.id) WHERE t.delete_mark = 0 AND t1.delete_mark = 0
        AND t1.delete_mark = 0
        <!--<if test="dto."></if>-->
    </select>
</mapper>