<?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.xhkjedu.sexam.mapper.system.UserMapper">
    <!--根据用户ids查找手机号-->
    <select id="listPhoneByUserIds" resultType="com.xhkjedu.sexam.vo.system.UserVo">
        select userid,userphone from t_user where userid in
        <foreach collection="userids" item="userid" open="(" separator="," close=")">
            ${userid}
        </foreach>
    </select>
    <!--获取考生-->
    <select id="listStuByExamId" resultType="com.xhkjedu.sexam.vo.system.UserVo">
        select u.userid,u.userphone,ec.classid
        from e_class ec left join t_class_student cs on ec.classid = cs.classid
        left join t_user u on cs.studentid = u.userid
        where ec.examid=#{examid}
    </select>
    <!--获取考试班级任教老师-->
    <select id="listTeacherByClassIds" resultType="com.xhkjedu.sexam.vo.system.UserVo">
        select u.userid,u.userphone
        from t_class_teacher ct left join t_user u on ct.teacherid = u.userid
        where ct.classid in(${classids}) and u.userstate=1
        group by u.userid
    </select>
    <!--主监考人查找-->
    <select id="listMasterTeacher" resultType="java.util.Map">
        select u.userid teacherid,u.username,u.loginname,u.usersex,sb.subjectid
        from t_user u left join t_teacher_powersb tp on tp.teacherid=u.userid
        left join t_subject_book sb on tp.lsbid = sb.lsbid
        where u.schoolid=#{schoolid} and u.usertype=1 and u.userstate=1
        group by u.userid
    </select>
    <!--主监考人快捷查找-->
    <select id="listQuickMasterTeacher" resultType="java.util.Map">
        select u.userid teacherid,u.username,u.loginname,u.usersex,sb.subjectid
        from t_user u left join t_teacher_powersb tp on tp.teacherid=u.userid
        left join t_subject_book sb on tp.lsbid = sb.lsbid
        where u.schoolid=#{schoolid} and u.usertype=1 and u.userstate=1 and u.username in
        <foreach collection="usernames" item="username" open="(" separator="," close=")">
            #{username}
        </foreach>
        group by u.userid
    </select>

    <!--根据准考证号获取学生id-->
    <select id="getUseridByExamno" resultType="java.lang.Integer">
        select userid from t_user where examno=#{examno}
    </select>
    <!--根据用户ids查找用户姓名-->
    <select id="listNameByUserIds" resultType="com.xhkjedu.sexam.vo.system.UserVo">
        select userid,username from t_user where userid in
        <foreach collection="userids" item="userid" open="(" separator="," close=")">
            ${userid}
        </foreach>
    </select>
</mapper>
