From 3ac4042b2ad2606aff2c973fac2b9a2d5cdb0da0 Mon Sep 17 00:00:00 2001 From: Lunix-420 Date: Mon, 28 Oct 2024 12:02:51 +0100 Subject: [PATCH] api: Add missing entities --- pom.xml | 7 ++++ .../java/com/maradona/backend/Employee.java | 32 +++++++++++++++++++ .../com/maradona/backend/FormOfAddress.java | 16 ++++++++++ .../java/com/maradona/backend/Project.java | 25 +++++++++++++++ .../maradona/backend/ProjectAssignment.java | 21 ++++++++++++ .../com/maradona/backend/SkillAssignment.java | 28 ++++++++++++++++ .../com/maradona/backend/SkillController.java | 22 ++++++------- 7 files changed, 140 insertions(+), 11 deletions(-) create mode 100644 src/main/java/com/maradona/backend/Employee.java create mode 100644 src/main/java/com/maradona/backend/FormOfAddress.java create mode 100644 src/main/java/com/maradona/backend/Project.java create mode 100644 src/main/java/com/maradona/backend/ProjectAssignment.java create mode 100644 src/main/java/com/maradona/backend/SkillAssignment.java diff --git a/pom.xml b/pom.xml index 056b2e9..2dda440 100644 --- a/pom.xml +++ b/pom.xml @@ -58,6 +58,13 @@ org.springframework.boot spring-boot-starter-oauth2-resource-server + + org.projectlombok + lombok + 1.18.30 + provided + + com.h2database diff --git a/src/main/java/com/maradona/backend/Employee.java b/src/main/java/com/maradona/backend/Employee.java new file mode 100644 index 0000000..579bccc --- /dev/null +++ b/src/main/java/com/maradona/backend/Employee.java @@ -0,0 +1,32 @@ +package com.maradona.backend; + +import jakarta.persistence.*; +import lombok.Data; +import java.time.LocalTime; + +@Entity +@Data +public class Employee { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + private Integer employeeNr; + + @Column(length = 100) + private String firstName; + + @Column(length = 100) + private String lastName; + + @ManyToOne + @JoinColumn(name = "AID") + private FormOfAddress formOfAddress; + + @Column(length = 150) + private String mail; + + private LocalTime dStart; + private LocalTime dEnd; +} diff --git a/src/main/java/com/maradona/backend/FormOfAddress.java b/src/main/java/com/maradona/backend/FormOfAddress.java new file mode 100644 index 0000000..4c2295c --- /dev/null +++ b/src/main/java/com/maradona/backend/FormOfAddress.java @@ -0,0 +1,16 @@ +package com.maradona.backend; + +import jakarta.persistence.*; +import lombok.Data; + +@Entity +@Data +public class FormOfAddress { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(nullable = false, length = 50) + private String description; +} diff --git a/src/main/java/com/maradona/backend/Project.java b/src/main/java/com/maradona/backend/Project.java new file mode 100644 index 0000000..8d4a9fb --- /dev/null +++ b/src/main/java/com/maradona/backend/Project.java @@ -0,0 +1,25 @@ +package com.maradona.backend; + +import jakarta.persistence.*; +import lombok.Data; +import java.time.LocalDate; + +@Entity +@Data +public class Project { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @Column(nullable = false, length = 255) + private String name; + + private LocalDate startDate; + private LocalDate endDate; + + private Integer workload; + + @Column(columnDefinition = "TEXT") + private String description; +} diff --git a/src/main/java/com/maradona/backend/ProjectAssignment.java b/src/main/java/com/maradona/backend/ProjectAssignment.java new file mode 100644 index 0000000..907bf6f --- /dev/null +++ b/src/main/java/com/maradona/backend/ProjectAssignment.java @@ -0,0 +1,21 @@ +package com.maradona.backend; + +import jakarta.persistence.*; +import lombok.Data; + +@Entity +@Data +public class ProjectAssignment { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne + @JoinColumn(name = "PID", nullable = false) + private Project project; + + @ManyToOne + @JoinColumn(name = "EID", nullable = false) + private Employee employee; +} diff --git a/src/main/java/com/maradona/backend/SkillAssignment.java b/src/main/java/com/maradona/backend/SkillAssignment.java new file mode 100644 index 0000000..2a51eb5 --- /dev/null +++ b/src/main/java/com/maradona/backend/SkillAssignment.java @@ -0,0 +1,28 @@ +package com.maradona.backend; + +import jakarta.persistence.*; +import lombok.Data; + +@Entity +@Data +public class SkillAssignment { + public enum SkillLevel { + ONE, TWO, THREE, FOUR, FIVE; + } + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; + + @ManyToOne + @JoinColumn(name = "EID", nullable = false) + private Employee employee; + + @ManyToOne + @JoinColumn(name = "SSID", nullable = false) + private SecondarySkill secondarySkill; + + @Column(nullable = false) + @Enumerated(EnumType.ORDINAL) + private SkillLevel level; +} diff --git a/src/main/java/com/maradona/backend/SkillController.java b/src/main/java/com/maradona/backend/SkillController.java index efdd66d..4c2295c 100644 --- a/src/main/java/com/maradona/backend/SkillController.java +++ b/src/main/java/com/maradona/backend/SkillController.java @@ -1,16 +1,16 @@ package com.maradona.backend; -import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestParam; +import jakarta.persistence.*; +import lombok.Data; +@Entity +@Data +public class FormOfAddress { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + private Long id; - -@RestController -@RequestMapping("/api/skills") -public class SkillController { - + @Column(nullable = false, length = 50) + private String description; }