Skip to content

Commit

Permalink
feat: [功能]新增网页通知实现类 (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Planeswalker23 committed May 11, 2021
1 parent db56c63 commit d82390f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ public interface NoticeMethod {
* 邮件
*/
String MAIL = "Mail";
/**
* 网页
*/
String WEBSITE = "Website";
/**
* 手机短信
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package io.walkers.planes.fundhelper.service.notice;
package io.walkers.planes.fundhelper.service.notice.impl;

import io.walkers.planes.fundhelper.service.notice.NoticeMessage;
import io.walkers.planes.fundhelper.service.notice.NoticeMethod;
import io.walkers.planes.fundhelper.service.notice.Notification;
import io.walkers.planes.fundhelper.service.notice.NotificationSelector;
import io.walkers.planes.fundhelper.util.JacksonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
Expand Down Expand Up @@ -30,9 +34,9 @@ public Boolean match(String noticeMethod) {

@Override
public Boolean notice(NoticeMessage noticeMessage) {
SimpleMailMessage newMessage = this.convert2SimpleMailMessage(noticeMessage);
mailSender.send(newMessage);
log.info("邮件发送成功 -> 邮件实体类内容: {}", JacksonUtil.toJson(newMessage));
SimpleMailMessage simpleMailMessage = this.convert2SimpleMailMessage(noticeMessage);
mailSender.send(simpleMailMessage);
log.info("邮件发送成功 -> 邮件实体类内容: {}", JacksonUtil.toJson(simpleMailMessage));
return Boolean.TRUE;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package io.walkers.planes.fundhelper.service.notice.impl;

import io.walkers.planes.fundhelper.service.notice.NoticeMessage;
import io.walkers.planes.fundhelper.service.notice.NoticeMethod;
import io.walkers.planes.fundhelper.service.notice.Notification;
import io.walkers.planes.fundhelper.service.notice.NotificationSelector;
import io.walkers.planes.fundhelper.util.JacksonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
* 网页通知,仅会被 {@link NotificationSelector} 使用
*
* @author planeswalker23
*/
@Slf4j
@Service(value = NoticeMethod.WEBSITE)
public class NotificationByWebsite implements Notification {

@Override
public Boolean match(String noticeMethod) {
return NoticeMethod.WEBSITE.equals(noticeMethod);
}

@Override
public Boolean notice(NoticeMessage noticeMessage) {
// todo 网页通知实现
log.info("网页通知成功 -> 内容: {}", JacksonUtil.toJson(noticeMessage));
return Boolean.TRUE;
}
}

0 comments on commit d82390f

Please sign in to comment.