Class DbNotificationTemplateResolver<T extends NotificationTemplateBase>

java.lang.Object
io.leandev.appfuse.notification.template.DbNotificationTemplateResolver<T>
Type Parameters:
T - 應用宣告的具體範本 entity(繼承 NotificationTemplateBase
All Implemented Interfaces:
NotificationTemplateResolver

public class DbNotificationTemplateResolver<T extends NotificationTemplateBase> extends Object implements NotificationTemplateResolver

DB 範本解析器(Phase 2):查一張範本表,指定語系 → 不分語系(wildcard)兩層,查無委派 fallback

ADR-017 泛型化於 NotificationTemplateBase、依賴 NotificationTemplateRepositoryBase——本類不再認識租戶: 舊版的四段優先序(tenant+locale → tenant+null → global+locale → global+null)拆成「每個表兩層 + fallback 串鏈」,由應用組解析鏈表達跨表優先序:

// 租戶覆寫表 → 全域表 → 訊息束(NlsNotificationTemplateResolver)
new DbNotificationTemplateResolver<>(tenantRepo,
        new DbNotificationTemplateResolver<>(globalRepo, bundleFallback))

單一實例的解析優先序(命中即用):

  1. 指定語系(locale.toLanguageTag()
  2. 不分語系(NotificationTemplateBase.ANY_LOCALE wildcard)
  3. 委派 fallback(下一張表或訊息束預設)

租戶範圍由應用 entity 的 @TenantId 於 Session 建構時自動限縮(render 發生在寫 Outbox 的同步 執行緒,tenant context 仍在);全域表無租戶欄位、天然全域。命中 DB 範本時以 TemplateInterpolationmodel${name} 插值,與訊息束預設同一套插值。

Since:
4.0.0