package com.css.simulation.resource.server.infra.oauth;

import api.common.pojo.constants.DictConstants;
import com.css.simulation.resource.server.infra.util.AuthUtil;
import org.springframework.stereotype.Component;

@Component("AuthorityCheck")
public class AuthorityCheck {

    public boolean admin(){
        String roleCode = AuthUtil.getCurrentUserRoleCode();
        switch (roleCode){
            case DictConstants.ROLE_CODE_SYSADMIN:
                return true;
            case DictConstants.ROLE_CODE_ADMIN:
                return true;
            default:
                return false;
        }
    }

    public boolean adminAndUser(){
        String roleCode = AuthUtil.getCurrentUserRoleCode();
        switch (roleCode){
            case DictConstants.ROLE_CODE_SYSADMIN:
                return true;
            case DictConstants.ROLE_CODE_ADMIN:
                return true;
            case DictConstants.ROLE_CODE_UESR:
                return true;
            default:
                return false;
        }
    }
}
