From 4b80a1082d5a57e1a1422c0cc3a71b6b79bd76f6 Mon Sep 17 00:00:00 2001 From: Lunix-420 Date: Tue, 12 Nov 2024 17:38:45 +0100 Subject: [PATCH] feat: Update project/create.html --- .../controllers/api/ProjectController.java | 1 + .../maradona/backend/entities/Employee.java | 3 ++ .../maradona/backend/entities/Project.java | 3 ++ .../templates/pages/projects/create.html | 54 ++++++++++++++++++- 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/maradona/backend/controllers/api/ProjectController.java b/src/main/java/com/maradona/backend/controllers/api/ProjectController.java index 8aa501b..9d65bbb 100644 --- a/src/main/java/com/maradona/backend/controllers/api/ProjectController.java +++ b/src/main/java/com/maradona/backend/controllers/api/ProjectController.java @@ -101,6 +101,7 @@ public class ProjectController { */ @PostMapping({ "/", "" }) public ResponseEntity post(@RequestBody Project project) { + System.out.println(project); Project savedProject = projectActions.saveProject(project); return ResponseEntity.status(HttpStatus.CREATED).body(savedProject); } diff --git a/src/main/java/com/maradona/backend/entities/Employee.java b/src/main/java/com/maradona/backend/entities/Employee.java index f75ddf4..546f917 100644 --- a/src/main/java/com/maradona/backend/entities/Employee.java +++ b/src/main/java/com/maradona/backend/entities/Employee.java @@ -2,6 +2,8 @@ package com.maradona.backend.entities; import jakarta.persistence.*; import lombok.Data; + +import com.fasterxml.jackson.annotation.JsonBackReference; import com.fasterxml.jackson.annotation.JsonManagedReference; import java.time.LocalTime; import java.util.List; @@ -81,6 +83,7 @@ public class Employee { */ @ManyToMany @JoinTable(name = "employee_project", joinColumns = @JoinColumn(name = "employee_eid"), inverseJoinColumns = @JoinColumn(name = "project_pid")) + @JsonBackReference private List projects; /** diff --git a/src/main/java/com/maradona/backend/entities/Project.java b/src/main/java/com/maradona/backend/entities/Project.java index 91471b2..a7cdb98 100644 --- a/src/main/java/com/maradona/backend/entities/Project.java +++ b/src/main/java/com/maradona/backend/entities/Project.java @@ -5,6 +5,8 @@ import lombok.Data; import java.time.LocalDate; import java.util.List; +import com.fasterxml.jackson.annotation.JsonManagedReference; + /** * Represents a project. * @@ -36,6 +38,7 @@ public class Project { * This is a list of references to the employee entity. */ @ManyToMany(mappedBy = "projects") + @JsonManagedReference private List employees; /** diff --git a/src/main/resources/templates/pages/projects/create.html b/src/main/resources/templates/pages/projects/create.html index 75c6a71..d7774e0 100644 --- a/src/main/resources/templates/pages/projects/create.html +++ b/src/main/resources/templates/pages/projects/create.html @@ -16,7 +16,8 @@

Create Project

+
+ + +
+
+ + +
+