<?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.sapi.mapper.component.UserComponentMapper">
    <!--删除用户组件-->
    <delete id="deleteByUserid">
        delete from t_user_component where userid=#{userid}
    </delete>

    <!--获取用户组件-->
    <select id="listComponentsByUserid" resultType="java.util.Map">
        select ccode,cwidth,cheight,corder from t_user_component where userid=#{userid} order by corder
    </select>

    <!--获取用户角色权限模块（匹配组件）-->
    <select id="listUserRoleModule" resultType="java.lang.String">
        SELECT m.mabbrevname
        FROM t_role_module rm LEFT JOIN t_module m ON rm.moduleid=m.moduleid
        LEFT JOIN t_user_role ur ON rm.roleid=ur.roleid
        WHERE userid=#{userid} and m.display=1 and rm.belongcode in (1,3)
        and m.mabbrevname is not null and m.mabbrevname!=''
        group by rm.moduleid ORDER BY m.level,m.morder,m.moduleid
    </select>

    <!--获取所有正常状态下老师和学校管理员id-->
    <select id="listAllUserids" resultType="java.lang.Integer">
        select userid from t_user where userstate=1 and usertype in (0,1)
    </select>
</mapper>
