#21 -- Add removing report
This commit is contained in:
parent
3791f10b8e
commit
a9c51790ea
@ -71,9 +71,15 @@ public class ReportController {
|
||||
return "report/editReport";
|
||||
}
|
||||
|
||||
@PostMapping("save-report")
|
||||
@PostMapping(value = "save-report", params = "save")
|
||||
public String saveReport(@ModelAttribute("report") ReportDto reportDto, Model model) {
|
||||
reportService.saveReport(reportDto);
|
||||
return "redirect:/report/reportList";
|
||||
}
|
||||
|
||||
@PostMapping(value = "save-report", params = "delete")
|
||||
public String deleteReport(@ModelAttribute("report") ReportDto reportDto) {
|
||||
reportService.deleteReport(reportDto.getId());
|
||||
return "redirect:/report/reportList";
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,8 @@
|
||||
package ru.ulstu.report.model;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.OneToMany;
|
||||
import jakarta.persistence.Temporal;
|
||||
@ -26,6 +28,9 @@ public class Report extends BaseEntity {
|
||||
@ManyToOne
|
||||
private Aspirant aspirant;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private ReportStatus status;
|
||||
|
||||
public Report() {
|
||||
}
|
||||
|
||||
@ -64,4 +69,12 @@ public class Report extends BaseEntity {
|
||||
public void setAspirant(Aspirant aspirant) {
|
||||
this.aspirant = aspirant;
|
||||
}
|
||||
|
||||
public ReportStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(ReportStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
5
src/main/java/ru/ulstu/report/model/ReportStatus.java
Normal file
5
src/main/java/ru/ulstu/report/model/ReportStatus.java
Normal file
@ -0,0 +1,5 @@
|
||||
package ru.ulstu.report.model;
|
||||
|
||||
public enum ReportStatus {
|
||||
NEW, REVIEW, CHECKING, APPROVED
|
||||
}
|
@ -3,6 +3,7 @@ package ru.ulstu.report.model.dto;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import ru.ulstu.indicator.model.Indicator;
|
||||
import ru.ulstu.report.model.Report;
|
||||
import ru.ulstu.report.model.ReportStatus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
@ -14,6 +15,7 @@ public class ReportDto {
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
|
||||
private Date createDate = new Date();
|
||||
private List<ReportValueDto> reportValues = new ArrayList<>();
|
||||
private ReportStatus status;
|
||||
|
||||
public ReportDto() {
|
||||
}
|
||||
@ -21,6 +23,7 @@ public class ReportDto {
|
||||
public ReportDto(Integer reportPeriodId, List<Indicator> indicators) {
|
||||
this.reportPeriodId = reportPeriodId;
|
||||
this.reportValues = indicators.stream().map(ReportValueDto::new).toList();
|
||||
this.status = ReportStatus.NEW;
|
||||
}
|
||||
|
||||
public ReportDto(Report report, List<Indicator> indicators) {
|
||||
@ -28,6 +31,7 @@ public class ReportDto {
|
||||
this.reportPeriodId = report.getReportPeriod().getId();
|
||||
this.createDate = report.getCreateDate();
|
||||
this.reportValues = indicators.stream().map(ReportValueDto::new).toList();
|
||||
this.status = report.getStatus();
|
||||
}
|
||||
|
||||
public List<ReportValueDto> getReportValues() {
|
||||
@ -61,4 +65,12 @@ public class ReportDto {
|
||||
public void setCreateDate(Date createDate) {
|
||||
this.createDate = createDate;
|
||||
}
|
||||
|
||||
public ReportStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(ReportStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
@ -57,4 +57,8 @@ public class ReportService {
|
||||
.findById(reportId)
|
||||
.orElseThrow(() -> new RuntimeException("Report not found by id"));
|
||||
}
|
||||
|
||||
public void deleteReport(Integer id) {
|
||||
reportRepository.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
@ -9,9 +9,10 @@
|
||||
<input type="hidden" th:field="*{id}">
|
||||
<input type="hidden" th:field="*{reportPeriodId}">
|
||||
<input type="hidden" th:field="*{createDate}">
|
||||
<input type="hidden" th:field="*{status}">
|
||||
|
||||
<div class="form-group" th:each="rv, ind : *{reportValues}">
|
||||
<a th:href="${'/edit-indicator/' + rv.indicator.id}"
|
||||
<a th:href="${'/edit-indicator-value/' + rv.indicator.id}"
|
||||
th:text="${rv.indicator.name}"></a>
|
||||
<p th:text="${rv.indicator.proofDocuments}"></p>
|
||||
<p th:text="'Максимальное количество баллов за показатель: '+ ${rv.indicator.max}"></p>
|
||||
|
@ -49,7 +49,7 @@
|
||||
<td th:text="${#calendars.format(r.reportPeriod.startDate, 'dd.MM.yyyy') + ' - ' + #calendars.format(r.reportPeriod.endDate, 'dd.MM.yyyy')}"></td>
|
||||
<td th:text="${r.aspirant.surname + ' '+ r.aspirant.name + ' '+ r.aspirant.patronymic }"></td>
|
||||
<td th:text="${#calendars.format(r.createDate, 'dd.MM.yyyy HH:mm')}"></td>
|
||||
<!-- <td th:text="${r.status}"></td>-->
|
||||
<td th:text="${r.status}"></td>
|
||||
<td>
|
||||
<!-- Ссылка на редактирование -->
|
||||
<a th:href="@{'/report/edit-report/' + ${r.id}}" class="btn btn-sm btn-primary">
|
||||
|
Loading…
x
Reference in New Issue
Block a user