package com.zhangmeng.admin.manager.utils;

import com.zhangmeng.model.bean.TokenTools;
import com.zhangmeng.model.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.zhangmeng.admin.manager.service.UserService;
import java.util.Map;

@Component
public class UserUtil {

    @Autowired
    private TokenTools tokenTools;

    @Autowired
    private UserService userService;

    public User currentUser() {
        Map<String, Object> userInfo = this.tokenTools.getUserInfo();
        return this.userService.loadUserByUsername(userInfo.get("username").toString());
    }

    public Map<String,Object> claims(){
        return this.tokenTools.getUserInfo();
    }
}
