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

[fix] 추첨 이벤트 참여 대상이 아닌 이벤트 유저가 참여할 수 있는 문제 수정(#107) #109

Merged
merged 2 commits into from
Aug 20, 2024

Conversation

blaxsior
Copy link
Collaborator

#️⃣ 연관 이슈

ex) #107

📝 작업 내용

이벤트 유저가 자신이 속하지 않은 이벤트 프레임의 추첨 이벤트에 접근하지 못하도록 제한하는 조건을 추가했습니다. 이벤트 유저와 이벤트는 모두 db 수준에서 이벤트 프레임에 대한 외래키를 가지고 있으므로, 이벤트 프레임을 fetch하지 않더라도 외래키 비교를 통해 두 객체가 동일한 이벤트 프레임에 속하는지 비교할 수 있습니다.

불필요한 db 접근을 줄이기 위해 이벤트 프레임 엔티티를 각각 fetch하는 대신 외래키를 노출하여 비교하는 방식으로 문제를 처리했습니다.

@blaxsior blaxsior added the fix 버그 및 오류 수정 label Aug 20, 2024
@blaxsior blaxsior self-assigned this Aug 20, 2024
@@ -77,6 +77,10 @@ public boolean isEnded(LocalDateTime now) {
@JoinColumn(name="event_frame_id")
private EventFrame eventFrame;

// eventFrame을 거치지 않고 유저를 확인하기 위해 사용
@Column(name = "event_frame_id", updatable = false, insertable = false)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이벤트 프레임을 fetch하는 대신 외래키끼리 비교할 수 있도록 외래키를 노출했습니다. 단, 외래키와 JoinColumn이 동시에 존재할 때 둘 모두로 업데이트하려고하면 예외가 발생하므로 외래키로는 업데이트나 삽입 동작이 불가능하도록 false로 지정했습니다.

@@ -25,14 +26,15 @@
import static org.mockito.Mockito.*;

class EventParticipationServiceTest {
EventMetadataRepository emRepository = mock(EventMetadataRepository.class);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

중복을 제거하고, 의도와는 다르게 동작하던 테스트 코드를 수정했습니다. instanceOf와 hasMessage을 추가하여 기존 테스트코드에 문제가 있음을 식별하고 수정했습니다.

Copy link
Collaborator

@win-luck win-luck left a comment

Choose a reason for hiding this comment

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

신속한 버그 수정에 감사드립니다.

@blaxsior blaxsior merged commit 9277775 into dev Aug 20, 2024
1 check passed
@win-luck win-luck deleted the fix/107-block-draw-notmatch branch August 23, 2024 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix 버그 및 오류 수정
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[fix] 추첨 이벤트 참여 대상이 아닌 이벤트 유저가 참여할 수 있는 문제 수정(#107)
2 participants