* @param context 模板需要的数据
*/
@Async
@Override
public void notify(final Long userId, final String templateName, final Map<String, Object> context) {
NotificationTemplate template = notificationTemplateService.findByName(templateName);
if(template == null) {
throw new TemplateNotFoundException(templateName);
}
NotificationData data = new NotificationData();
data.setUserId(userId);
data.setSystem(template.getSystem());
data.setDate(new Date());
String content = template.getTemplate();
String title = template.getTitle();
if(context != null) {
for(String key : context.keySet()) {
//TODO 如果量大可能有性能问题 需要调优
title = title.replace("{" + key + "}", String.valueOf(context.get(key)));
content = content.replace("{" + key + "}", String.valueOf(context.get(key)));