From 81d07645c20b60f7c9ceb742df37a4c03690e06c Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Tue, 16 Apr 2019 14:18:49 +0400 Subject: [PATCH] #65 added delete method of article, fixed copyFromDto method --- .../conference/controller/ConferenceController.java | 10 ++++++++++ .../ru/ulstu/conference/service/ConferenceService.java | 6 ++++++ .../resources/templates/conferences/conference.html | 5 ++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 0f76881..823f853 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -94,6 +94,16 @@ public class ConferenceController { return CONFERENCE_PAGE; } + @PostMapping(value = "/conference", params = "removePaper") + public String removePaper(@Valid ConferenceDto conferenceDto, Errors errors, + @RequestParam(value = "removePaper") Integer paperIndex) throws IOException { + if (errors.hasErrors()) { + return CONFERENCE_PAGE; + } + conferenceService.removePaper(conferenceDto, paperIndex); + return CONFERENCE_PAGE; + } + public List getNotSelectPapers(List paperIds) { return conferenceService.getConferencePapers(paperIds); } diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index e95addb..4d267d1 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -83,6 +83,11 @@ public class ConferenceService { conferenceDto.getDeadlines().remove((int) deadlineIndex); } + public void removePaper(ConferenceDto conferenceDto, Integer paperIndex) throws IOException { + Paper removedPaper = conferenceDto.getPapers().remove((int) paperIndex); + conferenceDto.getNotSelectedPapers().add(removedPaper); + } + public List getConferencePapers(List paperIds) { return paperService.findAllNotSelect(paperIds); } @@ -94,6 +99,7 @@ public class ConferenceService { conference.setPing(0); conference.setBeginDate(conferenceDto.getBeginDate()); conference.setEndDate(conferenceDto.getEndDate()); + conference.setPapers(conferenceDto.getPapers()); conference.setDeadlines(deadlineService.saveOrCreate(conferenceDto.getDeadlines())); if (conferenceDto.getPaperIds() != null && !conferenceDto.getPaperIds().isEmpty()) { conferenceDto.getPaperIds().forEach(paperId -> diff --git a/src/main/resources/templates/conferences/conference.html b/src/main/resources/templates/conferences/conference.html index 1ed2859..27c602a 100644 --- a/src/main/resources/templates/conferences/conference.html +++ b/src/main/resources/templates/conferences/conference.html @@ -60,8 +60,7 @@ + alt="Удалить" name="removeDeadline" th:value="${rowStat.index}"/> @@ -146,7 +145,7 @@ + alt="Удалить" name="removePaper" th:value="${rowStat.index}"/>