package com.dxhy.common.controller;

import org.apache.commons.lang3.StringUtils;

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

/**
 * Controller公共组件
 * 
 * @author jiaohongyang
 */
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;
    }
}