返回列表 發布新帖

DAP後端如何取得租戶與使用者相關訊息?

160 1
發表於 2025-2-25 17:12 | 查看全部 閱讀模式
問答

緊急程度

已完結
DAP後端要取用 request端身分相關訊息,可以參考哪邊?
另外請問request header哪些欄位訊息是必要的,才能正常解譯sid呢?

最佳答案

查看完整內容

1.請確認請求訊息的header中有傳入使用者token 2.在程式碼中使用 DWServiceContext.getContext().getProfile().get(key);來取得相關資訊。 key可以為: tenantSid: 租戶sid tenantId: 租戶id tenantName: 租戶名稱 userId: 使用者id userName: 使用者名稱 可參考以下範例程式碼: // 取出服務上下文 DWServiceContext context = DWServiceContext.getContext(); Map<String, Object> tProfile = DWServiceContext.getContext( ...

評論1

鄭舜尹樓主Lv.9 發表於 2025-2-25 17:17 | 查看全部
1.請確認請求訊息的header中有傳入使用者token
2.在程式碼中使用 DWServiceContext.getContext().getProfile().get(key);來取得相關資訊。
key可以為:
tenantSid: 租戶sid
tenantId: 租戶id
tenantName: 租戶名稱
userId: 使用者id
userName: 使用者名稱


可參考以下範例程式碼:
  1. // 取出服務上下文
  2. DWServiceContext context = DWServiceContext.getContext();
  3. Map<String, Object> tProfile = DWServiceContext.getContext().getProfile();
  4. // 取得租戶SID
  5. long tenantSid = (long) tProfile.get("tenantSid");
  6. // 取得租戶ID
  7. String tenantId = (String) tProfile.get("tenantId");
  8. // 取得租戶名稱
  9. String tenantName = (String) tProfile.get("tenantName");
  10. // 取得使用者ID
  11. String userId = (String) tProfile.get("userId");
  12. // 取得使用者名稱
  13. String userName = (String) tProfile.get("userName");
復制代碼

回復

您需要登錄後才可以回帖 登錄 | 立即注册

本版積分規則

  • 加入Line諮詢
Copyright © 2026 鼎新數智股份有限公司 版權所有 All Rights Reserved. Powered by Discuz! X5.0
關燈 在本版發帖
即将开放
返回頂部
快速回復 返回頂部 返回列表