<?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.tuoheng.mapper.op.PermissionsMapper">

    <resultMap id="BaseResultMap" type="com.tuoheng.model.entity.Permissions">
        <id property="id" column="id" jdbcType="INTEGER"/>
        <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
        <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
        <result property="createUser" column="create_user" jdbcType="INTEGER"/>
        <result property="updateUser" column="update_user" jdbcType="INTEGER"/>
        <result property="mark" column="mark" jdbcType="TINYINT"/>
        <result property="clientId" column="client_id" jdbcType="VARCHAR"/>
        <result property="code" column="code" jdbcType="VARCHAR"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="remark" column="remark" jdbcType="VARCHAR"/>
        <result property="type" column="type" jdbcType="INTEGER"/>
        <result property="menuId" column="menu_id" jdbcType="INTEGER"/>
        <result property="apiUrl" column="api_url" jdbcType="VARCHAR"/>
    </resultMap>

    <sql id="Base_Column_List">
        id,create_time,update_time,
        create_user,update_user,mark,
        client_id,code,name,
        remark,type,menu_id,
        api_url
    </sql>

    <!--根据role_id获取对应的权限集合-->
    <select id="getOpPermissionsByRoleId" resultType="com.tuoheng.model.entity.Permissions">
        select
        <include refid="Base_Column_List"/>
        from op_permissions
        where mark = 1
        and id in (select permission_id from op_role_permission where role_id = #{roleId} and mark = 1)
    </select>


</mapper>
