#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 name;
|
||||||
private String fileName;
|
private String fileName;
|
||||||
private String tmpFileName;
|
private String tmpFileName;
|
||||||
|
|
||||||
private boolean deleted;
|
private boolean deleted;
|
||||||
|
|
||||||
public FileDataDto() {
|
public FileDataDto() {
|
||||||
|
@ -95,17 +95,14 @@ public class FileService {
|
|||||||
@Transactional
|
@Transactional
|
||||||
public FileData update(FileDataDto fileDataDto) {
|
public FileData update(FileDataDto fileDataDto) {
|
||||||
FileData file = fileRepository.findOne(fileDataDto.getId());
|
FileData file = fileRepository.findOne(fileDataDto.getId());
|
||||||
fileRepository.save(copyFromDto(file, fileDataDto));
|
return fileRepository.save(copyFromDto(file, fileDataDto));
|
||||||
return file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public FileData create(FileDataDto fileDataDto) throws IOException {
|
public FileData create(FileDataDto fileDataDto) throws IOException {
|
||||||
FileData newFile = null;
|
FileData newFile = createFileFromTmp(fileDataDto.getTmpFileName());
|
||||||
newFile = createFileFromTmp(fileDataDto.getTmpFileName());
|
|
||||||
copyFromDto(newFile, fileDataDto);
|
copyFromDto(newFile, fileDataDto);
|
||||||
newFile = fileRepository.save(newFile);
|
return fileRepository.save(newFile);
|
||||||
return newFile;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private FileData copyFromDto(FileData fileData, FileDataDto fileDataDto) {
|
private FileData copyFromDto(FileData fileData, FileDataDto fileDataDto) {
|
||||||
|
@ -31,9 +31,7 @@ public class PaperDto {
|
|||||||
private List<Deadline> deadlines = new ArrayList<>();
|
private List<Deadline> deadlines = new ArrayList<>();
|
||||||
private String comment;
|
private String comment;
|
||||||
private Boolean locked;
|
private Boolean locked;
|
||||||
|
|
||||||
private List<FileDataDto> files = new ArrayList<>();
|
private List<FileDataDto> files = new ArrayList<>();
|
||||||
|
|
||||||
private Set<Integer> authorIds;
|
private Set<Integer> authorIds;
|
||||||
private Set<UserDto> authors;
|
private Set<UserDto> authors;
|
||||||
private Integer filterAuthorId;
|
private Integer filterAuthorId;
|
||||||
@ -75,9 +73,7 @@ public class PaperDto {
|
|||||||
this.deadlines = paper.getDeadlines();
|
this.deadlines = paper.getDeadlines();
|
||||||
this.comment = paper.getComment();
|
this.comment = paper.getComment();
|
||||||
this.locked = paper.getLocked();
|
this.locked = paper.getLocked();
|
||||||
|
|
||||||
this.files = convert(paper.getFiles(), FileDataDto::new);
|
this.files = convert(paper.getFiles(), FileDataDto::new);
|
||||||
|
|
||||||
this.authorIds = convert(paper.getAuthors(), user -> user.getId());
|
this.authorIds = convert(paper.getAuthors(), user -> user.getId());
|
||||||
this.authors = convert(paper.getAuthors(), UserDto::new);
|
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.FAILED;
|
||||||
import static ru.ulstu.paper.model.Paper.PaperStatus.ON_PREPARATION;
|
import static ru.ulstu.paper.model.Paper.PaperStatus.ON_PREPARATION;
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class PaperService {
|
public class PaperService {
|
||||||
private final static int MAX_DISPLAY_SIZE = 40;
|
private final static int MAX_DISPLAY_SIZE = 40;
|
||||||
|
Loading…
Reference in New Issue
Block a user