From d6b7fe790a46be285659f2066f5a71eac208d104 Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Fri, 5 Apr 2019 13:21:15 +0400 Subject: [PATCH] #55 added transition to the page new conference --- .../controller/ConferenceController.java | 14 +++++++++++++- .../conference/service/ConferenceService.java | 14 +++----------- .../templates/conferences/conference.html | 6 ++++-- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 153bd28..291b5fc 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -5,8 +5,10 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import ru.ulstu.conference.model.ConferenceFilterDto; import ru.ulstu.conference.service.ConferenceService; +import ru.ulstu.paper.model.PaperDto; import springfox.documentation.annotations.ApiIgnore; @Controller() @@ -22,6 +24,16 @@ public class ConferenceController { @GetMapping("/conferences") public void getConferences(ModelMap modelMap) { - modelMap.put("filteredConferences", new ConferenceFilterDto(conferenceService.findAllDto(), null, null)); + modelMap.put("filteredConferences", new ConferenceFilterDto(conferenceService.findAllDto(), + null, null)); + } + + @GetMapping("/conference") + public void getConference(ModelMap modelMap, @RequestParam(value = "id") Integer id) { + if (id != null && id > 0) { + modelMap.put("conferenceDto", conferenceService.findOneDto(id)); + } else { + modelMap.put("conferenceDto", new PaperDto()); + } } } diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index fd9cc5b..8fcccb0 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -34,17 +34,9 @@ public class ConferenceService { return conferences; } -// private List sortPapers(List conferences) { -// return conferences.stream().sorted((paper1, paper2) -> { -// int statusCompareResult = -// Integer.valueOf(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper1.getStatus())) -// .compareTo(Arrays.asList(Paper.PaperStatus.values()).indexOf(paper2.getStatus())); -// if (statusCompareResult != 0) { -// return statusCompareResult; -// } -// return paper1.getTitle().compareTo(paper2.getTitle()); -// }).collect(toList()); -// } + public ConferenceDto findOneDto(Integer id) { + return new ConferenceDto(conferenceRepository.findOne(id)); + } } diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index 59545b5..7e8d0b7 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -18,11 +18,13 @@
-
+
- +