1 | package edu.gjoko.schedlr.entity;
|
---|
2 |
|
---|
3 | import com.fasterxml.jackson.annotation.JsonBackReference;
|
---|
4 | import com.fasterxml.jackson.annotation.JsonIgnore;
|
---|
5 | import com.fasterxml.jackson.annotation.JsonManagedReference;
|
---|
6 | import lombok.AllArgsConstructor;
|
---|
7 | import lombok.Getter;
|
---|
8 | import lombok.NoArgsConstructor;
|
---|
9 | import lombok.Setter;
|
---|
10 | import org.springframework.data.annotation.CreatedDate;
|
---|
11 | import org.springframework.data.annotation.LastModifiedDate;
|
---|
12 | import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
---|
13 |
|
---|
14 | import javax.persistence.*;
|
---|
15 | import java.time.LocalDateTime;
|
---|
16 | import java.util.List;
|
---|
17 |
|
---|
18 | @Entity
|
---|
19 | @EntityListeners(AuditingEntityListener.class)
|
---|
20 | @Table(name = "service")
|
---|
21 | @Getter
|
---|
22 | @Setter
|
---|
23 | @NoArgsConstructor
|
---|
24 | @AllArgsConstructor
|
---|
25 | public class Service {
|
---|
26 |
|
---|
27 | @Id
|
---|
28 | @GeneratedValue(strategy = GenerationType.SEQUENCE)
|
---|
29 | private Long id;
|
---|
30 |
|
---|
31 | @Column(name = "duration")
|
---|
32 | private Integer duration;
|
---|
33 |
|
---|
34 | @Column(name = "price")
|
---|
35 | private Integer price;
|
---|
36 |
|
---|
37 | @Column(name = "cumulated_rating")
|
---|
38 | private Float rating = 0.0f;
|
---|
39 |
|
---|
40 | @Column(name = "reviews_count")
|
---|
41 | private Integer reviewsCount = 0;
|
---|
42 |
|
---|
43 | @OneToOne(cascade = CascadeType.MERGE)
|
---|
44 | @JoinColumn(name = "service_type_id", referencedColumnName = "id")
|
---|
45 | private ServiceType serviceType;
|
---|
46 |
|
---|
47 | @ManyToOne
|
---|
48 | @JoinColumn(name = "business_id")
|
---|
49 | @JsonBackReference(value = "services")
|
---|
50 | private Business business;
|
---|
51 |
|
---|
52 | @Column(name = "description")
|
---|
53 | private String description;
|
---|
54 |
|
---|
55 | @OneToMany(mappedBy="service")
|
---|
56 | @JsonManagedReference(value = "serviceAppointments")
|
---|
57 | private List<Appointment> appointments;
|
---|
58 |
|
---|
59 | @Column(name = "service_status")
|
---|
60 | @Enumerated(EnumType.STRING)
|
---|
61 | private ServiceStatus serviceStatus = ServiceStatus.ACTIVE;
|
---|
62 |
|
---|
63 | @Column(name = "created")
|
---|
64 | @CreatedDate
|
---|
65 | @JsonIgnore
|
---|
66 | private LocalDateTime created;
|
---|
67 |
|
---|
68 | @Column(name = "modified")
|
---|
69 | @LastModifiedDate
|
---|
70 | @JsonIgnore
|
---|
71 | private LocalDateTime modified;
|
---|
72 | }
|
---|