<?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.hccake.ballcat.admin.modules.sys.mapper.SysPermissionMapper">

	<!-- 通用查询映射结果 -->
	<resultMap id="BaseResultMap" type="com.hccake.ballcat.admin.modules.sys.model.entity.SysPermission">
        <id column="id" property="id"/>
        <result column="title" property="title"/>
        <result column="code" property="code"/>
        <result column="path" property="path"/>
        <result column="router_name" property="routerName"/>
        <result column="component" property="component"/>
        <result column="redirect" property="redirect"/>
        <result column="parent_id" property="parentId"/>
        <result column="icon" property="icon"/>
        <result column="sort" property="sort"/>
        <result column="keep_alive" property="keepAlive"/>
        <result column="hidden" property="hidden"/>
        <result column="type" property="type"/>
        <result column="del_flag" property="delFlag"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
    </resultMap>


	<!--通过角色查询菜单信息-->
	<select id="listPermissionVOsByRoleId" resultType="com.hccake.ballcat.admin.modules.sys.model.vo.PermissionVO">
		SELECT
			m.*
		FROM
			sys_permission m
		LEFT JOIN sys_role_permission rm ON m.id = rm.permission_id
		WHERE
			m.del_flag = 0
		AND rm.role_id = #{roleId}
		ORDER BY
			m.sort DESC
    </select>

	<!--通过角色ID 查询权限-->
	<select id="listPermissionsByRoleIds" resultType="java.lang.String">
        SELECT
            m.sysPermission
        FROM
        	sys_permission m, sys_role_permission rm
        WHERE
        	m.id = rm.permission_id
        AND m.del_flag = 0
        AND rm.role_id IN (#{roleIds})
    </select>
</mapper>
