package com.hfkj.dao;

import com.hfkj.entity.SecPermission;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;

import java.util.List;

/**
 * mapper扩展类
 */
public interface SecRolePermissionRelMapperExt {


    @Select({"<script>" +
            "SELECT sp.* FROM " +
            "sec_permission sp " +
            "LEFT JOIN sec_role_permission_rel rpr ON sp.id = rpr.permission_id " +
            "LEFT JOIN sec_user_role_rel urr ON urr.role_id = rpr.role_id where urr.user_id = #{userId}" +
            " </script>"})
    @Results({
            @Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
            @Result(column="permission_name", property="permissionName", jdbcType=JdbcType.VARCHAR),
            @Result(column="permission_code", property="permissionCode", jdbcType=JdbcType.VARCHAR),
            @Result(column="permission_desc", property="permissionDesc", jdbcType=JdbcType.VARCHAR),
            @Result(column="sort", property="sort", jdbcType=JdbcType.INTEGER),
            @Result(column="menu_id", property="menuId", jdbcType=JdbcType.BIGINT)
    })
    List<SecPermission> getPermissionListByUserId(@Param("userId") Long userId);
}
