-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor : 티켓 타입 기획 수정 반영 #339
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,9 +27,9 @@ public class TicketItem extends BaseTimeEntity { | |
@Column(name = "ticket_item_id") | ||
private Long id; | ||
|
||
// 티켓 타입 | ||
// 티켓 지불 타입 | ||
@Enumerated(EnumType.STRING) | ||
private TicketType type; | ||
private TicketPayType payType; | ||
|
||
// 티켓 이름 | ||
private String name; | ||
|
@@ -49,6 +49,16 @@ public class TicketItem extends BaseTimeEntity { | |
// 1인당 구매 매수 제한 | ||
private Long purchaseLimit; | ||
|
||
// 티켓 승인 타입 | ||
@Enumerated(EnumType.STRING) | ||
private TicketType type; | ||
|
||
// 계좌번호 | ||
private String accountNumber; | ||
|
||
// 재고 공개 여부 | ||
private Boolean isQuantityPublic; | ||
|
||
// 판매 가능 여부 | ||
private Boolean isSellable; | ||
|
||
|
@@ -72,24 +82,30 @@ public class TicketItem extends BaseTimeEntity { | |
|
||
@Builder | ||
public TicketItem( | ||
TicketType type, | ||
TicketPayType payType, | ||
String name, | ||
String description, | ||
Money price, | ||
Long quantity, | ||
Long supplyCount, | ||
Long purchaseLimit, | ||
TicketType type, | ||
String accountNumber, | ||
Boolean isQuantityPublic, | ||
Boolean isSellable, | ||
LocalDateTime saleStartAt, | ||
LocalDateTime saleEndAt, | ||
Event event) { | ||
this.type = type; | ||
this.payType = payType; | ||
this.name = name; | ||
this.description = description; | ||
this.price = price; | ||
this.quantity = quantity; | ||
this.supplyCount = supplyCount; | ||
this.purchaseLimit = purchaseLimit; | ||
this.type = type; | ||
this.accountNumber = accountNumber; | ||
this.isQuantityPublic = isQuantityPublic; | ||
this.isSellable = isSellable; | ||
this.saleStartAt = saleStartAt; | ||
this.saleEndAt = saleEndAt; | ||
|
@@ -132,9 +148,33 @@ public void validateEventId(Long eventId) { | |
} | ||
} | ||
|
||
public void validateTicketPrice() { | ||
if (!Money.ZERO.equals(this.price)) { | ||
throw InvalidTicketPriceException.EXCEPTION; | ||
public void validateTicketPayType(Boolean isPartner) { | ||
// 두둥티켓은 무조건 승인 + 계좌번호 필요 | ||
if (this.payType.equals(TicketPayType.DUDOONG_TICKET)) { | ||
if (!this.type.equals(TicketType.APPROVAL)) { | ||
throw InvalidTicketTypeException.EXCEPTION; | ||
} | ||
if (this.accountNumber == null || this.accountNumber.isBlank()) { | ||
throw EmptyAccountNumberException.EXCEPTION; | ||
} | ||
} | ||
// 유료티켓은 무조건 선착순 + 제휴 확인 + 1000원 이상 | ||
else if (this.payType.equals(TicketPayType.PRICE_TICKET)) { | ||
if (!this.type.equals(TicketType.FIRST_COME_FIRST_SERVED)) { | ||
throw InvalidTicketTypeException.EXCEPTION; | ||
} | ||
if (!isPartner) { | ||
throw InvalidPartnerException.EXCEPTION; | ||
} | ||
if (this.price.isLessThan(Money.wons(1000))) { | ||
throw InvalidTicketPriceException.EXCEPTION; | ||
} | ||
} | ||
// 무료티켓은 무조건 0원 | ||
else { | ||
if (!this.price.equals(Money.ZERO)) { | ||
throw InvalidTicketPriceException.EXCEPTION; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TicketPayType 이넘안에서 레퍼런스
근데 이건뭐 자율입니당 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이부분은 좀 더 고민을 해보겠숩니당! |
||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package band.gosrock.domain.domains.ticket_item.domain; | ||
|
||
|
||
import com.fasterxml.jackson.annotation.JsonValue; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum TicketPayType { | ||
// 두둥티켓 | ||
DUDOONG_TICKET("DUDOONG_TICKET", "두둥티켓"), | ||
// 무료티켓 | ||
FREE_TICKET("FREE_TICKET", "무료티켓"), | ||
// 유료티켓 | ||
PRICE_TICKET("PRICE_TICKET", "유료티켓"); | ||
|
||
private String value; | ||
|
||
@JsonValue private String kr; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이러면 스웨거엔 한글로 뜰텐데 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 어라 저희 스웨거 한글로 통일한거 아녔나여?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ㅇㅇㅇ 근데 한글로 입력받을 수 있나? JsonCreater 같은걸로 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 그냥 두둥티켓, 무료티켓, 유료티켓 이렇게 입력하게 해놧는디? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 그렇게 하면 받아짐? 굿굿 잘했넹 ㅇㅋㅇㅋ |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package band.gosrock.domain.domains.ticket_item.exception; | ||
|
||
|
||
import band.gosrock.common.exception.DuDoongCodeException; | ||
|
||
public class EmptyAccountNumberException extends DuDoongCodeException { | ||
|
||
public static final DuDoongCodeException EXCEPTION = new EmptyAccountNumberException(); | ||
|
||
private EmptyAccountNumberException() { | ||
super(TicketItemErrorCode.EMPTY_ACCOUT_NUMBER); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package band.gosrock.domain.domains.ticket_item.exception; | ||
|
||
|
||
import band.gosrock.common.exception.DuDoongCodeException; | ||
|
||
public class InvalidPartnerException extends DuDoongCodeException { | ||
|
||
public static final DuDoongCodeException EXCEPTION = new InvalidPartnerException(); | ||
|
||
private InvalidPartnerException() { | ||
super(TicketItemErrorCode.INVALID_PARTNER); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package band.gosrock.domain.domains.ticket_item.exception; | ||
|
||
|
||
import band.gosrock.common.exception.DuDoongCodeException; | ||
|
||
public class InvalidTicketTypeException extends DuDoongCodeException { | ||
|
||
public static final DuDoongCodeException EXCEPTION = new InvalidTicketTypeException(); | ||
|
||
private InvalidTicketTypeException() { | ||
super(TicketItemErrorCode.INVALID_TICKET_TYPE); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,9 +18,8 @@ public class TicketItemService { | |
|
||
@Transactional | ||
public TicketItem createTicketItem(TicketItem ticketItem, Boolean isPartner) { | ||
if (!isPartner) { | ||
ticketItem.validateTicketPrice(); | ||
} | ||
|
||
ticketItem.validateTicketPayType(isPartner); | ||
Comment on lines
-21
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 굿 잘 집어넣으셨네용 |
||
return ticketItemAdaptor.save(ticketItem); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StringUtils isEmpty 있을거에요!