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

[feat] 영화 예매 취소하기 API 구현 #16

Merged
merged 19 commits into from
May 16, 2024
Merged

[feat] 영화 예매 취소하기 API 구현 #16

merged 19 commits into from
May 16, 2024

Conversation

kgy1008
Copy link
Contributor

@kgy1008 kgy1008 commented May 15, 2024

Related Issue 📌

Description ✔️

영화 예매 취소하기 api 구현
예매 취소하기를 눌렀을 때, 해당 영화의 모든 예매 내역을 삭제하도록 구현함

public class Ticket {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ManyToOne(fetch = FetchType.LAZY)
private Theater theater;
private Long movieId;
@Builder
private Ticket(Theater theater) {
this.theater = theater;
this.movieId = theater.getMovie().getId();
}
public static Ticket create(Theater theater) {
return Ticket.builder()
.theater(theater)
.build();
}
}

Ticket 엔티티를 구현하였는데, 영화 기본키 값을 넣기 위해서 Movie 엔티티와 연관관계를 설정하였더니 이행적 함수 종속(?) 형태가 되는 것 같아서.. 아래 그림처럼 erd가 좀 이상해.. (이거 이렇게 되면 안된다고 배웠던거 같은데..)
image

그래서 굳이 Movie랑 연관관계를 짓지 않고 기존의 theaters 속성으로 영화의 기본키 값을 불러올 수 있어서 코드를 위처럼 작성했는데 이 방법말고 그냥 Movie 엔티티랑 연관관계를 맺는게 더 나을까??

image

@kgy1008 kgy1008 self-assigned this May 15, 2024
@tkdwns414
Copy link
Contributor

사실 내가 처음에 생각했던건 그냥 theaters에서 가져오는 방식이 맞아. 그런데 이게 합동세미나에서 하는거다보니 우리가 원하는대로 ERD가 안 나올 수밖에 없어. 원래대로면 표를 취소할 때 표만 가져오면 되는거니까 무비랑 직접 연관을 맺을 일이 없는데 이번에는 그런 형식이 아니라 영화 조회 페이지에서 취소되는 로직이라(표 뷰가 따로 없으니까) 일어난 일 같아. 그래서 네가 말한 두 방법 중 어느 방법으로 해도 앞으로의 프로젝트에서는 이런식으로 꼬이는 일이 발생하지는 않을 것 같아

@kgy1008 kgy1008 merged commit 603f921 into develop May 16, 2024
1 check passed
@kgy1008 kgy1008 deleted the feat/13 branch May 16, 2024 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feat] 영화 예매 취소하기 API 구현
2 participants