From b3f8b334efb65e6ff460556c7d9c5f15ad4a836e Mon Sep 17 00:00:00 2001 From: Alyona Date: Sun, 28 Oct 2018 00:26:09 +0400 Subject: [PATCH] fix --- .../ru/ulstu/paper/service/PaperMessages.java | 25 ------------------- .../ru/ulstu/paper/service/PaperService.java | 15 ++++++++++- 2 files changed, 14 insertions(+), 26 deletions(-) delete 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 deleted file mode 100644 index 926c061..0000000 --- a/src/main/java/ru/ulstu/paper/service/PaperMessages.java +++ /dev/null @@ -1,25 +0,0 @@ -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()); - } - } -} diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java index 5b22cdf..ad32055 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -7,6 +7,8 @@ import ru.ulstu.paper.model.Paper; import ru.ulstu.paper.model.PaperDto; import ru.ulstu.paper.model.PaperStatusDto; import ru.ulstu.paper.repository.PaperRepository; +import ru.ulstu.user.model.UserDto; +import ru.ulstu.user.service.MailService; import java.io.IOException; import java.util.Arrays; @@ -20,11 +22,14 @@ public class PaperService { private final PaperRepository paperRepository; private final FileService fileService; + public final MailService mailService; + public PaperService(PaperRepository paperRepository, - FileService fileService) { + FileService fileService, MailService mailService) { this.paperRepository = paperRepository; this.fileService = fileService; + this.mailService = mailService; } public List findAll() { @@ -80,4 +85,12 @@ public class PaperService { public List getPaperStatuses() { return convert(Arrays.asList(Paper.PaperStatus.values()), status ->new PaperStatusDto(status)); } + + private void sendMessageAboutStatusChange(Paper.PaperStatus oldStatus, PaperDto paper){ + for (UserDto user: paper.getAuthors()) { + mailService.sendEmail(user.getEmail(), "Обновление статуса статьи", + "Статус статьи " + paper.getTitle() + " сменился с " + oldStatus.getName() + + " на " + paper.getStatus().getName()); + } + } }