#13 reduce of code
This commit is contained in:
parent
7012c00c5f
commit
482e74e10e
@ -8,7 +8,6 @@ public class FileDataDto {
|
||||
private String name;
|
||||
private String fileName;
|
||||
private String tmpFileName;
|
||||
|
||||
private boolean deleted;
|
||||
|
||||
public FileDataDto() {
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user