package com.cool.store.context;

import com.alibaba.fastjson.JSON;
import com.cool.store.vo.PartnerUserInfoVO;
import org.apache.commons.lang3.StringUtils;

/**
 * C端登录用户信息
 */
public class PartnerUserHolder {

    private static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();

    public static PartnerUserInfoVO getUser() {
       String userStr = contextHolder.get();
        if (StringUtils.isNotBlank(userStr)) {
            return JSON.parseObject(userStr, PartnerUserInfoVO.class);
        }
        return new PartnerUserInfoVO();
    }

    public static void setUser(String user) {
        contextHolder.set(user);
    }

    public static void removeUser(){
        contextHolder.remove();
    }



}


