source: src/main/java/edu/gjoko/schedlr/entity/Service.java@ 77205be

Last change on this file since 77205be was 77205be, checked in by gjoko kostadinov <gjokokostadinov@…>, 6 months ago

Add entire code

  • Property mode set to 100755
File size: 1.7 KB
Line 
1package edu.gjoko.schedlr.entity;
2
3import com.fasterxml.jackson.annotation.JsonBackReference;
4import com.fasterxml.jackson.annotation.JsonIgnore;
5import com.fasterxml.jackson.annotation.JsonManagedReference;
6import lombok.AllArgsConstructor;
7import lombok.Getter;
8import lombok.NoArgsConstructor;
9import lombok.Setter;
10import org.springframework.data.annotation.CreatedDate;
11import org.springframework.data.annotation.LastModifiedDate;
12import org.springframework.data.jpa.domain.support.AuditingEntityListener;
13
14import javax.persistence.*;
15import java.time.LocalDateTime;
16import java.util.List;
17
18@Entity
19@EntityListeners(AuditingEntityListener.class)
20@Table(name = "service")
21@Getter
22@Setter
23@NoArgsConstructor
24@AllArgsConstructor
25public 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 @OneToMany(mappedBy="service")
53 @JsonManagedReference(value = "serviceAppointments")
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}
Note: See TracBrowser for help on using the repository browser.