package com.persagy.adm.diagram.frame;

import lombok.Data;

/**
 * bdtp服务请求封装
 */
@Data
public class BdtpRequest {

	private String userId;

	private String appId = "diagram-tool";

	private String groupCode = "0";

	private String projectId = "0";

	private BdtpRequest(){

	}

	public static BdtpRequest get(String groupCode, String projectId, String userId){
		BdtpRequest req = new BdtpRequest();
		req.setGroupCode(groupCode);
		req.setProjectId(projectId);
		req.setUserId(userId);
		return req;
	}

	/**
	 * 线程变量，方便过程中使用请求对象
	 */
	private static ThreadLocal<BdtpRequest> threadLocal = new ThreadLocal<>();

	public static void setCurrent(BdtpRequest bdtpRequest){
		threadLocal.set(bdtpRequest);
	}

	public static BdtpRequest getCurrent(){
		return threadLocal.get();
	}

	public static void removeCurrent(){
		threadLocal.remove();
	}

}
