From 0cc8de2d323fd026fdf4983292d5e23079878dbd Mon Sep 17 00:00:00 2001 From: Nightblade73 Date: Mon, 15 Apr 2019 10:36:55 +0400 Subject: [PATCH] #58 added delete method of conference --- .../ulstu/conference/controller/ConferenceController.java | 7 +++++++ .../ru/ulstu/conference/service/ConferenceService.java | 6 ++++++ .../templates/conferences/fragments/confLineFragment.html | 8 ++++---- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java index 7a229ca..1011c51 100644 --- a/src/main/java/ru/ulstu/conference/controller/ConferenceController.java +++ b/src/main/java/ru/ulstu/conference/controller/ConferenceController.java @@ -5,6 +5,7 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; @@ -60,6 +61,12 @@ public class ConferenceController { } + @GetMapping("/delete/{conference-id}") + public String delete(@PathVariable("conference-id") Integer conferenceId) throws IOException { + conferenceService.delete(conferenceId); + return String.format(REDIRECT_TO, CONFERENCES_PAGE); + } + @PostMapping(value = "/conference", params = "addDeadline") public String addDeadline(@Valid ConferenceDto conferenceDto, Errors errors) { filterEmptyDeadlines(conferenceDto); diff --git a/src/main/java/ru/ulstu/conference/service/ConferenceService.java b/src/main/java/ru/ulstu/conference/service/ConferenceService.java index 9c40295..b01bd42 100644 --- a/src/main/java/ru/ulstu/conference/service/ConferenceService.java +++ b/src/main/java/ru/ulstu/conference/service/ConferenceService.java @@ -64,6 +64,12 @@ public class ConferenceService { return conference.getId(); } + @Transactional + public void delete(Integer conferenceId) { + // Conference conference = conferenceRepository.findOne(conferenceId); + conferenceRepository.delete(conferenceId); + } + public void removeDeadline(ConferenceDto conferenceDto, Integer deadlineIndex) throws IOException { if (conferenceDto.getDeadlines().get(deadlineIndex).getId() != null) { conferenceDto.getRemovedDeadlineIds().add(conferenceDto.getDeadlines().get(deadlineIndex).getId()); diff --git a/src/main/resources/templates/conferences/fragments/confLineFragment.html b/src/main/resources/templates/conferences/fragments/confLineFragment.html index 317da03..d104952 100644 --- a/src/main/resources/templates/conferences/fragments/confLineFragment.html +++ b/src/main/resources/templates/conferences/fragments/confLineFragment.html @@ -4,13 +4,13 @@ -
+