1 | package edu.gjoko.schedlr.entity;
|
---|
2 |
|
---|
3 | import com.fasterxml.jackson.annotation.JsonManagedReference;
|
---|
4 | import com.fasterxml.jackson.annotation.JsonProperty;
|
---|
5 | import lombok.AllArgsConstructor;
|
---|
6 | import lombok.Getter;
|
---|
7 | import lombok.NoArgsConstructor;
|
---|
8 | import lombok.Setter;
|
---|
9 | import org.springframework.data.annotation.CreatedDate;
|
---|
10 | import org.springframework.data.annotation.LastModifiedDate;
|
---|
11 | import org.springframework.data.jpa.domain.support.AuditingEntityListener;
|
---|
12 |
|
---|
13 | import javax.persistence.*;
|
---|
14 | import java.time.LocalDateTime;
|
---|
15 | import java.util.List;
|
---|
16 |
|
---|
17 | @Entity
|
---|
18 | @EntityListeners(AuditingEntityListener.class)
|
---|
19 | @Table(name = "business")
|
---|
20 | @Getter
|
---|
21 | @Setter
|
---|
22 | @NoArgsConstructor
|
---|
23 | @AllArgsConstructor
|
---|
24 | public class Business {
|
---|
25 |
|
---|
26 | @Id
|
---|
27 | @GeneratedValue(strategy = GenerationType.SEQUENCE)
|
---|
28 | private Long id;
|
---|
29 |
|
---|
30 | @Column(name = "company_name")
|
---|
31 | private String companyName;
|
---|
32 |
|
---|
33 | @OneToOne
|
---|
34 | @JoinColumn(name = "business_type_id", referencedColumnName = "id")
|
---|
35 | @JsonProperty("businessType")
|
---|
36 | private BusinessType businessType;
|
---|
37 |
|
---|
38 | @ManyToOne(cascade = CascadeType.PERSIST)
|
---|
39 | @JoinColumn(name = "owner_id", referencedColumnName = "id", nullable = false)
|
---|
40 | @JsonProperty("owner")
|
---|
41 | private Stakeholder owner;
|
---|
42 |
|
---|
43 | @OneToMany(mappedBy = "business", cascade = CascadeType.PERSIST)
|
---|
44 | @JsonManagedReference
|
---|
45 | private List<Service> services;
|
---|
46 |
|
---|
47 | @Column(name = "business_status")
|
---|
48 | @Enumerated(EnumType.STRING)
|
---|
49 | private BusinessStatus businessStatus;
|
---|
50 |
|
---|
51 | @Column(name = "created")
|
---|
52 | @CreatedDate
|
---|
53 | private LocalDateTime created;
|
---|
54 |
|
---|
55 | @Column(name = "modified")
|
---|
56 | @LastModifiedDate
|
---|
57 | private LocalDateTime modified;
|
---|
58 |
|
---|
59 |
|
---|
60 | }
|
---|