diff --git a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java index f95d17af..51d6a760 100644 --- a/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java +++ b/src/main/java/cat/udl/eps/softarch/demo/domain/ShelterCertificate.java @@ -1,14 +1,30 @@ package cat.udl.eps.softarch.demo.domain; -import java.util.Date; +import java.time.ZonedDateTime; +import com.fasterxml.jackson.annotation.JsonIdentityReference; +import com.fasterxml.jackson.annotation.JsonProperty; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.validation.constraints.NotNull; +import lombok.Data; +import lombok.EqualsAndHashCode; +@EqualsAndHashCode(callSuper = true) +@Data +@Entity public class ShelterCertificate extends UriEntity { - + + @Id + @GeneratedValue() private Long id; - private Date expirationDate; - @Override - public Long getId() { - return id; - } + @JsonProperty(access = JsonProperty.Access.READ_ONLY) + @NotNull + private ZonedDateTime expirationDate; + + @JsonIdentityReference(alwaysAsId = true) + @ManyToOne + private Shelter shelterServed; } diff --git a/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertificateRepository.java b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertificateRepository.java new file mode 100644 index 00000000..114d4322 --- /dev/null +++ b/src/main/java/cat/udl/eps/softarch/demo/repository/ShelterCertificateRepository.java @@ -0,0 +1,9 @@ +package cat.udl.eps.softarch.demo.repository; + +import cat.udl.eps.softarch.demo.domain.ShelterCertificate; +import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; + +public interface ShelterCertificateRepository extends CrudRepository, PagingAndSortingRepository { + +}