#21 -- Add save report mapping

This commit is contained in:
Anton Romanov 2025-04-04 14:19:24 +04:00
parent faa081f828
commit 7d63899fb2
3 changed files with 11 additions and 19 deletions

View File

@ -3,6 +3,7 @@ package ru.ulstu.report.controller;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; 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.PathVariable;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -62,4 +63,10 @@ public class ReportController {
model.addAttribute("report", new ReportDto(reportId, reportPeriodId, indicators)); model.addAttribute("report", new ReportDto(reportId, reportPeriodId, indicators));
return "report/editReport"; return "report/editReport";
} }
@PostMapping("saveReport")
public String saveReport(@ModelAttribute("report") ReportDto reportDto, Model model) {
System.out.println(reportDto);
return "redirect:/report/reportList";
}
} }

View File

@ -12,6 +12,9 @@ public class ReportDto {
private Date createDate = new Date(); private Date createDate = new Date();
private List<ReportValueDto> reportValues = new ArrayList<>(); private List<ReportValueDto> reportValues = new ArrayList<>();
public ReportDto() {
}
public ReportDto(Integer id, Integer reportPeriodId, List<Indicator> indicators) { public ReportDto(Integer id, Integer reportPeriodId, List<Indicator> indicators) {
this.id = id; this.id = id;
this.reportPeriodId = reportPeriodId; this.reportPeriodId = reportPeriodId;

View File

@ -17,7 +17,7 @@
<div class="form-group files-list" id="files-list"> <div class="form-group files-list" id="files-list">
<label class="form-label">Загрузка подтверждающих документов</label> <label class="form-label">Загрузка подтверждающих документов</label>
<div th:replace="/report/reportFilesListFragment"></div> <div th:replace="~{/report/reportFilesListFragment}"></div>
</div> </div>
</div> </div>
@ -40,31 +40,13 @@
maxSize: -1, maxSize: -1,
extensions: [], extensions: [],
callback: function (response) { callback: function (response) {
showFeedbackMessage("Файл успешно загружен");
console.debug(response); console.debug(response);
addNewFile(response, $("#files-list")); addNewFile(response, $("#files-list"));
} }
}); });
$('.selectpicker').selectpicker(); $('.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) { function addNewFile(fileDto, listElement) {
var fileNumber = $('.files-list div.row').length; var fileNumber = $('.files-list div.row').length;