<?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.qmth.teachcloud.common.mapper.SysPrivilegeMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.qmth.teachcloud.common.entity.SysPrivilege">
    <result column="id" property="id" />
        <result column="name" property="name" />
        <result column="url" property="url" />
        <result column="type" property="type" />
        <result column="parent_id" property="parentId" />
        <result column="sequence" property="sequence" />
        <result column="property" property="property" />
        <result column="related" property="related" />
        <result column="enable" property="enable" />
        <result column="create_time" property="createTime" />
    </resultMap>

    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id,
        school_id, name, url, type, parent_id, sequence, property, related, create_id, create_time, update_id, update_time
    </sql>
    <select id="getClientUrlByUserId" resultMap="BaseResultMap">
        SELECT
            *
        FROM
            sys_privilege sp
                JOIN
            sys_role_privilege srp ON sp.id = srp.privilege_id
                JOIN
            sys_user_role sur ON srp.role_id = sur.role_id
        WHERE
            sur.user_id = #{userId}
    </select>

</mapper>
