Refactoring start
This commit is contained in:
@@ -10,8 +10,10 @@ import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@@ -20,37 +22,105 @@ import java.util.List;
|
||||
@Builder
|
||||
@Table(name = "course")
|
||||
public class Course {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Id
|
||||
@GeneratedValue
|
||||
private Long id;
|
||||
private String numero;
|
||||
@OneToOne
|
||||
private Reunion reunion;
|
||||
@Pattern(regexp = "^\\d{2}/\\d{2}/\\d{4}$", message = "La date doit être au format dd/MM/yyyy HH:mm:ss")
|
||||
@JsonFormat(pattern = "dd/MM/yyyy HH:mm:ss", shape = JsonFormat.Shape.STRING)
|
||||
@Column(name = "heure_course")
|
||||
private LocalDateTime heureCourse;
|
||||
private String lieu;
|
||||
private int nombreChevauxInscrits;
|
||||
|
||||
private String type;
|
||||
|
||||
private Integer numero;
|
||||
|
||||
private String nom;
|
||||
|
||||
@Column(name = "date_depart_course")
|
||||
private LocalDateTime dateDepartCourse;
|
||||
|
||||
@Column(name = "date_debut_paris")
|
||||
private LocalDateTime dateDebutParis;
|
||||
|
||||
@Column(name = "date_fin_paris")
|
||||
private LocalDateTime dateFinParis;
|
||||
|
||||
@Column(name = "reunion_id")
|
||||
private Long reunionId;
|
||||
|
||||
@Column(name = "reunion_course")
|
||||
private Integer reunionCourse;
|
||||
|
||||
private String particularite;
|
||||
|
||||
private Integer partants;
|
||||
|
||||
private Integer distance;
|
||||
|
||||
private String condition;
|
||||
|
||||
private boolean estTerminee;
|
||||
private boolean estAnnulee;
|
||||
private boolean aDeadHeat;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private StatutCourse statut;
|
||||
private String statut;
|
||||
|
||||
@OneToOne(mappedBy = "course")
|
||||
private Resultat resultat;
|
||||
private int nombreChevauxInscrits;
|
||||
|
||||
@Column(name = "resultat_statut")
|
||||
private String resultatStatut;
|
||||
|
||||
@Column(name = "created_by")
|
||||
private String createdBy;
|
||||
|
||||
@Column(name = "validated_by")
|
||||
private String validatedBy;
|
||||
|
||||
@Column(name = "created_at")
|
||||
private LocalDateTime createdAt;
|
||||
|
||||
@Column(name = "updated_at")
|
||||
private LocalDateTime updatedAt;
|
||||
|
||||
@OneToMany(mappedBy = "course", cascade = CascadeType.ALL)
|
||||
private List<NonPartant> nonPartants;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
|
||||
@JoinTable(name = "course_chevaux",
|
||||
joinColumns = @JoinColumn(name = "course_id"),
|
||||
inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
private List<Cheval> chevaux;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL,mappedBy = "course")
|
||||
private List<Pari> paris;
|
||||
public boolean estEligiblePourTrioOrdre() {
|
||||
return chevaux != null && chevaux.size() >= 3 && chevaux.size() <= 7;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public class Course {
|
||||
// @Id
|
||||
// @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
// private Long id;
|
||||
// private String numero;
|
||||
|
||||
// // FIX 1: Changement de @OneToOne à @ManyToOne (Une course appartient à une seule réunion)
|
||||
// @ManyToOne
|
||||
// @JoinColumn(name = "reunion_id", nullable = false)
|
||||
// private Reunion reunion;
|
||||
|
||||
// @JsonFormat(pattern = "dd/MM/yyyy HH:mm:ss", shape = JsonFormat.Shape.STRING)
|
||||
// @Column(name = "heure_course")
|
||||
// private LocalDateTime heureCourse;
|
||||
// private String lieu;
|
||||
// private int nombreChevauxInscrits;
|
||||
// private boolean estTerminee;
|
||||
// private boolean estAnnulee;
|
||||
// private boolean aDeadHeat;
|
||||
|
||||
// @Enumerated(EnumType.STRING)
|
||||
// private StatutCourse statut;
|
||||
|
||||
// @OneToOne(mappedBy = "course")
|
||||
// private Resultat resultat;
|
||||
|
||||
// @OneToMany(fetch = FetchType.LAZY)
|
||||
// @JoinTable(name = "course_chevaux",
|
||||
// joinColumns = @JoinColumn(name = "course_id"),
|
||||
// inverseJoinColumns = @JoinColumn(name = "cheval_id"))
|
||||
// private List<Cheval> chevaux;
|
||||
|
||||
// @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL,mappedBy = "course")
|
||||
// private List<Pari> paris;
|
||||
|
||||
// public boolean estEligiblePourTrioOrdre() {
|
||||
// return chevaux != null && chevaux.size() >= 3 && chevaux.size() <= 7;
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user