-
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: 발급 티켓 도메인 메서드 정리 및 API 추가 #180
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
...-Api/src/main/java/band/gosrock/api/issuedTicket/service/EntranceIssuedTicketUseCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package band.gosrock.api.issuedTicket.service; | ||
|
||
|
||
import band.gosrock.api.common.UserUtils; | ||
import band.gosrock.api.issuedTicket.mapper.IssuedTicketMapper; | ||
import band.gosrock.common.annotation.UseCase; | ||
import band.gosrock.domain.common.vo.IssuedTicketInfoVo; | ||
import band.gosrock.domain.domains.issuedTicket.service.IssuedTicketDomainService; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@UseCase | ||
@RequiredArgsConstructor | ||
public class EntranceIssuedTicketUseCase { | ||
|
||
private final IssuedTicketDomainService issuedTicketDomainService; | ||
|
||
private final IssuedTicketMapper issuedTicketMapper; | ||
|
||
private final UserUtils userUtils; | ||
|
||
public IssuedTicketInfoVo execute(Long issuedTicketId) { | ||
Long currentUserId = userUtils.getCurrentUserId(); | ||
return issuedTicketDomainService.processingEntranceIssuedTicket( | ||
currentUserId, issuedTicketId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,10 @@ | |
import band.gosrock.domain.domains.event.domain.Event; | ||
import band.gosrock.domain.domains.issuedTicket.dto.request.CreateIssuedTicketDTO; | ||
import band.gosrock.domain.domains.issuedTicket.dto.response.CreateIssuedTicketResponse; | ||
import band.gosrock.domain.domains.issuedTicket.exception.CanNotCancelEntranceException; | ||
import band.gosrock.domain.domains.issuedTicket.exception.CanNotCancelException; | ||
import band.gosrock.domain.domains.issuedTicket.exception.CanNotEntranceException; | ||
import band.gosrock.domain.domains.issuedTicket.exception.IssuedTicketAlreadyEntranceException; | ||
import band.gosrock.domain.domains.ticket_item.domain.TicketItem; | ||
import band.gosrock.domain.domains.user.domain.User; | ||
import java.util.ArrayList; | ||
|
@@ -57,7 +61,6 @@ public class IssuedTicket extends BaseTimeEntity { | |
|
||
/* | ||
발급 티켓의 주문 행 (단방향) | ||
Todo: 발급 티켓이 굳이 order line 을 알아야 할까? -찬진 OrderResponse 에서 필요함! 연관관계는 따로안짓고 레지스터리에서 불러올게용ㄴ | ||
*/ | ||
private Long orderLineId; | ||
|
||
|
@@ -98,7 +101,7 @@ public void addOptionAnswers(List<IssuedTicketOptionAnswer> answers) { | |
private Money price; | ||
|
||
/* | ||
상태 | ||
발급 티켓 상태 | ||
*/ | ||
@Enumerated(EnumType.STRING) | ||
private IssuedTicketStatus issuedTicketStatus = IssuedTicketStatus.ENTRANCE_INCOMPLETE; | ||
|
@@ -127,6 +130,11 @@ public IssuedTicket( | |
this.issuedTicketOptionAnswers.addAll(issuedTicketOptionAnswers); | ||
} | ||
|
||
/** ---------------------------- 생성 관련 메서드 ---------------------------------- */ | ||
|
||
/* | ||
개발 및 테스트 용도로 사용되는 티켓 발급 정적 메서드 | ||
*/ | ||
public static IssuedTicket createForDev( | ||
Event event, | ||
User user, | ||
|
@@ -149,16 +157,25 @@ public static IssuedTicket createForDev( | |
return createIssuedTicket; | ||
} | ||
|
||
/* | ||
issuedTicket 생성하면서 UUID 생성 | ||
*/ | ||
@PrePersist | ||
public void createUUID() { | ||
this.uuid = UUID.randomUUID().toString(); | ||
} | ||
|
||
/* | ||
issuedTicket 생성하면서 티켓 넘버 부여 | ||
*/ | ||
@PostPersist | ||
public void createIssuedTicketNo() { | ||
this.issuedTicketNo = "T" + Long.sum(NO_START_NUMBER, this.id); | ||
} | ||
|
||
/* | ||
발급 티켓 옵션들 합 계산 | ||
*/ | ||
public Money sumOptionPrice() { | ||
return issuedTicketOptionAnswers.stream() | ||
.map( | ||
|
@@ -167,10 +184,16 @@ public Money sumOptionPrice() { | |
.reduce(Money.ZERO, Money::plus); | ||
} | ||
|
||
/* | ||
issuedTicket VO 변환 메서드 | ||
*/ | ||
public IssuedTicketInfoVo toIssuedTicketInfoVo() { | ||
return IssuedTicketInfoVo.from(this); | ||
} | ||
|
||
/* | ||
orderLine -> issuedTicket 생성 메서드 | ||
*/ | ||
public static CreateIssuedTicketResponse orderLineItemToIssuedTickets( | ||
CreateIssuedTicketDTO dto) { | ||
long quantity = dto.getOrderLineItem().getQuantity(); | ||
|
@@ -196,7 +219,41 @@ public static CreateIssuedTicketResponse orderLineItemToIssuedTickets( | |
return new CreateIssuedTicketResponse(createIssuedTickets, issuedTicketOptionAnswers); | ||
} | ||
|
||
public void cancelIssuedTicket() { | ||
/** ---------------------------- 상태 변환 관련 메서드 ---------------------------------- */ | ||
|
||
/* | ||
발급 티켓 취소 메서드 | ||
티켓이 입장 미완료 상태가 아니면 취소 할 수 없음 | ||
*/ | ||
public void cancel() { | ||
if (this.issuedTicketStatus != IssuedTicketStatus.ENTRANCE_INCOMPLETE) { | ||
throw CanNotCancelException.EXCEPTION; | ||
} | ||
this.issuedTicketStatus = IssuedTicketStatus.CANCELED; | ||
} | ||
|
||
/* | ||
발급 티켓으로 입장 시 상태 변환 메서드 | ||
티켓이 입장 미완료 상태가 아니면 입장 할 수 없음 | ||
*/ | ||
public void entrance() { | ||
if (this.issuedTicketStatus == IssuedTicketStatus.CANCELED) { | ||
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. 백기선 님 강좌듣는데 이넘값을 == 으로 비교하면 더 좋다 그러더라구요 |
||
throw CanNotEntranceException.EXCEPTION; | ||
} | ||
if (this.issuedTicketStatus == IssuedTicketStatus.ENTRANCE_COMPLETED) { | ||
throw IssuedTicketAlreadyEntranceException.EXCEPTION; | ||
} | ||
this.issuedTicketStatus = IssuedTicketStatus.ENTRANCE_COMPLETED; | ||
} | ||
|
||
/* | ||
입장 처리 취소 메서드 | ||
티켓이 입장 완료 상태가 아니면 입장 취소 할 수 없음 | ||
*/ | ||
public void entranceCancel() { | ||
if (this.issuedTicketStatus != IssuedTicketStatus.ENTRANCE_COMPLETED) { | ||
throw CanNotCancelEntranceException.EXCEPTION; | ||
} | ||
this.issuedTicketStatus = IssuedTicketStatus.ENTRANCE_INCOMPLETE; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...ava/band/gosrock/domain/domains/issuedTicket/exception/CanNotCancelEntranceException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package band.gosrock.domain.domains.issuedTicket.exception; | ||
|
||
|
||
import band.gosrock.common.exception.DuDoongCodeException; | ||
|
||
public class CanNotCancelEntranceException extends DuDoongCodeException { | ||
|
||
public static final DuDoongCodeException EXCEPTION = new CanNotCancelEntranceException(); | ||
|
||
private CanNotCancelEntranceException() { | ||
super(IssuedTicketErrorCode.CAN_NOT_CANCEL_ENTRANCE); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...c/main/java/band/gosrock/domain/domains/issuedTicket/exception/CanNotCancelException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package band.gosrock.domain.domains.issuedTicket.exception; | ||
|
||
|
||
import band.gosrock.common.exception.DuDoongCodeException; | ||
|
||
public class CanNotCancelException extends DuDoongCodeException { | ||
|
||
public static final DuDoongCodeException EXCEPTION = new CanNotCancelException(); | ||
|
||
private CanNotCancelException() { | ||
super(IssuedTicketErrorCode.CAN_NOT_CANCEL); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...main/java/band/gosrock/domain/domains/issuedTicket/exception/CanNotEntranceException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package band.gosrock.domain.domains.issuedTicket.exception; | ||
|
||
|
||
import band.gosrock.common.exception.DuDoongCodeException; | ||
|
||
public class CanNotEntranceException extends DuDoongCodeException { | ||
|
||
public static final DuDoongCodeException EXCEPTION = new CanNotEntranceException(); | ||
|
||
private CanNotEntranceException() { | ||
super(IssuedTicketErrorCode.CAN_NOT_ENTRANCE); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
...d/gosrock/domain/domains/issuedTicket/exception/IssuedTicketAlreadyEntranceException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package band.gosrock.domain.domains.issuedTicket.exception; | ||
|
||
|
||
import band.gosrock.common.exception.DuDoongCodeException; | ||
|
||
public class IssuedTicketAlreadyEntranceException extends DuDoongCodeException { | ||
|
||
public static final DuDoongCodeException EXCEPTION = new IssuedTicketAlreadyEntranceException(); | ||
|
||
private IssuedTicketAlreadyEntranceException() { | ||
super(IssuedTicketErrorCode.ISSUED_TICKET_ALREADY_ENTRANCE); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
cancel 로 통일시키는게 좋아보입니당!