From 1ac50fdd540d90bb5e0a7f013b6db649b8f923b4 Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Thu, 30 Jan 2025 01:35:06 +0400 Subject: [PATCH] Add report models and controller --- .../controller/AspirantController.java | 3 ++ .../java/ru/ulstu/aspirant/model/Report.java | 36 +++++++++++++++++++ .../ru/ulstu/aspirant/model/ReportValue.java | 30 ++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 src/main/java/ru/ulstu/aspirant/model/Report.java create mode 100644 src/main/java/ru/ulstu/aspirant/model/ReportValue.java diff --git a/src/main/java/ru/ulstu/aspirant/controller/AspirantController.java b/src/main/java/ru/ulstu/aspirant/controller/AspirantController.java index 91f953c..08ee801 100644 --- a/src/main/java/ru/ulstu/aspirant/controller/AspirantController.java +++ b/src/main/java/ru/ulstu/aspirant/controller/AspirantController.java @@ -4,6 +4,7 @@ import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import ru.ulstu.aspirant.model.Report; import ru.ulstu.aspirant.service.AspirantService; import ru.ulstu.indicator.model.Indicator; @@ -21,6 +22,8 @@ public class AspirantController { @GetMapping("aspirantReport") public String createReport(Model model) { List indicators = aspirantService.getIndicatorsByCourse(); + model.addAttribute("indicators", indicators); + model.addAttribute("report", new Report()); return "aspirant/editReport"; } } diff --git a/src/main/java/ru/ulstu/aspirant/model/Report.java b/src/main/java/ru/ulstu/aspirant/model/Report.java new file mode 100644 index 0000000..8bb1771 --- /dev/null +++ b/src/main/java/ru/ulstu/aspirant/model/Report.java @@ -0,0 +1,36 @@ +package ru.ulstu.aspirant.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.OneToMany; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import ru.ulstu.model.BaseEntity; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +@Entity +public class Report extends BaseEntity { + @Temporal(TemporalType.TIMESTAMP) + private Date createDate = new Date(); + + @OneToMany + private List values = new ArrayList<>(); + + public List getValues() { + return values; + } + + public void setValues(List values) { + this.values = values; + } + + public Date getCreateDate() { + return createDate; + } + + public void setCreateDate(Date createDate) { + this.createDate = createDate; + } +} diff --git a/src/main/java/ru/ulstu/aspirant/model/ReportValue.java b/src/main/java/ru/ulstu/aspirant/model/ReportValue.java new file mode 100644 index 0000000..37b10da --- /dev/null +++ b/src/main/java/ru/ulstu/aspirant/model/ReportValue.java @@ -0,0 +1,30 @@ +package ru.ulstu.aspirant.model; + +import jakarta.persistence.Entity; +import jakarta.persistence.ManyToOne; +import ru.ulstu.indicator.model.Indicator; +import ru.ulstu.model.BaseEntity; + +@Entity +public class ReportValue extends BaseEntity { + @ManyToOne + private Indicator indicator; + + private int indicatorValue; + + public Indicator getIndicator() { + return indicator; + } + + public void setIndicator(Indicator indicator) { + this.indicator = indicator; + } + + public int getIndicatorValue() { + return indicatorValue; + } + + public void setIndicatorValue(int indicatorValue) { + this.indicatorValue = indicatorValue; + } +}