Class NlsNotificationTemplateResolver
java.lang.Object
io.leandev.appfuse.notification.template.NlsNotificationTemplateResolver
- All Implemented Interfaces:
NotificationTemplateResolver
預設範本解析器:Spring MessageSource 訊息束 + ${...} 具名插值
依鍵慣例 notification.{type}.{channel}.subject / .body 從訊息束取範本字串(支援 locale),
再以 NotificationRequest#model(含保留鍵 deepLink)做 ${name} 具名插值。應用層把範本放進
messages*.properties(或自訂 basename),即可在地化、per-locale 客製;缺鍵時退回極簡預設,
不讓「漏範本」導致整批 dead-letter。
範例訊息束(messages_zh_TW.properties):
notification.product.low-stock.email.subject=【補貨提醒】${productName} 庫存不足
notification.product.low-stock.email.body=<p>${productName} 目前庫存 ${stock},請盡快補貨。</p><p><a href="${deepLink}">前往補貨</a></p>
- Since:
- 4.0.0
-
Constructor Summary
ConstructorsConstructorDescriptionNlsNotificationTemplateResolver(org.springframework.context.MessageSource messageSource) -
Method Summary
Modifier and TypeMethodDescription渲染某通知於某通道、某語系的內容
-
Constructor Details
-
NlsNotificationTemplateResolver
public NlsNotificationTemplateResolver(org.springframework.context.MessageSource messageSource) - Parameters:
messageSource- Spring 訊息束(通常為 Spring Boot 自動配置的messageSource)
-
-
Method Details
-
render
public RenderedTemplate render(String type, ChannelType channel, Locale locale, Map<String, Object> model) Description copied from interface:NotificationTemplateResolver渲染某通知於某通道、某語系的內容- Specified by:
renderin interfaceNotificationTemplateResolver- Parameters:
type- 通知型別鍵channel- 遞送通道locale- 目標語系(null 表示系統預設)model- 範本資料袋(含保留鍵deepLink,若有)- Returns:
- 渲染後的主旨與內文
-