1 | package edu.gjoko.schedlr.entity;
|
---|
2 |
|
---|
3 | import com.fasterxml.jackson.annotation.JsonIgnore;
|
---|
4 | import com.fasterxml.jackson.annotation.JsonManagedReference;
|
---|
5 | import com.fasterxml.jackson.annotation.JsonProperty;
|
---|
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 = "business")
|
---|
21 | @Getter
|
---|
22 | @Setter
|
---|
23 | @NoArgsConstructor
|
---|
24 | @AllArgsConstructor
|
---|
25 | public class Business {
|
---|
26 |
|
---|
27 | @Id
|
---|
28 | @GeneratedValue(strategy = GenerationType.SEQUENCE)
|
---|
29 | private Long id;
|
---|
30 |
|
---|
31 | @Column(name = "company_name")
|
---|
32 | private String companyName;
|
---|
33 |
|
---|
34 | @OneToOne
|
---|
35 | @JoinColumn(name = "business_type_id", referencedColumnName = "id")
|
---|
36 | @JsonProperty("businessType")
|
---|
37 | private BusinessType businessType;
|
---|
38 |
|
---|
39 | @OneToOne(cascade = CascadeType.PERSIST)
|
---|
40 | @JoinColumn(name = "owner_id", referencedColumnName = "id", nullable = false)
|
---|
41 | @JsonProperty("owner")
|
---|
42 | private Stakeholder owner;
|
---|
43 |
|
---|
44 | @OneToMany(mappedBy = "business", cascade = CascadeType.PERSIST)
|
---|
45 | @JsonManagedReference(value = "services")
|
---|
46 | private List<Service> services;
|
---|
47 |
|
---|
48 | @Column(name = "business_status")
|
---|
49 | @Enumerated(EnumType.STRING)
|
---|
50 | private BusinessStatus businessStatus;
|
---|
51 |
|
---|
52 | @Column(name = "created")
|
---|
53 | @CreatedDate
|
---|
54 | @JsonIgnore
|
---|
55 | private LocalDateTime created;
|
---|
56 |
|
---|
57 | @Column(name = "modified")
|
---|
58 | @LastModifiedDate
|
---|
59 | @JsonIgnore
|
---|
60 | private LocalDateTime modified;
|
---|
61 |
|
---|
62 |
|
---|
63 | }
|
---|