Skip to content

Commit 2e5c6db

Browse files
authored
[refactor] 프로필 수정 메서드를 Patch로 변경 #53 (#57)
* refactor: 프로필 수정 DTO에서 이메일 필드 제거 * refactor: ProfileService에서 이메일 관련 로직 제거 - `ProfileService`의 `updateProfile` 메서드에서 이메일 관련 업데이트 로직을 삭제 - 이는 프로필 수정 DTO(ProfileUpdateRequestDto)에서 이메일 필드를 제거한 변경사항에 맞춘 후속 조치 * refactor: ProfileController API 엔드포인트 및 HTTP 메서드 변경 - `ProfileController`의 기본 API 엔드포인트를 `/me/profile`에서 `/api/me/profile`로 변경 - 프로필 수정에 사용되던 **`PUT` 메서드를 제거하고,** 부분 업데이트에 더 적합한 `PATCH` 메서드를 도입
1 parent 5dfc70a commit 2e5c6db

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

src/main/java/com/back/domain/profile/controller/ProfileController.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import org.springframework.web.bind.annotation.*;
1212

1313
@RestController
14-
@RequestMapping("/me/profile")
14+
@RequestMapping("/api/me/profile")
1515
@RequiredArgsConstructor
1616
public class ProfileController {
1717

@@ -24,9 +24,14 @@ public RsData<ProfileResponseDto> getProfile(@AuthenticationPrincipal(expression
2424
return RsData.successOf(body); // code=200, message="success"
2525
}
2626

27-
@PutMapping
28-
public RsData<ProfileResponseDto> updateProfile(@AuthenticationPrincipal(expression = "id") Long userId, @Valid @RequestBody ProfileUpdateRequestDto profileUpdateRequestDto) {
29-
ProfileResponseDto body = profileService.updateProfile(userId, profileUpdateRequestDto);
30-
return RsData.successOf(body); // code=200
27+
// PUT 제거: PATCH 전용으로 운영
28+
29+
@PatchMapping
30+
public RsData<ProfileResponseDto> patchNickname(
31+
@AuthenticationPrincipal(expression = "id") Long userId,
32+
@Valid @RequestBody ProfileUpdateRequestDto request
33+
) {
34+
ProfileResponseDto body = profileService.updateProfile(userId, request);
35+
return RsData.successOf(body);
3136
}
3237
}
Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.back.domain.profile.dto;
22

3-
import jakarta.validation.constraints.Email;
43
import jakarta.validation.constraints.Size;
54
import lombok.Getter;
65
import lombok.Setter;
@@ -11,7 +10,4 @@ public class ProfileUpdateRequestDto {
1110

1211
@Size(min = 1, max = 10, message = "닉네임은 1~10자")
1312
private String nickname;
14-
15-
@Email(message = "이메일 형식이 아닙니다")
16-
private String email;
1713
}

src/main/java/com/back/domain/profile/service/ProfileService.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ public ProfileResponseDto updateProfile(Long id, ProfileUpdateRequestDto profile
5050
user.setNickname(nickname);
5151
}
5252

53-
if (profileUpdateRequestDto.getEmail() != null) {
54-
String email = profileUpdateRequestDto.getEmail().trim();
55-
user.setEmail(email.isEmpty() ? null : email);
56-
}
57-
5853
userRepository.save(user);
5954

6055
return getProfile(id);

0 commit comments

Comments
 (0)