From 7f54394b440501f31cca0ad3446906799ceffa93 Mon Sep 17 00:00:00 2001 From: Alyona Date: Sat, 27 Oct 2018 23:11:07 +0400 Subject: [PATCH] class for send messages about update paper --- .../ru/ulstu/paper/service/PaperMessages.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/main/java/ru/ulstu/paper/service/PaperMessages.java diff --git a/src/main/java/ru/ulstu/paper/service/PaperMessages.java b/src/main/java/ru/ulstu/paper/service/PaperMessages.java new file mode 100644 index 0000000..926c061 --- /dev/null +++ b/src/main/java/ru/ulstu/paper/service/PaperMessages.java @@ -0,0 +1,25 @@ +package ru.ulstu.paper.service; + +import ru.ulstu.paper.model.Paper; +import ru.ulstu.paper.model.PaperDto; +import ru.ulstu.user.model.UserDto; +import ru.ulstu.user.service.MailService; + +import java.util.List; + +public class PaperMessages { + + public final MailService mailService; + + public PaperMessages(MailService mailService){ + this.mailService = mailService; + } + private void sendMessageAboutStatusChange(Paper.PaperStatus oldStatus, PaperDto paper){ + List users = paper.getAuthors(); + for (UserDto user: users) { + mailService.sendEmail(user.getEmail(), "Обновление статуса статьи", + "Статус статьи " + paper.getTitle() + " сменился с " + oldStatus.getName() + + " на " + paper.getStatus().getName()); + } + } +}