Skip to content

Commit

Permalink
refactor: 매칭 API 엔드포인트 구조 개선
Browse files Browse the repository at this point in the history
  • Loading branch information
23tae committed Dec 1, 2024
1 parent 7e60e28 commit e8d2548
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
18 changes: 9 additions & 9 deletions src/main/kotlin/uoslife/servermeeting/match/api/MatchApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ class MatchApi(
),
]
)
@GetMapping("/teams/participation")
fun getMeetingParticipation(
@GetMapping("/me/participations")
fun getUserMeetingParticipation(
@AuthenticationPrincipal userDetails: UserDetails
): ResponseEntity<MeetingParticipationResponse> {
val result = matchingService.getMeetingParticipation(userDetails.username.toLong())
val result = matchingService.getUserMeetingParticipation(userDetails.username.toLong())
return ResponseEntity.ok(result)
}

Expand Down Expand Up @@ -78,13 +78,13 @@ class MatchApi(
)]
)]
)
@GetMapping("/teams/{meetingTeamId}/result")
@GetMapping("/teams/{teamId}/result")
fun getMatchResult(
@PathVariable meetingTeamId: Long,
@PathVariable teamId: Long,
@AuthenticationPrincipal userDetails: UserDetails
): ResponseEntity<MatchResultResponse> {
return ResponseEntity.ok(
matchingService.getMatchResult(userDetails.username.toLong(), meetingTeamId)
matchingService.getMatchResult(userDetails.username.toLong(), teamId)
)
}

Expand Down Expand Up @@ -138,14 +138,14 @@ class MatchApi(
),
]
)
@GetMapping("/matches/{matchId}/partner")
fun getMatchedMeetingTeamInformation(
@GetMapping("/{matchId}/partner")
fun getMatchedPartnerInformation(
@PathVariable matchId: Long,
@AuthenticationPrincipal userDetails: UserDetails,
): ResponseEntity<MeetingTeamInformationGetResponse> {
return ResponseEntity.status(HttpStatus.OK)
.body(
matchingService.getMatchPartnerInformation(userDetails.username.toLong(), matchId)
matchingService.getMatchedPartnerInformation(userDetails.username.toLong(), matchId)
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class MatchingService(
private val singleMeetingService: SingleMeetingService,
private val tripleMeetingService: TripleMeetingService,
) {
fun getMeetingParticipation(userId: Long): MeetingParticipationResponse {
fun getUserMeetingParticipation(userId: Long): MeetingParticipationResponse {
val userTeams = userTeamDao.findAllByUserIdWithPaymentStatus(userId)

return MeetingParticipationResponse(
Expand All @@ -54,12 +54,16 @@ class MatchingService(
)
}

fun getMatchPartnerInformation(userId: Long, matchId: Long): MeetingTeamInformationGetResponse {
fun getMatchedPartnerInformation(
userId: Long,
matchId: Long
): MeetingTeamInformationGetResponse {
val match = matchedDao.findById(matchId) ?: throw MatchNotFoundException()

val userTeam =
userTeamDao.findUserWithMeetingTeamByMatchId(userId, matchId)
?: throw UnauthorizedMatchAccessException()

val match = matchedDao.findById(matchId) ?: throw MatchNotFoundException()
val partnerTeam = getPartnerTeam(userTeam.team.gender, match)

// 매칭된 상대의 정보를 조회
Expand Down

0 comments on commit e8d2548

Please sign in to comment.