Record Class NotificationRequest
java.lang.Object
java.lang.Record
io.leandev.appfuse.notification.NotificationRequest
- Record Components:
type- 通知型別鍵(消費端自定義,如product.low-stock),必填; 驅動範本查找、預設通道與偏好(Phase 2)model- 範本資料袋(供NotificationTemplateResolver插值;缺省空 Map)recipients- 顯式收件人(非空時略過RecipientResolver;可為 null)ccRecipients- EMAIL 副本收件人(最多 100 位;與每位正本共用相同內容;不另建 Outbox 列;可為 null)channels- 遞送通道(缺省{EMAIL};可為 null)deepLink- 隨通知附帶的深連結 URL(最多 2000 字元;如簽章連結;可為 null)dedupeKey- 顯式通知等價鍵(同鍵在 Outbox 視為同一則;最多 100 字元;可為 null)。技術重試/ 多節點遞送保護由 Outbox 機制承擔;一般應用除非已明確決定獨立提交可合併,否則 應省略本值。框架/Feature core 封裝的 opaque technical token 不在此限localeName- 語系覆寫(IETF BCP 47,如zh-TW;null 表示用收件人 / 系統語系)
public record NotificationRequest(String type, Map<String,Object> model, List<Recipient> recipients, List<Recipient> ccRecipients, Set<ChannelType> channels, String deepLink, String dedupeKey, String localeName)
extends Record
一則通知請求(描述「發生了什麼」,不描述「怎麼遞送」)
呼叫端只需提供 type 與 model;由 RecipientResolver 解析收件人、
NotificationTemplateResolver 依 type×channel×locale 渲染內容、NotificationChannel
遞送。recipients 為選用——非空時略過 RecipientResolver(呼叫端已知收件人時用,
如免密碼登入指定 email);ccRecipients 僅套用於 EMAIL,會與每位正本收件人形成同一封
郵件的 CC 標頭,不另建獨立遞送列;channels 缺省為 {EMAIL};model 缺省為空 Map。
CC 收件人會看到正本收件人的相同渲染內容與深連結,因此只適合內容完全相同、沒有
per-recipient 私密資訊的郵件。若 recipients 有多人,既有語意維持「每位正本各一封」,
每封都帶同一組 CC。
與簽章連結正交組合:deepLink 帶一條已簽好的連結(由 io.leandev.appfuse.security.link
原語產生),框架原樣放進渲染脈絡與遞送訊息,不碰其簽章。
容量契約由 NotificationService 在落庫前統一把關:type 100 字元、recipient user id 36
字元、各通道位址 320 字元、CC 最多 100 位、渲染後 subject 500 字元、deep link 2000
字元、呼叫端 dedupe key 100 字元。body 使用大型文字,不另設框架上限。
範例:
NotificationRequest.builder()
.type("product.low-stock")
.model(Map.of("productName", "玫瑰花束", "stock", 3))
.deepLink(signedLinkUrl)
.build();
- Since:
- 4.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionNotificationRequest(String type, Map<String, Object> model, List<Recipient> recipients, List<Recipient> ccRecipients, Set<ChannelType> channels, String deepLink, String dedupeKey, String localeName) Creates an instance of aNotificationRequestrecord class.NotificationRequest(String type, Map<String, Object> model, List<Recipient> recipients, Set<ChannelType> channels, String deepLink, String dedupeKey, String localeName) 相容舊版 canonical constructor(未指定 CC 時視為空清單)。 -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theccRecipientsrecord component.channels()Returns the value of thechannelsrecord component.Returns the value of thededupeKeyrecord component.deepLink()Returns the value of thedeepLinkrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of thelocaleNamerecord component.model()Returns the value of themodelrecord component.Returns the value of therecipientsrecord component.final StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.
-
Constructor Details
-
NotificationRequest
-
NotificationRequest
public NotificationRequest(String type, Map<String, Object> model, List<Recipient> recipients, List<Recipient> ccRecipients, Set<ChannelType> channels, String deepLink, String dedupeKey, String localeName) Creates an instance of aNotificationRequestrecord class.- Parameters:
type- the value for thetyperecord componentmodel- the value for themodelrecord componentrecipients- the value for therecipientsrecord componentccRecipients- the value for theccRecipientsrecord componentchannels- the value for thechannelsrecord componentdeepLink- the value for thedeepLinkrecord componentdedupeKey- the value for thededupeKeyrecord componentlocaleName- the value for thelocaleNamerecord component
-
-
Method Details
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
type
-
model
-
recipients
Returns the value of therecipientsrecord component.- Returns:
- the value of the
recipientsrecord component
-
ccRecipients
Returns the value of theccRecipientsrecord component.- Returns:
- the value of the
ccRecipientsrecord component
-
channels
-
deepLink
-
dedupeKey
-
localeName
Returns the value of thelocaleNamerecord component.- Returns:
- the value of the
localeNamerecord component
-