From 7d63899fb2f64ff0a2bb6af6a885fe832e51ef53 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 4 Apr 2025 14:19:24 +0400 Subject: [PATCH] #21 -- Add save report mapping --- .../report/controller/ReportController.java | 7 +++++++ .../ru/ulstu/report/model/dto/ReportDto.java | 3 +++ .../templates/report/editReport.html | 20 +------------------ 3 files changed, 11 insertions(+), 19 deletions(-) diff --git a/src/main/java/ru/ulstu/report/controller/ReportController.java b/src/main/java/ru/ulstu/report/controller/ReportController.java index e71f6c7..93ba8c9 100644 --- a/src/main/java/ru/ulstu/report/controller/ReportController.java +++ b/src/main/java/ru/ulstu/report/controller/ReportController.java @@ -3,6 +3,7 @@ package ru.ulstu.report.controller; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +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.RequestMapping; @@ -62,4 +63,10 @@ public class ReportController { model.addAttribute("report", new ReportDto(reportId, reportPeriodId, indicators)); return "report/editReport"; } + + @PostMapping("saveReport") + public String saveReport(@ModelAttribute("report") ReportDto reportDto, Model model) { + System.out.println(reportDto); + return "redirect:/report/reportList"; + } } diff --git a/src/main/java/ru/ulstu/report/model/dto/ReportDto.java b/src/main/java/ru/ulstu/report/model/dto/ReportDto.java index f4798ff..92041b0 100644 --- a/src/main/java/ru/ulstu/report/model/dto/ReportDto.java +++ b/src/main/java/ru/ulstu/report/model/dto/ReportDto.java @@ -12,6 +12,9 @@ public class ReportDto { private Date createDate = new Date(); private List reportValues = new ArrayList<>(); + public ReportDto() { + } + public ReportDto(Integer id, Integer reportPeriodId, List indicators) { this.id = id; this.reportPeriodId = reportPeriodId; diff --git a/src/main/resources/templates/report/editReport.html b/src/main/resources/templates/report/editReport.html index e71fd8a..19c3321 100644 --- a/src/main/resources/templates/report/editReport.html +++ b/src/main/resources/templates/report/editReport.html @@ -17,7 +17,7 @@
-
+
@@ -40,31 +40,13 @@ maxSize: -1, extensions: [], callback: function (response) { - showFeedbackMessage("Файл успешно загружен"); console.debug(response); - addNewFile(response, $("#files-list")); } }); $('.selectpicker').selectpicker(); }); - function sendPing() { - id = document.getElementById("projectId").value - - $.ajax({ - url: "/projects/ping?projectId=" + id, - contentType: "application/json; charset=utf-8", - method: "POST", - success: function () { - showFeedbackMessage("Ping был отправлен", MessageTypesEnum.SUCCESS) - }, - error: function (errorData) { - showFeedbackMessage(errorData.responseJSON.error.message, MessageTypesEnum.WARNING) - } - }) - } - /*]]>*/ function addNewFile(fileDto, listElement) { var fileNumber = $('.files-list div.row').length;