From 34071ec1d8c770f4ffcbf2d4114cad17aaf5d2cd Mon Sep 17 00:00:00 2001 From: Mirna Gama Date: Fri, 5 Jan 2024 18:39:07 -0300 Subject: [PATCH] [R4] Add active attribute to doctor entity --- .../domain/entities/Doctor.java | 21 +++++++++++++++++++ .../V3__alter-table-add-column-doctors.sql | 3 +++ 2 files changed, 24 insertions(+) create mode 100644 src/main/resources/db/migration/V3__alter-table-add-column-doctors.sql diff --git a/src/main/java/com/mirna/hospitalmanagementapi/domain/entities/Doctor.java b/src/main/java/com/mirna/hospitalmanagementapi/domain/entities/Doctor.java index a972014..281df81 100644 --- a/src/main/java/com/mirna/hospitalmanagementapi/domain/entities/Doctor.java +++ b/src/main/java/com/mirna/hospitalmanagementapi/domain/entities/Doctor.java @@ -30,6 +30,7 @@ public class Doctor { * @see DoctorDTO */ public Doctor(DoctorDTO doctorDTO) { + this.active=true; this.name=doctorDTO.name(); this.email=doctorDTO.email(); this.crm=doctorDTO.crm(); @@ -62,6 +63,10 @@ public class Doctor { @NotNull(message="specialty cannot be null") @Enumerated(EnumType.STRING) private Specialty specialty; + + @NotNull(message="active cannot be null") + @Column(name="active") + private Boolean active; @NotNull(message="address cannot be null") @Embedded @@ -164,6 +169,22 @@ public class Doctor { this.specialty = specialty; } + /** + * Returns the active + * @return A boolean value that states whether the doctor is active in the system + */ + public Boolean getActive() { + return active; + } + + /** + * Sets the active + * @param active Must not be null. Starts with the true value by default + */ + public void setActive(Boolean active) { + this.active = active; + } + /** * Returns the address * @return An object class representing the doctor's address. diff --git a/src/main/resources/db/migration/V3__alter-table-add-column-doctors.sql b/src/main/resources/db/migration/V3__alter-table-add-column-doctors.sql new file mode 100644 index 0000000..be5e62a --- /dev/null +++ b/src/main/resources/db/migration/V3__alter-table-add-column-doctors.sql @@ -0,0 +1,3 @@ +alter table doctors add active tinyint; +update doctors set active = 1; +