feat(common): 添加 BusinessException/GlobalExceptionHandler/CompanyContext/状态枚举 (T007/T008/T012-T015)
This commit is contained in:
21
src/main/java/com/label/common/context/CompanyContext.java
Normal file
21
src/main/java/com/label/common/context/CompanyContext.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package com.label.common.context;
|
||||
|
||||
public class CompanyContext {
|
||||
private static final ThreadLocal<Long> COMPANY_ID = new ThreadLocal<>();
|
||||
|
||||
public static void set(Long companyId) {
|
||||
COMPANY_ID.set(companyId);
|
||||
}
|
||||
|
||||
public static Long get() {
|
||||
return COMPANY_ID.get();
|
||||
}
|
||||
|
||||
public static void clear() {
|
||||
COMPANY_ID.remove(); // Use remove() not set(null) to prevent memory leaks
|
||||
}
|
||||
|
||||
private CompanyContext() { // Prevent instantiation
|
||||
throw new UnsupportedOperationException("Utility class");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user