package com.sobot.common.login.db;


import com.sobot.common.login.model.LoginUserEntity;

/**
 * 获取当前登录用户信息
 */
public class LoginUserInfoUtils {

    private static LoginUserEntity user;

    public synchronized static LoginUserEntity getUser() {
        if (user == null || user.getAid() == null) {
            user = LoginUserManager.getInstance().getCurUser();
        }
        return user;
    }

    public static void setUser(LoginUserEntity newUser) {
        LoginUserManager.getInstance().deleteAll();
        user = newUser;
        if (user != null) {
            LoginUserManager.getInstance().insert(user);
        } else {
            HostManager.getInstance().deleteAll();
            ServiceInfoManager.getInstance().deleteAll();
        }
    }
}
