Skip to content

Commit 8f5df23

Browse files
committed
#193 [refactor] 챌린지 참여하기, 초대코드 일치 여부 controller 수정
1 parent 428bad7 commit 8f5df23

File tree

2 files changed

+24
-20
lines changed

2 files changed

+24
-20
lines changed

src/main/kotlin/com/photi/server/api/controller/challenge/ChallengeController.kt

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -450,35 +450,40 @@ class ChallengeController(
450450
return ResponseEntity.ok(response)
451451
}
452452

453-
@PostMapping("/{challengeId}/join/public")
454-
@Operation(summary = "공개 챌린지 참여하기", security = [SecurityRequirement(name = ACCESS_TOKEN_KEY)])
453+
@PostMapping("/{challengeId}/join")
454+
@Operation(
455+
summary = "챌린지 참여하기",
456+
security = [SecurityRequirement(name = ACCESS_TOKEN_KEY)],
457+
description = "건너뛰기 시 { \"goal\": \"\" } 넣어주시면 됩니다.",
458+
)
455459
@ApiResponse(responseCode = "200")
456460
@ApiErrorResponses([TOKEN_UNAUTHENTICATED, TOKEN_UNAUTHORIZED, USER_NOT_FOUND, CHALLENGE_NOT_FOUND, EXISTING_CHALLENGE_MEMBER, CHALLENGE_LIMIT_EXCEED])
457-
fun joinPublicChallenge(
461+
fun joinChallenge(
458462
principal: Principal,
459463
@PathVariable @Parameter(description = "챌린지 id", example = "1") challengeId: Long,
464+
@RequestBody @Valid request: JoinChallengeRequest,
460465
): ResponseEntity<StringSuccessResponse> {
461-
challengeService.joinPublicChallenge(UserUtility.getUserId(principal), challengeId)
466+
challengeService.joinChallenge(
467+
UserUtility.getUserId(principal),
468+
challengeId,
469+
request.toServiceDto(),
470+
)
462471

463-
return ResponseEntity.ok(StringSuccessResponse("공개 챌린지 참여하기가 완료되었습니다."))
472+
return ResponseEntity.ok(StringSuccessResponse("챌린지 참여하기가 완료되었습니다."))
464473
}
465474

466-
@PostMapping("/{challengeId}/join/private")
467-
@Operation(summary = "비공개 챌린지 참여하기", security = [SecurityRequirement(name = ACCESS_TOKEN_KEY)])
475+
@GetMapping("/{challengeId}/invitation-code-match")
476+
@Operation(summary = "챌린지 초대코드 일치 여부 조회")
468477
@ApiResponse(responseCode = "200")
469-
@ApiErrorResponses([TOKEN_UNAUTHENTICATED, TOKEN_UNAUTHORIZED, USER_NOT_FOUND, CHALLENGE_NOT_FOUND, EXISTING_CHALLENGE_MEMBER, CHALLENGE_INVITATION_CODE_INVALID, CHALLENGE_LIMIT_EXCEED])
470-
fun joinPrivateChallenge(
471-
principal: Principal,
478+
@ApiErrorResponses([CHALLENGE_NOT_FOUND])
479+
fun findChallengeInvitationCodeIsMatch(
472480
@PathVariable @Parameter(description = "챌린지 id", example = "1") challengeId: Long,
473-
@RequestBody @Valid request: JoinPrivateChallengeRequest,
474-
): ResponseEntity<StringSuccessResponse> {
475-
challengeService.joinPrivateChallenge(
476-
UserUtility.getUserId(principal),
477-
challengeId,
478-
request.toServiceDto()
479-
)
481+
@RequestBody @Valid request: FindChallengeInvitationCodeIsMatchRequest,
482+
): ResponseEntity<FindChallengeInvitationCodeIsMatchResponse> {
483+
val isMatch = challengeService.isMatchInvitationCode(challengeId, request.toServiceDto())
484+
val response = FindChallengeInvitationCodeIsMatchResponse.of(isMatch)
480485

481-
return ResponseEntity.ok(StringSuccessResponse("비공개 챌린지 참여하기가 완료되었습니다."))
486+
return ResponseEntity.ok(response)
482487
}
483488

484489
@PostMapping("/{challengeId}/feeds/{feedId}/like")

src/main/kotlin/com/photi/server/config/SecurityConfig.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ class SecurityConfig(
4747
"/api/challenges/{challengeId}/invitation-code",
4848
"/api/challenges/{challengeId}/challenge-members/goal",
4949
"/api/challenges/{challengeId}/challenge-members",
50-
"/api/challenges/{challengeId}/join/public",
51-
"/api/challenges/{challengeId}/join/private",
50+
"/api/challenges/{challengeId}/join",
5251
"/api/challenges/{challengeId}/feeds",
5352
"/api/challenges/{challengeId}/feeds/{feedId}",
5453
"/api/challenges/{challengeId}/feeds/{feedId}/like",

0 commit comments

Comments
 (0)