|
|
@ -7,19 +7,20 @@ 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.PathVariable;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
|
|
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.core.model.response.Response;
|
|
|
|
import ru.ulstu.deadline.model.DeadlineDto;
|
|
|
|
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.service.PaperService;
|
|
|
|
import ru.ulstu.paper.service.PaperService;
|
|
|
|
import ru.ulstu.user.model.User;
|
|
|
|
import ru.ulstu.user.model.User;
|
|
|
|
|
|
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
import javax.validation.Valid;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import static org.springframework.util.StringUtils.isEmpty;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Controller()
|
|
|
|
@Controller()
|
|
|
@ -45,7 +46,7 @@ public class PaperController {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/paper")
|
|
|
|
@PostMapping(value = "/paper", params = "save")
|
|
|
|
public String save(@Valid PaperDto paperDto, Errors errors) throws IOException {
|
|
|
|
public String save(@Valid PaperDto paperDto, Errors errors) throws IOException {
|
|
|
|
if (errors.hasErrors()) {
|
|
|
|
if (errors.hasErrors()) {
|
|
|
|
return "/papers/paper";
|
|
|
|
return "/papers/paper";
|
|
|
@ -54,6 +55,13 @@ public class PaperController {
|
|
|
|
return "redirect:/papers/papers";
|
|
|
|
return "redirect:/papers/papers";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping(value = "/paper", params = "addDeadline")
|
|
|
|
|
|
|
|
public String addDeadline(@Valid PaperDto paperDto) {
|
|
|
|
|
|
|
|
filterEmptyDeadlines(paperDto);
|
|
|
|
|
|
|
|
paperDto.getDeadlines().add(new DeadlineDto());
|
|
|
|
|
|
|
|
return "/papers/paper";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/delete/{paper-id}")
|
|
|
|
@GetMapping("/delete/{paper-id}")
|
|
|
|
public String delete(@PathVariable("paper-id") Integer paperId) throws IOException {
|
|
|
|
public String delete(@PathVariable("paper-id") Integer paperId) throws IOException {
|
|
|
|
paperService.delete(paperId);
|
|
|
|
paperService.delete(paperId);
|
|
|
@ -70,8 +78,9 @@ public class PaperController {
|
|
|
|
return paperService.getPaperAuthors();
|
|
|
|
return paperService.getPaperAuthors();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@PostMapping("/filter")
|
|
|
|
private void filterEmptyDeadlines(PaperDto paperDto) {
|
|
|
|
public Response<List<PaperDto>> filter(@RequestBody @Valid PaperFilterDto paperFilterDto) throws IOException {
|
|
|
|
paperDto.setDeadlines(paperDto.getDeadlines().stream()
|
|
|
|
return new Response<>(paperService.filter(paperFilterDto));
|
|
|
|
.filter(dto -> dto.getDate() != null || !isEmpty(dto.getDescription()))
|
|
|
|
|
|
|
|
.collect(Collectors.toList()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|