package com.changfa.base;

import com.alibaba.fastjson.JSON;
import com.changfa.dto.UserBaseDto;
import com.changfa.entity.TUser;
import com.changfa.utils.JwtUtil;
import org.apache.shiro.SecurityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


public abstract class BaseController {

    protected  final Logger log = LoggerFactory.getLogger(this.getClass());

    public static UserBaseDto userBaseInfo(){
        return JSON.parseObject(JwtUtil.getTokenData(SecurityUtils.getSubject().getSession().getId().toString()).toString(), UserBaseDto.class);
    }

    public static TUser currentUser(){
        return JSON.parseObject(JwtUtil.getTokenData(SecurityUtils.getSubject().getSession().getId().toString()).toString(), UserBaseDto.class).getUser();
    }

}
