【同步】BOOT 和 CLOUD 的功能(所有)

This commit is contained in:
YunaiV
2024-12-31 09:36:14 +08:00
parent 8bfa39a59e
commit 0082bd2189
6 changed files with 37 additions and 24 deletions

View File

@@ -22,6 +22,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Callable;
/**
* Flowable 相关的工具方法
@@ -40,6 +41,17 @@ public class FlowableUtils {
Authentication.setAuthenticatedUserId(null);
}
public static <V> V executeAuthenticatedUserId(Long userId, Callable<V> callable) {
setAuthenticatedUserId(userId);
try {
return callable.call();
} catch (Exception e) {
throw new RuntimeException(e);
} finally {
clearAuthenticatedUserId();
}
}
public static String getTenantId() {
Long tenantId = TenantContextHolder.getTenantId();
return tenantId != null ? String.valueOf(tenantId) : ProcessEngineConfiguration.NO_TENANT_ID;