#13 reduce of code

This commit is contained in:
Anton Romanov 2019-03-22 13:58:03 +04:00
parent 7012c00c5f
commit 482e74e10e
4 changed files with 3 additions and 12 deletions

View File

@ -8,7 +8,6 @@ public class FileDataDto {
private String name;
private String fileName;
private String tmpFileName;
private boolean deleted;
public FileDataDto() {

View File

@ -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) {

View File

@ -31,9 +31,7 @@ public class PaperDto {
private List<Deadline> deadlines = new ArrayList<>();
private String comment;
private Boolean locked;
private List<FileDataDto> files = new ArrayList<>();
private Set<Integer> authorIds;
private Set<UserDto> 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);
}

View File

@ -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;