package com.iailab.module.data.framework.interceptor; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; import java.util.HashMap; import java.util.Map; import java.util.Objects; @Slf4j @Getter @Setter public class CommonData { private static ThreadLocal> threadLocal = new ThreadLocal<>(); /** * 添加数据 * @param key * @param value */ public static void set(String key, Object value) { if (threadLocal.get() == null) { Map map = new HashMap<>(); threadLocal.set(map); } threadLocal.get().put(key, value); } /** * 清除数据 */ public static void clearAll() { threadLocal.set(null); } public static Map getSignParam() { Object o = threadLocal.get().get("param"); if (Objects.isNull(o)) { log.info("CommonData.getSignParam is null"); return null; } return (Map) o; } }