package com.kcim.common.util;

import cn.dev33.satoken.stp.StpUtil;
import com.kcim.vo.SessionUserVO;

import static com.kcim.common.constants.Constant.USER_PREFIX;

/**
 * @author 李加喜
 * @Package com.imed.costaccount.common.util
 * @date 2021-08-03 8:46
 */
public class UserContext {

    /**
     * 获取当前用户
     */
    public static SessionUserVO getCurrentUser() {
        SessionUserVO user = (SessionUserVO) StpUtil.getSession().get(USER_PREFIX + StpUtil.getLoginId());
        return user;
    }

    /**
     * 获取当前用户所登录的医院id
     */
    public static Long getCurrentLoginHospId() {
        SessionUserVO user = (SessionUserVO) StpUtil.getSession().get(USER_PREFIX + StpUtil.getLoginId());
        return user.getHospId();
    }

    public static Long getHospId() {
        SessionUserVO user = (SessionUserVO) StpUtil.getSession().get(USER_PREFIX + StpUtil.getLoginId());
        return user.getHospId();
    }
}
