租戶及使用者資訊可以在服務上下文中取得。 請參考以下代碼範例:
- 取出服務上下文
DWServiceContext context = DWServiceContext.getContext();
Map tProfile = DWServiceContext.getContext().getProfile();
- 取得租戶SID
long tenantSid = (long) tProfile.get(“tenantSid”);
- 取得租戶ID
String tenantId = (String) tProfile.get(“tenantId”);
- 取得租戶名稱
String tenantName = (String) tProfile.get(“tenantName”);
- 取得使用者ID
String userId = (String) tProfile.get(“userId”);
- 取得租戶名稱
String userName = (String) tProfile.get(“userName”); |