package com.dxhy.common.controller;
import com.dxhy.api.model.config.UserInfo;
import org.apache.commons.lang3.StringUtils;

import com.alibaba.fastjson.JSON;
import com.dxhy.common.utils.BaseContextHandler;

/**
 * Controller公共组件
 * 
 * @author Allen
 */
public abstract class AbstractController {

    public String getUserName() {
        return BaseContextHandler.getUsername();
    }

    public String getLoginName() {
        return BaseContextHandler.getLonginname();
    }

    public String getUserId() {
        return BaseContextHandler.getUserID();
    }

    public UserInfo getUserInfo() {
        String userInfo = BaseContextHandler.getUserInfo();
        UserInfo user = null;
        if (StringUtils.isNotBlank(userInfo)) {
            user = JSON.parseObject(userInfo, UserInfo.class);
        }
        return user;
    }

    public String getToken() {
        return BaseContextHandler.getToken();
    }
}