-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAmateurShow.java
More file actions
171 lines (132 loc) · 5.6 KB
/
AmateurShow.java
File metadata and controls
171 lines (132 loc) · 5.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
package cc.backend.amateurShow.entity;
import cc.backend.amateurShow.dto.AmateurUpdateRequestDTO;
import cc.backend.amateurShow.entity.enums.ApprovalStatus;
import cc.backend.domain.common.BaseEntity;
import cc.backend.member.entity.Member;
import cc.backend.photoAlbum.entity.PhotoAlbum;
import jakarta.persistence.*;
import lombok.*;
import org.hibernate.annotations.BatchSize;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
@Entity
@Getter
@Builder
@AllArgsConstructor
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public class AmateurShow extends BaseEntity {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(nullable = false, columnDefinition = "bigint")
private Long id;
private String name;
private LocalDate start;
private LocalDate end;
private String performerName; // 공연진 이름
private String hallName; // 공연장 이름
//private String place; // 공연장 주소
private String roadAddress; // 공연장 도로명 주소
private String detailAddress; // 공연장 상세 주소
private String bankName; // 은행명
private String account; // 계좌번호
private String depositor; // 입금자명
// 추가
private String runtime;
private String hashtag;
private String contact;
private String rejectReason;
private Integer cancelFee;
private String summary;
private String posterImageUrl;
private Integer totalSoldTicket;
@Enumerated(EnumType.STRING)
@Builder.Default
@Column(length = 30)
private AmateurShowStatus status = AmateurShowStatus.YET; // default로 yet, 수정 필요
// 승인 여부 enum 분리
@Enumerated(EnumType.STRING)
@Builder.Default
@Column(length = 30)
private ApprovalStatus approvalStatus = ApprovalStatus.WAITING; // default로 waiting
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
private Member member;
@OneToMany (mappedBy = "amateurShow", cascade = CascadeType.PERSIST)
@Builder.Default
private List<PhotoAlbum> photoAlbums = new ArrayList<>();
@OneToMany(mappedBy = "amateurShow", cascade = CascadeType.ALL, orphanRemoval = true)
@BatchSize(size = 10)
@Builder.Default
private List<AmateurTicket> amateurTicketList = new ArrayList<>();
@OneToMany(mappedBy = "amateurShow", cascade = CascadeType.ALL, orphanRemoval = true)
@BatchSize(size = 10)
@Builder.Default
private List<AmateurCasting> amateurCastingList = new ArrayList<>();
@OneToOne(mappedBy = "amateurShow", cascade = CascadeType.ALL, orphanRemoval = true)
private AmateurNotice amateurNotice;
@OneToMany(mappedBy = "amateurShow", cascade = CascadeType.ALL, orphanRemoval = true)
@BatchSize(size = 10)
@Builder.Default
private List<AmateurStaff> amateurStaffList = new ArrayList<>();
//--공연 회차랑 날짜 넣기--
@OneToMany(mappedBy = "amateurShow", cascade = CascadeType.ALL, orphanRemoval = true)
@BatchSize(size = 10)
@Builder.Default
private List<AmateurRounds> amateurRounds = new ArrayList<>();
@Builder
public AmateurShow(String name, String detailAddress, LocalDate start, LocalDate end, List<PhotoAlbum> photoAlbums) {
this.name = name;
this.detailAddress = detailAddress;
this.start = start;
this.end = end;
this.photoAlbums = photoAlbums;
}
public void updateInfo(AmateurUpdateRequestDTO dto) {
if (dto.getName() != null) this.name = dto.getName();
//if (dto.getPlace() != null) this.place = dto.getPlace();
if (dto.getPerformerName() != null) this.performerName = dto.getPerformerName();
if (dto.getHallName() != null) this.hallName = dto.getHallName();
if (dto.getRoadAddress() != null) this.roadAddress = dto.getRoadAddress();
if (dto.getDetailAddress() != null) this.detailAddress = dto.getDetailAddress();
if (dto.getBankName() != null) this.bankName = dto.getBankName();
if (dto.getDepositor() != null) this.depositor = dto.getDepositor();
if (dto.getStart() != null) this.start = dto.getStart();
if (dto.getEnd() != null) this.end = dto.getEnd();
if (dto.getRuntime() != null) this.runtime = dto.getRuntime();
if (dto.getAccount() != null) this.account = dto.getAccount();
if (dto.getContact() != null) this.contact = dto.getContact();
if (dto.getHashtag() != null) this.hashtag = dto.getHashtag();
if (dto.getSummary() != null) this.summary = dto.getSummary();
}
public void increaseSoldTicket(int quantity) {
if (this.totalSoldTicket == null) {
this.totalSoldTicket = 0;
}
this.totalSoldTicket += quantity;
}
public void decreaseSoldTicket(int quantity) {
if (this.totalSoldTicket == null) {
this.totalSoldTicket = 0;
}
this.totalSoldTicket = Math.max(0, this.totalSoldTicket - quantity);
}
public void updatePosterImageUrl(String posterImageUrl){
this.posterImageUrl = posterImageUrl;
}
public void reviseShowInfo(String hashtag, String summary, String account, String contact) {
this.hashtag = hashtag;
this.summary = summary;
this.account = account;
this.contact = contact;
}
public void approve(){
this.approvalStatus = ApprovalStatus.APPROVED;
this.status = AmateurShowStatus.YET;
}
public void reject(String rejectReason){
this.approvalStatus = ApprovalStatus.REJECTED;
this.status = AmateurShowStatus.REJECT;
this.rejectReason = rejectReason;
}
}