package com.ruoyi.common.utils;

import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;

import java.util.List;

public class TmznTool {

    /**
     * 判断是否具有某个角色
     * @param user
     * @param rolaName
     * @return
     */
    public static boolean hasRole(SysUser user,String rolaName){
        List<SysRole> roles = user.getRoles();
        for (int i = 0; i < roles.size(); i++) {
            if (roles.get(i).getRoleKey().equals(rolaName)) {
                return true;
            }
        }
        return false;
    }


    /**
     * 是否是管理员
     * @param user
     * @return
     */
    public static boolean isAdmin(SysUser user){
        return hasRole(user,"admin");
    }



}
