From 482e74e10e0f5c583b64b0a2203a0effc32edba2 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 22 Mar 2019 13:58:03 +0400 Subject: [PATCH] #13 reduce of code --- src/main/java/ru/ulstu/file/model/FileDataDto.java | 1 - src/main/java/ru/ulstu/file/service/FileService.java | 9 +++------ src/main/java/ru/ulstu/paper/model/PaperDto.java | 4 ---- src/main/java/ru/ulstu/paper/service/PaperService.java | 1 - 4 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/main/java/ru/ulstu/file/model/FileDataDto.java b/src/main/java/ru/ulstu/file/model/FileDataDto.java index f99656c..919cd80 100644 --- a/src/main/java/ru/ulstu/file/model/FileDataDto.java +++ b/src/main/java/ru/ulstu/file/model/FileDataDto.java @@ -8,7 +8,6 @@ public class FileDataDto { private String name; private String fileName; private String tmpFileName; - private boolean deleted; public FileDataDto() { diff --git a/src/main/java/ru/ulstu/file/service/FileService.java b/src/main/java/ru/ulstu/file/service/FileService.java index 810f853..ad9f946 100644 --- a/src/main/java/ru/ulstu/file/service/FileService.java +++ b/src/main/java/ru/ulstu/file/service/FileService.java @@ -95,17 +95,14 @@ public class FileService { @Transactional public FileData update(FileDataDto fileDataDto) { FileData file = fileRepository.findOne(fileDataDto.getId()); - fileRepository.save(copyFromDto(file, fileDataDto)); - return file; + return fileRepository.save(copyFromDto(file, fileDataDto)); } @Transactional public FileData create(FileDataDto fileDataDto) throws IOException { - FileData newFile = null; - newFile = createFileFromTmp(fileDataDto.getTmpFileName()); + FileData newFile = createFileFromTmp(fileDataDto.getTmpFileName()); copyFromDto(newFile, fileDataDto); - newFile = fileRepository.save(newFile); - return newFile; + return fileRepository.save(newFile); } private FileData copyFromDto(FileData fileData, FileDataDto fileDataDto) { diff --git a/src/main/java/ru/ulstu/paper/model/PaperDto.java b/src/main/java/ru/ulstu/paper/model/PaperDto.java index c250a6b..18284f4 100644 --- a/src/main/java/ru/ulstu/paper/model/PaperDto.java +++ b/src/main/java/ru/ulstu/paper/model/PaperDto.java @@ -31,9 +31,7 @@ public class PaperDto { private List deadlines = new ArrayList<>(); private String comment; private Boolean locked; - private List files = new ArrayList<>(); - private Set authorIds; private Set authors; private Integer filterAuthorId; @@ -75,9 +73,7 @@ public class PaperDto { this.deadlines = paper.getDeadlines(); this.comment = paper.getComment(); this.locked = paper.getLocked(); - this.files = convert(paper.getFiles(), FileDataDto::new); - this.authorIds = convert(paper.getAuthors(), user -> user.getId()); this.authors = convert(paper.getAuthors(), UserDto::new); } diff --git a/src/main/java/ru/ulstu/paper/service/PaperService.java b/src/main/java/ru/ulstu/paper/service/PaperService.java index 89a087d..a664d00 100644 --- a/src/main/java/ru/ulstu/paper/service/PaperService.java +++ b/src/main/java/ru/ulstu/paper/service/PaperService.java @@ -30,7 +30,6 @@ import static ru.ulstu.paper.model.Paper.PaperStatus.DRAFT; import static ru.ulstu.paper.model.Paper.PaperStatus.FAILED; import static ru.ulstu.paper.model.Paper.PaperStatus.ON_PREPARATION; - @Service public class PaperService { private final static int MAX_DISPLAY_SIZE = 40;