[cf9cdbf] | 1 | package edu.gjoko.schedlr.entity;
|
---|
| 2 |
|
---|
[a436340] | 3 | import com.fasterxml.jackson.annotation.JsonBackReference;
|
---|
[8bcd64c] | 4 | import com.fasterxml.jackson.annotation.JsonIgnore;
|
---|
[77205be] | 5 | import com.fasterxml.jackson.annotation.JsonManagedReference;
|
---|
[cf9cdbf] | 6 | import lombok.AllArgsConstructor;
|
---|
| 7 | import lombok.Getter;
|
---|
| 8 | import lombok.NoArgsConstructor;
|
---|
| 9 | import lombok.Setter;
|
---|
[204464d] | 10 | import org.springframework.data.annotation.CreatedDate;
|
---|
| 11 | import org.springframework.data.annotation.LastModifiedDate;
|
---|
| 12 | import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
---|
[cf9cdbf] | 13 |
|
---|
| 14 | import javax.persistence.*;
|
---|
[204464d] | 15 | import java.time.LocalDateTime;
|
---|
[77205be] | 16 | import java.util.List;
|
---|
[cf9cdbf] | 17 |
|
---|
| 18 | @Entity
|
---|
[204464d] | 19 | @EntityListeners(AuditingEntityListener.class)
|
---|
[cf9cdbf] | 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 |
|
---|
[8bcd64c] | 34 | @Column(name = "price")
|
---|
| 35 | private Integer price;
|
---|
| 36 |
|
---|
[77205be] | 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)
|
---|
[a436340] | 44 | @JoinColumn(name = "service_type_id", referencedColumnName = "id")
|
---|
| 45 | private ServiceType serviceType;
|
---|
| 46 |
|
---|
[cf9cdbf] | 47 | @ManyToOne
|
---|
[950fa0d] | 48 | @JoinColumn(name = "business_id")
|
---|
[77205be] | 49 | @JsonBackReference(value = "services")
|
---|
[cf9cdbf] | 50 | private Business business;
|
---|
[204464d] | 51 |
|
---|
[77205be] | 52 | @OneToMany(mappedBy="service")
|
---|
| 53 | @JsonManagedReference(value = "serviceAppointments")
|
---|
| 54 | private List<Appointment> appointments;
|
---|
| 55 |
|
---|
[1413ee2] | 56 | @Column(name = "service_status")
|
---|
| 57 | @Enumerated(EnumType.STRING)
|
---|
[53765dd] | 58 | private ServiceStatus serviceStatus = ServiceStatus.ACTIVE;
|
---|
[1413ee2] | 59 |
|
---|
[204464d] | 60 | @Column(name = "created")
|
---|
| 61 | @CreatedDate
|
---|
[8bcd64c] | 62 | @JsonIgnore
|
---|
[204464d] | 63 | private LocalDateTime created;
|
---|
| 64 |
|
---|
| 65 | @Column(name = "modified")
|
---|
| 66 | @LastModifiedDate
|
---|
[8bcd64c] | 67 | @JsonIgnore
|
---|
[204464d] | 68 | private LocalDateTime modified;
|
---|
[cf9cdbf] | 69 | }
|
---|