package com.dayou.utils;

/**
 * 权限拦截标识上下文
 *
 * @Auther: wucl
 * @Date: 2019/1/8 0008
 */
public class PermissionContext {

    private static final ThreadLocal<Boolean> permissionThreadLocal = new ThreadLocal<>();

    public static void setFlag(Boolean flag) {
        permissionThreadLocal.set(flag);
    }

    public static Boolean getFlag() {
        return permissionThreadLocal.get();
    }

    public static void removeAll() {
        permissionThreadLocal.remove();
    }

    /**
     * flag=true(将被放行 不执行权限)
     * 返回 true   将拦截 否则放行
     *
     * @return
     */
    public static boolean isReleasePermission() {
        return !Boolean.TRUE.equals(permissionThreadLocal.get());
    }
}
