|
|
@ -1,6 +1,5 @@
|
|
|
|
package ru.ulstu.paper.controller;
|
|
|
|
package ru.ulstu.paper.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.dao.DataIntegrityViolationException;
|
|
|
|
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
import org.springframework.http.HttpHeaders;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
|
import org.springframework.http.ResponseEntity;
|
|
|
@ -9,14 +8,14 @@ import org.springframework.ui.ModelMap;
|
|
|
|
import org.springframework.validation.Errors;
|
|
|
|
import org.springframework.validation.Errors;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
|
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
|
|
import ru.ulstu.conference.service.ConferenceService;
|
|
|
|
import ru.ulstu.deadline.model.Deadline;
|
|
|
|
import ru.ulstu.deadline.model.Deadline;
|
|
|
|
import ru.ulstu.paper.model.Paper;
|
|
|
|
import ru.ulstu.paper.model.Paper;
|
|
|
|
import ru.ulstu.paper.model.PaperDto;
|
|
|
|
import ru.ulstu.paper.model.PaperDto;
|
|
|
|
import ru.ulstu.paper.model.PaperFilterDto;
|
|
|
|
import ru.ulstu.paper.model.PaperListDto;
|
|
|
|
import ru.ulstu.paper.service.LatexService;
|
|
|
|
import ru.ulstu.paper.service.LatexService;
|
|
|
|
import ru.ulstu.paper.service.PaperService;
|
|
|
|
import ru.ulstu.paper.service.PaperService;
|
|
|
|
import ru.ulstu.user.model.User;
|
|
|
|
import ru.ulstu.user.model.User;
|
|
|
@ -39,23 +38,34 @@ import static org.springframework.util.StringUtils.isEmpty;
|
|
|
|
@ApiIgnore
|
|
|
|
@ApiIgnore
|
|
|
|
public class PaperController {
|
|
|
|
public class PaperController {
|
|
|
|
private final PaperService paperService;
|
|
|
|
private final PaperService paperService;
|
|
|
|
|
|
|
|
private final ConferenceService conferenceService;
|
|
|
|
private final LatexService latexService;
|
|
|
|
private final LatexService latexService;
|
|
|
|
|
|
|
|
|
|
|
|
public PaperController(PaperService paperService, LatexService latexService) {
|
|
|
|
public PaperController(PaperService paperService,
|
|
|
|
|
|
|
|
ConferenceService conferenceService,
|
|
|
|
|
|
|
|
LatexService latexService) {
|
|
|
|
this.paperService = paperService;
|
|
|
|
this.paperService = paperService;
|
|
|
|
|
|
|
|
this.conferenceService = conferenceService;
|
|
|
|
this.latexService = latexService;
|
|
|
|
this.latexService = latexService;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/papers")
|
|
|
|
@GetMapping("/papers")
|
|
|
|
public void getPapers(ModelMap modelMap) {
|
|
|
|
public void getPapers(ModelMap modelMap) {
|
|
|
|
modelMap.put("filteredPapers", new PaperFilterDto(paperService.findAllDto(), null, null));
|
|
|
|
modelMap.put("filteredPapers", new PaperListDto(paperService.findAllDto(), null, null));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/papers")
|
|
|
|
@PostMapping("/papers")
|
|
|
|
public void filterPapers(@Valid PaperFilterDto paperFilterDto, ModelMap modelMap) {
|
|
|
|
public void listPapers(@Valid PaperListDto paperListDto, ModelMap modelMap) {
|
|
|
|
modelMap.put("filteredPapers", new PaperFilterDto(paperService.filter(paperFilterDto),
|
|
|
|
if (paperListDto.getPaperDeleteId() != null) {
|
|
|
|
paperFilterDto.getFilterAuthorId(),
|
|
|
|
if (conferenceService.isAttachedToConference(paperListDto.getPaperDeleteId())) {
|
|
|
|
paperFilterDto.getYear()));
|
|
|
|
modelMap.put("flashMessage", "Статью нельзя удалить, она прикреплена к конференции");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
paperService.delete(paperListDto.getPaperDeleteId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
modelMap.put("filteredPapers", new PaperListDto(paperService.filter(paperListDto),
|
|
|
|
|
|
|
|
paperListDto.getFilterAuthorId(),
|
|
|
|
|
|
|
|
paperListDto.getYear()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/dashboard")
|
|
|
|
@GetMapping("/dashboard")
|
|
|
@ -95,19 +105,6 @@ public class PaperController {
|
|
|
|
return "/papers/paper";
|
|
|
|
return "/papers/paper";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/delete/{paper-id}")
|
|
|
|
|
|
|
|
public String delete(@Valid PaperFilterDto paperFilterDto,
|
|
|
|
|
|
|
|
@PathVariable("paper-id") Integer paperId,
|
|
|
|
|
|
|
|
Errors errors) throws IOException {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
paperService.delete(paperId);
|
|
|
|
|
|
|
|
} catch (DataIntegrityViolationException e) {
|
|
|
|
|
|
|
|
errors.reject("relationExist", "Статья прикреплена к конференции");
|
|
|
|
|
|
|
|
return "/papers/papers";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return "redirect:/papers/papers";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ModelAttribute("allStatuses")
|
|
|
|
@ModelAttribute("allStatuses")
|
|
|
|
public List<Paper.PaperStatus> getPaperStatuses() {
|
|
|
|
public List<Paper.PaperStatus> getPaperStatuses() {
|
|
|
|
return paperService.getPaperStatuses();
|
|
|
|
return paperService.getPaperStatuses();
|
|
|
|