|
|
@@ -0,0 +1,45 @@
|
|
|
+package com.usoftchina.saas.transfers.auth.context;
|
|
|
+
|
|
|
+import com.usoftchina.saas.constant.CommonConstants;
|
|
|
+import com.usoftchina.saas.utils.ObjectUtils;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author: guq
|
|
|
+ * @create: 2019-01-11 17:53
|
|
|
+ **/
|
|
|
+public class TransfersContextHodler {
|
|
|
+
|
|
|
+ private static final String BTOBCOMPANYID = "b2bcompanyid";
|
|
|
+
|
|
|
+ private static final ThreadLocal<Map<String, Object>> threadLocal = new ThreadLocal<>();
|
|
|
+
|
|
|
+ public static void set(String key, Object value) {
|
|
|
+ Map<String, Object> map = threadLocal.get();
|
|
|
+ if (map == null) {
|
|
|
+ map = new HashMap<>(1);
|
|
|
+ threadLocal.set(map);
|
|
|
+ }
|
|
|
+ map.put(key, value);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Object get(String key) {
|
|
|
+ Map<String, Object> map = threadLocal.get();
|
|
|
+ if (map == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return map.get(key);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void setB2bCompanyId(Long companyId) {
|
|
|
+ set(BTOBCOMPANYID, companyId);
|
|
|
+ }
|
|
|
+
|
|
|
+ public static Long getB2bCompanyId() {
|
|
|
+ Object value = get(BTOBCOMPANYID);
|
|
|
+ return ObjectUtils.getLongValue(value);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|