<?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.xintong.visualinspection.dao.master.PermissionDao">
    <select id="findAll"  resultType="com.xintong.visualinspection.bean.Permission">

        SELECT * from sys_permission ;
    </select>

    <select id="findByAdminUserId" parameterType="int" resultType="com.xintong.visualinspection.bean.Permission">
        select p.*
        from sys_permission p
        LEFT JOIN sys_role_user sru on sru.sys_user_id = #{userId}
        LEFT JOIN sys_role r on sru.sys_role_id=r.id
        LEFT JOIN sys_permission_role spr on spr.role_id=r.id
        where p.id =spr.permission_id
    </select>
</mapper>