Skip to content

Commit

Permalink
feat: 멤버 닉네임 변경 API 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
uwoobeat committed Jan 30, 2024
1 parent e18e303 commit 30c2b6d
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.depromeet.domain.auth.dto.request.UsernameCheckRequest;
import com.depromeet.domain.member.application.MemberService;
import com.depromeet.domain.member.dto.request.NicknameCheckRequest;
import com.depromeet.domain.member.dto.request.NicknameUpdateRequest;
import com.depromeet.domain.member.dto.response.MemberFindOneResponse;
import com.depromeet.domain.member.dto.response.MemberSearchResponse;
import com.depromeet.domain.member.dto.response.MemberSocialInfoResponse;
Expand Down Expand Up @@ -70,4 +71,12 @@ public ResponseEntity<MemberSocialInfoResponse> memberSocialInfoFind() {
MemberSocialInfoResponse response = memberService.findMemberSocialInfo();
return ResponseEntity.ok(response);
}

@Operation(summary = "회원 닉네임 변경", description = "회원 닉네임을 변경합니다.")
@PutMapping("/me/nickname")
public ResponseEntity<Void> memberNicknameUpdate(
@Valid @RequestBody NicknameUpdateRequest reqest) {
memberService.updateMemberNickname(reqest);
return ResponseEntity.ok().build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@ private void validateSocialInfoNotNull(Member member) {
}
}

public void updateMemberNickname(NicknameUpdateRequest reqest) {
final Member currentMember = memberUtil.getCurrentMember();
validateNicknameNotDuplicate(reqest.nickname());
currentMember.updateNickname(reqest.nickname());
}

private ImageFileExtension getImageFileExtension(Profile profile) {
// TODO: 이미지 확장자 정보 같이 넘겨주는 작업 추가 (24.01.26)
// 이미지 업로드와 닉네임 변경 분리 후 제거 예정
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/depromeet/domain/member/domain/Member.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,8 @@ public void withdrawal() {
}
this.status = MemberStatus.DELETED;
}

public void updateNickname(String nickname) {
this.profile = Profile.createProfile(nickname, this.profile.getProfileImageUrl());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.depromeet.domain.member.dto.request;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;

public record NicknameUpdateRequest(
@NotNull(message = "닉네임은 비워둘 수 없습니다.")
@Schema(description = "회원 닉네임", defaultValue = "nickname")
String nickname) {}

0 comments on commit 30c2b6d

Please sign in to comment.