<?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.slive.mapper.system.UserMapper">
    <!--根据用户id获取用户类型-->
    <select id="getUserTypeByUserId" resultType="java.lang.Integer">
        select usertype from t_user where userid=#{userid}
    </select>
    <!--根据用户账号和学校获取用户id-->
    <select id="getUserIdByNameAndSid" resultType="java.lang.Integer">
        select userid from t_user where <if test="schoolid!=null">schoolid=#{schoolid} and </if>loginname=#{loginname}
    </select>
    <!--根据用户id获取姓名-->
    <select id="getUserNameById" resultType="java.lang.String">
        select username from t_user where userid=#{userid}
    </select>
    <!--根据登录名获取学生信息-->
    <select id="getObjByLoginName" resultType="java.util.Map">
        select u.userid,u.usertype,u.userstate,u.schoolid
        from t_user u where u.loginname=#{loginname} limit 1
    </select>
    <!--根据登录名获取学生id和行政和提高班班级id-->
    <select id="getObjByLoginName2" resultType="java.util.Map">
        select u.userid,u.usertype,u.userstate,u.schoolid,group_concat(distinct c.classid) ultype
        from t_user u left join t_class_student cs on u.userid=cs.studentid
        left join t_class c on cs.classid=c.classid and c.classtype in(1,2) and c.classstate=1
        where u.loginname=#{loginname} limit 1
    </select>
    <!--根据登录名获取学生信息-->
    <select id="getObjById" resultType="java.util.Map">
        select u.userid,u.username,u.loginname,u.usertype,u.userstate,u.schoolid
        from t_user u where u.userid=#{userid} limit 1
    </select>
</mapper>
