diff --git a/api/src/main/java/com/teamnexters/lazy/api/controller/MemberController.java b/api/src/main/java/com/teamnexters/lazy/api/controller/MemberController.java index 69e6b64..8cb9b0d 100644 --- a/api/src/main/java/com/teamnexters/lazy/api/controller/MemberController.java +++ b/api/src/main/java/com/teamnexters/lazy/api/controller/MemberController.java @@ -4,6 +4,7 @@ import com.teamnexters.lazy.api.exception.MemberNotFoundException; import com.teamnexters.lazy.api.service.MemberService; import com.teamnexters.lazy.common.domain.member.Member; +import com.teamnexters.lazy.common.error.ErrorResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.media.Content; @@ -34,7 +35,9 @@ public class MemberController { responses = { @ApiResponse( responseCode = "200", description = "[Ok] Get One Member Info", - content = @Content(schema = @Schema(implementation = MemberDto.AllMemberRes.class)))}) + content = @Content(schema = @Schema(implementation = MemberDto.AllMemberRes.class))), + @ApiResponse(responseCode = "414", description = "[Error] 존재하지 않는 회원입니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}) @GetMapping("/v1/member") public ResponseEntity getOneMember( @Parameter(hidden = true) Authentication authentication) { @@ -44,19 +47,20 @@ public ResponseEntity getOneMember( if (member == null) { throw new MemberNotFoundException("Auth"); } else { - log.info(">>> Member info : {}", member); + log.debug(">>> Member info : {}", member); return ResponseEntity.ok().body(member); } } - @Operation(summary = "✅ 닉네임 수정 API", description = "회원의 닉네임을 수정해요.", security = @SecurityRequirement(name = "bearerAuth"), responses = { @ApiResponse( responseCode = "200", description = "[Ok] Update Member NickName", - content = @Content(schema = @Schema(implementation = MemberDto.MemberIndexRes.class)))}) + content = @Content(schema = @Schema(implementation = MemberDto.MemberIndexRes.class))), + @ApiResponse(responseCode = "411", description = "[Error] 이미 등록된 닉네임입니다.", + content = @Content(schema = @Schema(implementation = ErrorResponse.class)))}) @PutMapping("/v1/member") public ResponseEntity updateMemberNickName( @Parameter(hidden = true) Authentication authentication, @@ -68,4 +72,23 @@ public ResponseEntity updateMemberNickName( memberService.updateNickName(dto, memIdx); return ResponseEntity.ok().body(memIdx); } -} + + @Operation(summary = "✅ 닉네임 중복체크 API", + description = "닉네임이 중복됐는지 검사해요.(중복 : true)", + security = @SecurityRequirement(name = "bearerAuth"), + responses = { + @ApiResponse( + responseCode = "200", description = "[Ok] Check Member NickName", + content = @Content(schema = @Schema(implementation = Boolean.class)))}) + @GetMapping("/v1/member/{nickname}") + public ResponseEntity checkNickNameDuplication( + @Parameter(hidden = true) Authentication authentication, + @Parameter(description = "체크할 닉네임", required = true) @PathVariable(name="nickname") String nickName) { + Member member = (Member) authentication.getPrincipal(); + Long memIdx = member.getMemIdx(); + log.debug(">>> Check Member No [{}] NickName : {}", memIdx, nickName); + + return ResponseEntity.ok().body(memberService.isExistedNickName(nickName)); + } + +} \ No newline at end of file diff --git a/api/src/main/java/com/teamnexters/lazy/api/domain/MemberDto.java b/api/src/main/java/com/teamnexters/lazy/api/domain/MemberDto.java index 33931c3..e196667 100644 --- a/api/src/main/java/com/teamnexters/lazy/api/domain/MemberDto.java +++ b/api/src/main/java/com/teamnexters/lazy/api/domain/MemberDto.java @@ -24,6 +24,18 @@ public static class UpdateNickNameReq { private String nickName; } + /** + * 중복 체크할 닉네임 Dto + */ + @Getter + @NoArgsConstructor(access = AccessLevel.PROTECTED) + @AllArgsConstructor + @Schema(description = "Request to check duplication NickName") + public static class checkNickNameReq { + @Schema(description = "회원 닉네임", defaultValue = "체크할 닉네임") + private String nickName; + } + /** * 회원 데이터 Dto */ @@ -61,4 +73,5 @@ public static class MemberIndexRes { @Schema(description = "회원 번호", defaultValue = "2") private final Long memIdx; } + }