Skip to content
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

[BE] feat: 새로운 티켓, 티켓팅 도메인 추가 및 레거시 코드 마킹 (#1007-1) #1008

Open
wants to merge 3 commits into
base: feat/#1007
Choose a base branch
from

Conversation

seokjin8678
Copy link
Collaborator

📌 관련 이슈

✨ PR 세부 내용

이슈에 남긴 문제점을 개선한 새로운 티켓 생성, 티켓팅 로직을 추가했습니다.

기능이 많은 관계로 각 feat별로 브랜치를 나눠서 PR 올립니다!

해당 PR은 새로운 도메인인 NewTicket, StageTicket, ReserveTicket에 대한 추가와 단위 테스트로 작성되었습니다.

StageTicket은 JPA의 상속 전략을 사용해 생성되었습니다.

이유는 이슈에 남긴 첫 번째 문제를 해결하려고 하기 위함입니다.

추후 공연이 아닌 행사에 대해 티켓을 생성하고 싶으면 NewTicket을 상속한 엔티티를 추가하면 됩니다.

따라서 예매된 티켓의 생성 책임은 NewTicket에 추상 메서드로 작성되어 있습니다.
(이 때문에 양방향 의존이 발생하는데, 예매에 관련된 정보를 알고있는 객체가 NewTicket이라서 오히려 양방향 의존을 가지게 하는게 맞지 않나 싶네요. 추가로 ticket 패키지와 ticketing 패키지가 분리되어 있는데 하나로 합쳐도 괜찮을 것 같습니다.)

또한 예매 로직의 검증이 서로 분리되어 있는데, 이는 입장 시간을 계산하려고 시퀀스를 구할 때, 시퀀스가 롤백이 되면 안되기에 별도로 분리하였습니다.
(시퀀스 생성 후 예외 발생하면 해당 시퀀스 값이 사라짐, 롤백하려고 시도할 시 동시에 오는 요청 때문에 같은 시퀀스를 가질 위험이 있음)

세부 예매 코드는 이후 PR에 있으니 참고하시면 될 것 같습니다.

그 외 의도했던 내용에 대해선 코드에 리뷰로 남기겠습니다!

@seokjin8678 seokjin8678 added BE 백엔드에 관련된 작업 ☢️ DB 데이터베이스에 변경이 있는 작업 🏗️ 기능 기능 추가에 관한 작업 labels Jun 11, 2024
@seokjin8678 seokjin8678 self-assigned this Jun 11, 2024
Copy link

Test Results

254 files  254 suites   30s ⏱️
835 tests 835 ✅ 0 💤 0 ❌
860 runs  860 ✅ 0 💤 0 ❌

Results for commit 9503869.

@seokjin8678 seokjin8678 changed the title [BE] 새로운 티켓, 티켓팅 도메인 추가 및 레거시 코드 마킹 (#1007-1) [BE] feat: 새로운 티켓, 티켓팅 도메인 추가 및 레거시 코드 마킹 (#1007-1) Jun 11, 2024
Comment on lines 25 to 30
TICKET_CANNOT_RESERVE_STAGE_START("공연의 시작 시간 이후로 예매할 수 없습니다."),
INVALID_STUDENT_VERIFICATION_CODE("올바르지 않은 학생 인증 코드입니다."),
DELETE_CONSTRAINT_FESTIVAL("공연이 등록된 축제는 삭제할 수 없습니다."),
DELETE_CONSTRAINT_STAGE("티켓이 등록된 공연은 삭제할 수 없습니다."),
DELETE_CONSTRAINT_SCHOOL("학생 또는 축제에 등록된 학교는 삭제할 수 없습니다."), // @deprecate
DUPLICATE_SCHOOL("이미 존재하는 학교 정보입니다."), // @deprecate
VALIDATION_FAIL("검증이 실패하였습니다."),
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

추후 ErrorCode 정리가 필요해 보이네요. 😂

Comment on lines +22 to +25
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@NoArgsConstructor(access = AccessLevel.PROTECTED)
public abstract class NewTicket extends BaseTimeEntity {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다른 유형의 티켓을 지원하기 위한 새로운 티켓 엔티티 입니다.

만약 공연이 아닌 행사(Events? Party?)에 티켓팅이 필요하면 해당 클래스를 상속한 구현체를 사용하면 됩니다.

Comment on lines +39 to +42
/**
* 사용자가 최대 예매할 수 있는 티켓의 개수
*/
protected int maxReserveAmount = 1;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 필드의 사용으로 통합 테스트 또는 부하 테스트 시 수월하게 테스트가 가능합니다.

Comment on lines +7 to +30
/**
* 티켓팅을 하는 사용자
*/
@Builder
public class Booker {

private final Long memberId;
private final Long schoolId;

public Booker(Long memberId, Long schoolId) {
Validator.notNull(memberId, "memberId");
this.memberId = memberId;
this.schoolId = schoolId;
}

public Long getMemberId() {
return memberId;
}

@Nullable
public Long getSchoolId() {
return schoolId;
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

티켓팅을 할때 사용자의 개념을 가진 클래스 입니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BE 백엔드에 관련된 작업 ☢️ DB 데이터베이스에 변경이 있는 작업 🏗️ 기능 기능 추가에 관한 작업
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant