[R1] Entities for Doctor and Address
This commit is contained in:
parent
50181b7e8f
commit
864cfc38df
@ -0,0 +1,31 @@
|
|||||||
|
package com.mirna.hospitalmanagementapi.domain.entities;
|
||||||
|
|
||||||
|
import com.mirna.hospitalmanagementapi.domain.dtos.AddressDTO;
|
||||||
|
|
||||||
|
import jakarta.persistence.Embeddable;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Embeddable
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class Address {
|
||||||
|
|
||||||
|
public Address(AddressDTO addressDTO) {
|
||||||
|
this.street = addressDTO.street();
|
||||||
|
this.neighborhood = addressDTO.neighborhood();
|
||||||
|
this.zipCode = addressDTO.zipCode();
|
||||||
|
this.city = addressDTO.city();
|
||||||
|
this.state = addressDTO.state();
|
||||||
|
this.additionalDetails = addressDTO.additionalDetails();
|
||||||
|
this.houseNumber = addressDTO.houseNumber();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String street;
|
||||||
|
private String neighborhood;
|
||||||
|
private String zipCode;
|
||||||
|
private String city;
|
||||||
|
private String state;
|
||||||
|
private String additionalDetails;
|
||||||
|
private String houseNumber;
|
||||||
|
}
|
||||||
@ -0,0 +1,48 @@
|
|||||||
|
package com.mirna.hospitalmanagementapi.domain.entities;
|
||||||
|
|
||||||
|
import com.mirna.hospitalmanagementapi.domain.dtos.DoctorDTO;
|
||||||
|
import com.mirna.hospitalmanagementapi.domain.enums.Speciality;
|
||||||
|
|
||||||
|
import jakarta.persistence.Embedded;
|
||||||
|
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.Table;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Table(name="doctors")
|
||||||
|
@Entity(name="Doctor")
|
||||||
|
@Getter
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(of="id")
|
||||||
|
public class Doctor {
|
||||||
|
|
||||||
|
public Doctor(DoctorDTO doctorDTO) {
|
||||||
|
this.name=doctorDTO.name();
|
||||||
|
this.email=doctorDTO.email();
|
||||||
|
this.crm=doctorDTO.email();
|
||||||
|
this.telephone=doctorDTO.telephone();
|
||||||
|
this.address = new Address(doctorDTO.addressDTO());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
|
private Long id;
|
||||||
|
private String name;
|
||||||
|
private String email;
|
||||||
|
private String crm;
|
||||||
|
private String telephone;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
|
private Speciality speciality;
|
||||||
|
|
||||||
|
@Embedded
|
||||||
|
private Address address;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,9 @@
|
|||||||
|
package com.mirna.hospitalmanagementapi.domain.enums;
|
||||||
|
|
||||||
|
public enum Speciality {
|
||||||
|
|
||||||
|
ORTHOPEDICS,
|
||||||
|
CARDIOLOGY,
|
||||||
|
GYNECOLOGY,
|
||||||
|
DERMATOLOGY
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user