-
Notifications
You must be signed in to change notification settings - Fork 0
✨ Feat: MatchStatus 확장 및 Admin 매칭 취소 API 추가 #61
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
Changes from all 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 |
|---|---|---|
| @@ -1,7 +1,9 @@ | ||
| package com.be.sportizebe.domain.match.entity; | ||
|
|
||
| public enum MatchStatus { | ||
| OPEN, // 참여 가능 | ||
| FULL, // 정원 마감 | ||
| CLOSED // 운영상 종료(옵션) | ||
| OPEN, // 참여 가능 | ||
| FULL, // 정원 마감 | ||
| CLOSED, // 매칭 시작됨 (scheduledAt 이후, 참여 불가) -> "지금 진행중인 매칭" 탭 보여줄 때 | ||
| COMPLETED, // 매칭 종료 (scheduledAt + durationMinutes 이후) -> "매칭 완료 후 리뷰/평점. 포인트 지금 등 사이드 이펙트 필요 시COM | ||
| CANCELLED // Admin 취소 | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| import com.be.sportizebe.domain.match.entity.MatchParticipant; | ||
| import com.be.sportizebe.domain.match.entity.MatchParticipantStatus; | ||
| import com.be.sportizebe.domain.match.entity.MatchRoom; | ||
| import com.be.sportizebe.domain.match.entity.MatchStatus; | ||
| import com.be.sportizebe.domain.match.exception.MatchErrorCode; | ||
| import com.be.sportizebe.domain.match.repository.MatchParticipantRepository; | ||
| import com.be.sportizebe.domain.match.repository.MatchRoomRepository; | ||
|
|
@@ -126,6 +127,20 @@ public MatchDetailResponse getMatchDetail(Long matchId, Long userId) { | |
| return MatchDetailResponse.of(matchRoom, user); | ||
| } | ||
|
|
||
| @Override | ||
| public void cancelMatch(Long matchId) { | ||
| MatchRoom matchRoom = matchRoomRepository.findById(matchId) | ||
| .orElseThrow(() -> new CustomException(MatchErrorCode.MATCH_NOT_FOUND)); | ||
|
|
||
| if (matchRoom.getStatus() == MatchStatus.CANCELLED | ||
| || matchRoom.getStatus() == MatchStatus.CLOSED | ||
| || matchRoom.getStatus() == MatchStatus.COMPLETED) { | ||
| throw new CustomException(MatchErrorCode.MATCH_CANNOT_CANCEL); | ||
| } | ||
|
|
||
| matchRoom.cancel(); | ||
| } | ||
|
Comment on lines
+130
to
+142
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. 🧩 Analysis chain🏁 Script executed: # First, locate the MatchRoom entity and MatchRoomRepository files
find src/main/java/com/be/sportizebe -name "MatchRoom.java" -o -name "MatchRoomRepository.java"Repository: Sportize/be Length of output: 202 🏁 Script executed: # Check for `@Version`, `@Lock`, and locking-related annotations in the match domain
rg -n "@Version|@Lock|LockModeType|pessimistic|optimistic" src/main/java/com/be/sportizebe/domain/match --type=javaRepository: Sportize/be Length of output: 37 🏁 Script executed: # Find the MatchRoomRepository and examine its current methods
fd "MatchRoomRepository" src/main/java --type=javaRepository: Sportize/be Length of output: 226 🏁 Script executed: # Check the MatchRoom entity for version control
fd "MatchRoom\.java" src/main/java --type=java | head -5Repository: Sportize/be Length of output: 226 🏁 Script executed: # Look for existing usage of locking patterns in similar cancel/update operations
rg -n "findByIdForUpdate|PESSIMISTIC_WRITE" src/main/java/com/be/sportizebe --type=javaRepository: Sportize/be Length of output: 37 🏁 Script executed: # Read the MatchRoom entity to check for `@Version` and other annotations
cat -n src/main/java/com/be/sportizebe/domain/match/entity/MatchRoom.java | head -100Repository: Sportize/be Length of output: 2955 🏁 Script executed: # Read the MatchRoomRepository to check current methods
cat -n src/main/java/com/be/sportizebe/domain/match/repository/MatchRoomRepository.javaRepository: Sportize/be Length of output: 2113 🏁 Script executed: # Search for locking annotations/imports across match domain
rg -n "@Version|@Lock|LockModeType" src/main/java/com/be/sportizebe/domain/matchRepository: Sportize/be Length of output: 37 🏁 Script executed: # Check for pessimistic/optimistic locking patterns
rg -n "findByIdForUpdate|PESSIMISTIC_WRITE|OPTIMISTIC" src/main/java/com/be/sportizebe/domainRepository: Sportize/be Length of output: 37 🏁 Script executed: # Read the full MatchServiceImpl to understand the context better
cat -n src/main/java/com/be/sportizebe/domain/match/service/MatchServiceImpl.java | sed -n '120,150p'Repository: Sportize/be Length of output: 1559 🏁 Script executed: # Check if cancelMatch method has `@Transactional` or other synchronization annotations
cat -n src/main/java/com/be/sportizebe/domain/match/service/MatchServiceImpl.java | head -50Repository: Sportize/be Length of output: 2596 🏁 Script executed: # Check class-level annotations on MatchServiceImpl
rg -A 10 "class MatchServiceImpl" src/main/java/com/be/sportizebe/domain/match/service/MatchServiceImpl.javaRepository: Sportize/be Length of output: 445 🏁 Script executed: # Check if there are any other concurrent cancel/update patterns in the codebase that use locking
rg -B 2 "cancel\(\)" src/main/java/com/be/sportizebe/domain --context=3Repository: Sportize/be Length of output: 1349 동시 취소 요청 시 상태 체크와 변경이 원자적이지 않아 중복 성공이 발생할 수 있습니다.
이 경우 동시 요청이 모두 상태 검사를 통과한 후 실행될 수 있으므로, 두 번째 요청도 성공하게 됩니다. MatchRoom 엔티티에 🔧 제안 수정안- MatchRoom matchRoom = matchRoomRepository.findById(matchId)
+ MatchRoom matchRoom = matchRoomRepository.findByIdForUpdate(matchId)
.orElseThrow(() -> new CustomException(MatchErrorCode.MATCH_NOT_FOUND));// MatchRoomRepository.java (추가)
`@Lock`(LockModeType.PESSIMISTIC_WRITE)
`@Query`("select m from MatchRoom m where m.id = :matchId")
Optional<MatchRoom> findByIdForUpdate(`@Param`("matchId") Long matchId);🤖 Prompt for AI Agents |
||
|
|
||
| @Override | ||
| public void deleteMatch(Long matchId) { | ||
| if (!matchRoomRepository.existsById(matchId)) { | ||
|
|
||
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.
주석 문구가 중간에서 깨져 의미 전달이 어렵습니다.
Line 7의
...필요 시COM은 오탈자/잔여 문자열로 보이며, 상태 정의 주석은 배포 전 정리하는 것이 좋겠습니다.🤖 Prompt for AI Agents