fix
This commit is contained in:
parent
7f54394b44
commit
b3f8b334ef
@ -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<UserDto> users = paper.getAuthors();
|
||||
for (UserDto user: users) {
|
||||
mailService.sendEmail(user.getEmail(), "Обновление статуса статьи",
|
||||
"Статус статьи " + paper.getTitle() + " сменился с " + oldStatus.getName()
|
||||
+ " на " + paper.getStatus().getName());
|
||||
}
|
||||
}
|
||||
}
|
@ -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<PaperDto> findAll() {
|
||||
@ -80,4 +85,12 @@ public class PaperService {
|
||||
public List<PaperStatusDto> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user