1 | package edu.gjoko.schedlr.entity;
|
---|
2 |
|
---|
3 | import com.fasterxml.jackson.annotation.JsonIgnore;
|
---|
4 | import com.fasterxml.jackson.annotation.JsonManagedReference;
|
---|
5 | import lombok.AllArgsConstructor;
|
---|
6 | import lombok.Getter;
|
---|
7 | import lombok.NoArgsConstructor;
|
---|
8 | import lombok.Setter;
|
---|
9 | import org.springframework.data.annotation.CreatedDate;
|
---|
10 | import org.springframework.data.annotation.LastModifiedDate;
|
---|
11 | import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
---|
12 |
|
---|
13 | import javax.persistence.*;
|
---|
14 | import java.time.LocalDateTime;
|
---|
15 | import java.util.List;
|
---|
16 |
|
---|
17 | @Entity
|
---|
18 | @EntityListeners(AuditingEntityListener.class)
|
---|
19 | @Table(name = "stakeholder")
|
---|
20 | @Getter
|
---|
21 | @Setter
|
---|
22 | @NoArgsConstructor
|
---|
23 | @AllArgsConstructor
|
---|
24 | public class Stakeholder {
|
---|
25 |
|
---|
26 | @Id
|
---|
27 | @GeneratedValue(strategy = GenerationType.SEQUENCE)
|
---|
28 | private Long id;
|
---|
29 |
|
---|
30 | @Column(name = "stakeholder_type")
|
---|
31 | @Enumerated(EnumType.STRING)
|
---|
32 | private StakeholderType stakeholderType;
|
---|
33 |
|
---|
34 | @Column(name = "first_name")
|
---|
35 | private String firstName;
|
---|
36 |
|
---|
37 | @Column(name = "last_name")
|
---|
38 | private String lastName;
|
---|
39 |
|
---|
40 | @Column(name = "email")
|
---|
41 | private String email;
|
---|
42 |
|
---|
43 | @Column(name = "phone_number")
|
---|
44 | private String phoneNumber;
|
---|
45 |
|
---|
46 | @Column(name = "username")
|
---|
47 | private String username;
|
---|
48 |
|
---|
49 | @Column(name = "password")
|
---|
50 | private String password;
|
---|
51 |
|
---|
52 | @OneToMany(mappedBy = "customer")
|
---|
53 | @JsonManagedReference(value = "customerAppointments")
|
---|
54 | private List<Appointment> appointments;
|
---|
55 |
|
---|
56 | @Column(name = "created")
|
---|
57 | @CreatedDate
|
---|
58 | @JsonIgnore
|
---|
59 | private LocalDateTime created;
|
---|
60 |
|
---|
61 | @Column(name = "modified")
|
---|
62 | @LastModifiedDate
|
---|
63 | @JsonIgnore
|
---|
64 | private LocalDateTime modified;
|
---|
65 |
|
---|
66 | public String getFullName() {
|
---|
67 | return firstName + " " + lastName;
|
---|
68 | }
|
---|
69 | }
|
---|