package cn.cslg.pas.common.utils.SecurityUtils;

import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Component
public class SecurityUtils {
    @Resource
    private LoginUtils loginUtils;
    protected static final ThreadLocal<Map<String, Object>> threadLocal = new ThreadLocal<>();

    /**
     * 设置权限标识
     */
    public void startDataScope(String Function) {
        Map<String, Object> m = new HashMap<>();
        m.put("token", LoginUtils.getToken());
        m.put("loginId", loginUtils.getId());
        m.put("functionId", Function);
        threadLocal.set(m);
    }

    /**
     * 获取权限标识
     */
    public static Map<String, Object> getDataScope() {
        return threadLocal.get();
    }

    /**
     * 清除权限标识
     */
    public static void cleanDataScope() {
        threadLocal.remove();
    }


}
