Repository: MatthieuTricoire/ws-pieds-croises-back
Pull request #15: create subscription entity and repository, add box-subscription relation
Author: login: Agattepaille
Created: 2025-05-14T14:58:25Z | Merged: 2025-05-15T07:50:44Z



Diff:
diff --git a/src/main/java/com/crossfit/pieds_croises/model/Box.java b/src/main/java/com/crossfit/pieds_croises/model/Box.java
index a3c10b2..090b02a 100644
--- a/src/main/java/com/crossfit/pieds_croises/model/Box.java
+++ b/src/main/java/com/crossfit/pieds_croises/model/Box.java
@@ -1,12 +1,10 @@
 package com.crossfit.pieds_croises.model;
 
-import jakarta.persistence.Column;
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.Id;
+import jakarta.persistence.*;
 import lombok.*;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 @Entity
 @Getter
@@ -29,18 +27,20 @@ public class Box {
     @Column(length = 100)
     private String city;
 
-    @Column()
+    @Column(length = 5, nullable = false)
     private String zipcode;
 
     @Column(columnDefinition = "TEXT")
     private String schedule;
 
-    @Column(nullable = false)
+    @Column(name = "created_at", nullable = false, updatable = false)
     private LocalDateTime createdAt;
 
-    @Column(nullable = false)
+    @Column(name = "updated_at", nullable = false)
     private LocalDateTime updatedAt;
 
+    @OneToMany(mappedBy = "box")
+    private List<Subscription> subscriptions;
 
 }
 
diff --git a/src/main/java/com/crossfit/pieds_croises/model/Subscription.java b/src/main/java/com/crossfit/pieds_croises/model/Subscription.java
new file mode 100644
index 0000000..706b988
--- /dev/null
+++ b/src/main/java/com/crossfit/pieds_croises/model/Subscription.java
@@ -0,0 +1,36 @@
+package com.crossfit.pieds_croises.model;
+
+import jakarta.persistence.*;
+import lombok.*;
+
+@Entity
+@Getter
+@Setter
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class Subscription {
+
+    @Id
+    @GeneratedValue(strategy = jakarta.persistence.GenerationType.IDENTITY)
+    private Long id;
+
+    @Column(length = 100, nullable = false, unique = true)
+    private String name;
+
+    @Column(nullable = false, unique = true)
+    private int price;
+
+    @Column(name = "session_per_week")
+    private int sessionPerWeek;
+
+    @Column(nullable = false)
+    private short duration;
+
+    @Column(columnDefinition = "TEXT")
+    private String terminationConditions;
+
+    @ManyToOne
+    @JoinColumn(name = "box_id")
+    private Box box;
+}
diff --git a/src/main/java/com/crossfit/pieds_croises/repository/SubscriptionRepository.java b/src/main/java/com/crossfit/pieds_croises/repository/SubscriptionRepository.java
new file mode 100644
index 0000000..d8e7e15
--- /dev/null
+++ b/src/main/java/com/crossfit/pieds_croises/repository/SubscriptionRepository.java
@@ -0,0 +1,5 @@
+package com.crossfit.pieds_croises.repository;
+
+
+public interface SubscriptionRepository {
+}


Reviews:
user: login: Marie-Sail
state: CHANGES_REQUESTED
author_association: COLLABORATOR
submitted_at: 2025-05-14T15:34:03Z
user: login: Marie-Sail
state: APPROVED
author_association: COLLABORATOR
submitted_at: 2025-05-15T07:49:34Z

Review comments:
diff_hunk: @@ -35,12 +33,14 @@ public class Box {
     @Column(columnDefinition = "TEXT")
path: src/main/java/com/crossfit/pieds_croises/model/Box.java
user: login: Marie-Sail
body:  @Column(length = 100, nullable = false)
    String city;

    @Column(length = 5, nullable = false)
    String zipcode;
created_at: 2025-05-14T15:22:30Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,36 @@
+package com.crossfit.pieds_croises.model;
+
+import jakarta.persistence.*;
+import lombok.*;
+
+@Entity
+@Getter
+@Setter
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class Subscription {
+
+    @Id
+    @GeneratedValue(strategy = jakarta.persistence.GenerationType.IDENTITY)
+    private Long id;
+
+    @Column(length = 100, nullable = false, unique = true)
+    private String name;
+
+    @Column(nullable = false, unique = true)
+    private int price;
+
+    @Column()
path: src/main/java/com/crossfit/pieds_croises/model/Subscription.java
user: login: Marie-Sail
body: @Column(name = "session_per_week")
created_at: 2025-05-14T15:27:47Z
author_association: COLLABORATOR
diff_hunk: @@ -0,0 +1,36 @@
+package com.crossfit.pieds_croises.model;
+
+import jakarta.persistence.*;
+import lombok.*;
+
+@Entity
+@Getter
+@Setter
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class Subscription {
+
+    @Id
+    @GeneratedValue(strategy = jakarta.persistence.GenerationType.IDENTITY)
+    private Long id;
+
+    @Column(length = 100, nullable = false, unique = true)
+    private String name;
+
+    @Column(nullable = false, unique = true)
+    private int price;
+
+    @Column()
+    private int sessionPerWeek;
+
+    @Column(nullable = false)
+    private int duration;
path: src/main/java/com/crossfit/pieds_croises/model/Subscription.java
user: login: Marie-Sail
body: private short duration;        pour être en smallint :) 
created_at: 2025-05-14T15:33:04Z
author_association: COLLABORATOR

PR comments:
user: login: Marie-Sail
created_at: 2025-05-14T15:36:09Z
body: Si tu peux rajouter le repository de la box, ce sera top ! 😉
author_association: COLLABORATOR
user: login: Agattepaille
created_at: 2025-05-15T07:46:50Z
body: > Si tu peux rajouter le repository de la box, ce sera top ! 😉

le repo de la box a été créé dans la branche feature/box-model ;)
author_association: COLLABORATOR