package com.starry.admin.common.conf;

import com.alibaba.ttl.TransmittableThreadLocal;
import com.starry.admin.modules.clerk.module.entity.PlayClerkUserInfoEntity;
import com.starry.admin.modules.custom.module.entity.PlayCustomUserInfoEntity;

/**
 * @author : huchuansai
 * @since : 2024/4/2 12:10 AM
 */
public class ThreadLocalRequestDetail {
    private static final TransmittableThreadLocal<Object> THREAD_LOCAL = new TransmittableThreadLocal<>();

    /**
     * 设置请求信息到当前线程中
     */
    public static void setRequestDetail(Object data) {
        THREAD_LOCAL.set(data);
    }

    /**
     * 从当前线程中获取请求信息
     */
    public static Object getRequestDetail() {
        return THREAD_LOCAL.get();
    }

    public static PlayClerkUserInfoEntity getClerkUserInfo() {
        return (PlayClerkUserInfoEntity) THREAD_LOCAL.get();
    }

    public static PlayCustomUserInfoEntity getCustomUserInfo() {
        return (PlayCustomUserInfoEntity) THREAD_LOCAL.get();
    }

    /**
     * 销毁
     */
    public static void remove() {
        THREAD_LOCAL.remove();
    }

}
