initial
This commit is contained in:
56
src/main/java/com/pmu/betengine/model/Course.java
Normal file
56
src/main/java/com/pmu/betengine/model/Course.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package com.pmu.betengine.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.pmu.betengine.model.statut.StatutCourse;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Entity
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
@Table(name = "course")
|
||||
public class Course {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
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 boolean estTerminee;
|
||||
private boolean estAnnulee;
|
||||
private boolean aDeadHeat;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private StatutCourse statut;
|
||||
|
||||
@OneToOne(mappedBy = "course")
|
||||
private Resultat resultat;
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user