Improve model validations
This commit is contained in:
@@ -1,13 +1,7 @@
|
||||
package com.project.back_end.models;
|
||||
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.EnumType;
|
||||
import jakarta.persistence.Enumerated;
|
||||
import jakarta.persistence.GeneratedValue;
|
||||
import jakarta.persistence.GenerationType;
|
||||
import jakarta.persistence.Id;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.Future;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
|
||||
@@ -25,10 +19,12 @@ public class Appointment {
|
||||
|
||||
@NotNull
|
||||
@ManyToOne
|
||||
@JsonIgnore
|
||||
private Doctor doctor;
|
||||
|
||||
@NotNull
|
||||
@ManyToOne
|
||||
@JsonIgnore
|
||||
private Patient patient;
|
||||
|
||||
@NotNull
|
||||
@@ -76,18 +72,31 @@ public class Appointment {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Transient
|
||||
public LocalDateTime getEndTime() {
|
||||
return appointmentTime.plusHours(1);
|
||||
}
|
||||
|
||||
@Transient
|
||||
public LocalDate getAppointmentDate() {
|
||||
return appointmentTime.toLocalDate();
|
||||
}
|
||||
|
||||
@Transient
|
||||
public LocalTime getAppointmentTimeOnly() {
|
||||
return appointmentTime.toLocalTime();
|
||||
}
|
||||
|
||||
@Transient
|
||||
public String getDoctorName() {
|
||||
return doctor.getName();
|
||||
}
|
||||
|
||||
@Transient
|
||||
public String getPatientName() {
|
||||
return patient.getName();
|
||||
}
|
||||
|
||||
public enum Status {
|
||||
SCHEDULED,
|
||||
COMPLETED,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.project.back_end.models;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.validation.constraints.Email;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
@@ -18,6 +19,7 @@ public class Doctor {
|
||||
|
||||
@NotNull
|
||||
@OneToOne
|
||||
@JsonIgnore
|
||||
private User user;
|
||||
|
||||
@NotNull
|
||||
@@ -30,11 +32,11 @@ public class Doctor {
|
||||
|
||||
@NotNull
|
||||
@Email
|
||||
private String email_address;
|
||||
private String emailAddress;
|
||||
|
||||
@NotNull
|
||||
@Pattern(regexp = "^[0-9]{10}$")
|
||||
private String phone_number;
|
||||
private String phoneNumber;
|
||||
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
private List<Appointment> appointments;
|
||||
@@ -47,8 +49,8 @@ public class Doctor {
|
||||
@OneToMany(fetch = FetchType.LAZY)
|
||||
private List<UnavailabilitySchedule> unavailabilitySchedules;
|
||||
|
||||
|
||||
@NotNull
|
||||
@JsonIgnore
|
||||
private Boolean archived;
|
||||
|
||||
public Doctor() {
|
||||
@@ -72,20 +74,28 @@ public class Doctor {
|
||||
this.specialization = specialization;
|
||||
}
|
||||
|
||||
public String getEmail_address() {
|
||||
return email_address;
|
||||
public String getEmailAddress() {
|
||||
return emailAddress;
|
||||
}
|
||||
|
||||
public void setEmail_address(String email_address) {
|
||||
this.email_address = email_address;
|
||||
public void setEmailAddress(String emailAddress) {
|
||||
this.emailAddress = emailAddress;
|
||||
}
|
||||
|
||||
public String getPhone_number() {
|
||||
return phone_number;
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setPhone_number(String phone_number) {
|
||||
this.phone_number = phone_number;
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
public List<Appointment> getAppointments() {
|
||||
|
||||
Reference in New Issue
Block a user