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