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

Last change on this file was f29cd58, checked in by gjoko kostadinov <gjokokostadinov@…>, 10 months ago

Add services search functionality.

  • Property mode set to 100755
File size: 1.9 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 @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}
Note: See TracBrowser for help on using the repository browser.