Skip to content

Commit

Permalink
닉네임 수정 API fix
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomeo184 committed Dec 12, 2023
1 parent fea8df5 commit fcf4939
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/main/java/com/offer/member/MemberController.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import com.offer.common.response.ApiResponse;
import com.offer.common.response.ResponseMessage;
import com.offer.member.request.MemberUpdateRequest;
import com.offer.member.request.NicknameQueryRequest;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
Expand All @@ -19,6 +20,7 @@
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -32,8 +34,8 @@ public class MemberController {

@Operation(summary = "닉네임 중복 조회")
@PostMapping("/nickname-duplicate")
public ResponseEntity<ApiResponse<Map<String, Boolean>>> getNicknameDuplication(String nickname) {
boolean exists = memberService.hasNickname(nickname);
public ResponseEntity<ApiResponse<Map<String, Boolean>>> getNicknameDuplication(@RequestBody NicknameQueryRequest request) {
boolean exists = memberService.hasNickname(request.getNickname());
HashMap<String, Boolean> result = new HashMap<>();
result.put("duplicate", exists);
return ResponseEntity.ok(
Expand Down Expand Up @@ -63,7 +65,7 @@ public ResponseEntity<ApiResponse<MemberProfileResponse>> getMember(@PathVariabl
@PutMapping("/member/{memberId}")
public ResponseEntity<ApiResponse<Long>> updateMember(
@Schema(hidden = true) @AuthenticationPrincipal LoginMember loginMember,
@PathVariable Long memberId, MemberUpdateRequest request) {
@PathVariable Long memberId, @RequestBody MemberUpdateRequest request) {
log.info("getMember = {}", loginMember);
if (loginMember.getId() == null) {
throw new IllegalArgumentException("잘못된 토큰");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/offer/member/MemberService.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Long updateMember(Long memberId, MemberUpdateRequest request) {
if (StringUtils.hasText(profileImageUrl)) {
member.changeProfileImageUrl(profileImageUrl);
}
if (StringUtils.hasText(nickname)) {
if (!StringUtils.hasText(nickname)) {
throw new IllegalArgumentException("닉네임이 비어있음");
}
member.changeNickname(nickname);
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/offer/member/request/NicknameQueryRequest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.offer.member.request;

import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
@NoArgsConstructor
public class NicknameQueryRequest {

private String nickname;
}

0 comments on commit fcf4939

Please sign in to comment.