[cf9cdbf] | 1 | package edu.gjoko.schedlr.entity;
|
---|
| 2 |
|
---|
[77205be] | 3 | import com.fasterxml.jackson.annotation.JsonBackReference;
|
---|
| 4 | import lombok.*;
|
---|
[46fd0c7] | 5 | import org.springframework.data.annotation.LastModifiedDate;
|
---|
| 6 | import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
---|
[cf9cdbf] | 7 |
|
---|
| 8 | import javax.persistence.*;
|
---|
| 9 | import java.time.LocalDateTime;
|
---|
| 10 |
|
---|
| 11 | @Entity
|
---|
[46fd0c7] | 12 | @EntityListeners(AuditingEntityListener.class)
|
---|
[cf9cdbf] | 13 | @Table(name = "appointment")
|
---|
[77205be] | 14 | @Data
|
---|
[cf9cdbf] | 15 | @NoArgsConstructor
|
---|
| 16 | @AllArgsConstructor
|
---|
| 17 | public class Appointment {
|
---|
| 18 |
|
---|
| 19 | @Id
|
---|
| 20 | @GeneratedValue(strategy = GenerationType.AUTO)
|
---|
| 21 | private Long id;
|
---|
| 22 |
|
---|
[950fa0d] | 23 | @Column(name = "start_time")
|
---|
[cf9cdbf] | 24 | private LocalDateTime startTime;
|
---|
| 25 |
|
---|
| 26 | @Column(name = "end_time")
|
---|
| 27 | private LocalDateTime endTime;
|
---|
| 28 |
|
---|
[950fa0d] | 29 | @ManyToOne
|
---|
[77205be] | 30 | @JoinColumn(name = "stakeholder_id")
|
---|
| 31 | @JsonBackReference(value = "customerAppointments")
|
---|
| 32 | private Stakeholder customer;
|
---|
[950fa0d] | 33 |
|
---|
| 34 | @ManyToOne
|
---|
| 35 | @JoinColumn(name = "service_id")
|
---|
[77205be] | 36 | @JsonBackReference(value = "serviceAppointments")
|
---|
[950fa0d] | 37 | private Service service;
|
---|
[cf9cdbf] | 38 |
|
---|
[77205be] | 39 | @Column(name = "appointment_status", length = 32, columnDefinition = "varchar(32) default 'NEW'")
|
---|
| 40 | @Enumerated(EnumType.STRING)
|
---|
| 41 | private AppointmentStatus appointmentStatus = AppointmentStatus.NEW;
|
---|
| 42 |
|
---|
[cf9cdbf] | 43 | @Column(name = "created")
|
---|
[46fd0c7] | 44 | @LastModifiedDate
|
---|
[cf9cdbf] | 45 | private LocalDateTime created;
|
---|
| 46 |
|
---|
| 47 | @Column(name = "modified")
|
---|
[46fd0c7] | 48 | @LastModifiedDate
|
---|
[cf9cdbf] | 49 | private LocalDateTime modified;
|
---|
[77205be] | 50 |
|
---|
| 51 | public String getTimePeriod() {
|
---|
| 52 | return startTime + " - " + endTime;
|
---|
| 53 | }
|
---|
| 54 |
|
---|
[cf9cdbf] | 55 | }
|
---|