package com.live.utils;

import java.util.Hashtable;

public class CommonLoginInfo {
    private Hashtable<String, CommonRequestParameters> loginInfoMap ;
    public Hashtable<String, CommonRequestParameters> getLoginInfoMap() {
        return loginInfoMap;
    }

    public void setLoginInfoMap(Hashtable<String, CommonRequestParameters> loginInfoMap) {
        this.loginInfoMap = new Hashtable<String, CommonRequestParameters>();
    }

    public void add(String loginUser, CommonRequestParameters loginInfo){
        if(null == loginInfoMap){
            loginInfoMap =  new Hashtable<String, CommonRequestParameters>();
        }
        this.loginInfoMap.put(loginUser,loginInfo);
    }

    public CommonRequestParameters get(String loginUser){
        if(null == loginInfoMap){
            return  new CommonRequestParameters();
        }
        if(null ==loginInfoMap.get(loginUser) ){
            return  new CommonRequestParameters();
        }
        return loginInfoMap.get(loginUser);
    }

    /**
     * 获取登录信息user   未取到信息将自动返回一个 空对象。 使用时自行处理判断
     * @param loginUser
     * @return
     */
    public static CommonRequestParameters getLoginUser(String loginUser){
        com.live.utils.CommonLoginInfo _loginInfoMap = (com.live.utils.CommonLoginInfo) SpringContextUtil.getBean("commonLoginInfoMap");
        CommonRequestParameters loginInfo = _loginInfoMap.get(loginUser);
        return  loginInfo;
    }
}
