<?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.diagbot.mapper.SysPermissionMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.diagbot.entity.SysPermission">
        <id column="id" property="id"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="gmt_create" property="gmtCreate"/>
        <result column="gmt_modified" property="gmtModified"/>
        <result column="creator" property="creator"/>
        <result column="modifier" property="modifier"/>
        <result column="name" property="name"/>
        <result column="permissionUrl" property="permissionUrl"/>
        <result column="method" property="method"/>
        <result column="descritpion" property="descritpion"/>
    </resultMap>

    <select id="getByUserId" parameterType="java.lang.Long" resultType="com.diagbot.entity.SysPermission">
      select DISTINCT p.permissionUrl, p.method from sys_user u, sys_user_role sru, sys_role_permission rp, sys_permission p
      where u.is_deleted = 'N' and sru.is_deleted = 'N' and rp.is_deleted = 'N' and p.is_deleted = 'N'
      and u.id = sru.user_id and sru.role_id = rp.role_id and rp.permission_id = p.id and u.status = 1
      and u.id= #{userId}
     </select>
</mapper>
