From 9ca16ad60ad6d4fa2f46928ab4d43bace88919e7 Mon Sep 17 00:00:00 2001 From: GiJungPark Date: Sun, 14 Dec 2025 11:38:22 +0900 Subject: [PATCH 1/3] =?UTF-8?q?[REFACTOR]=20=EA=B8=B0=EC=A1=B4=20=EC=95=84?= =?UTF-8?q?=EB=B0=94=ED=83=80=20=EB=AA=A9=EB=A1=9D=20=EC=A1=B0=ED=9A=8C?= =?UTF-8?q?=EC=8B=9C,=20=EC=8B=A0=EA=B7=9C=20=EC=95=84=EB=B0=94=ED=83=80?= =?UTF-8?q?=EB=8A=94=20=EC=A1=B0=ED=9A=8C=EB=90=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/org/websoso/WSSServer/service/AvatarService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/websoso/WSSServer/service/AvatarService.java b/src/main/java/org/websoso/WSSServer/service/AvatarService.java index e0b80d64..38c48810 100644 --- a/src/main/java/org/websoso/WSSServer/service/AvatarService.java +++ b/src/main/java/org/websoso/WSSServer/service/AvatarService.java @@ -50,7 +50,7 @@ public AvatarsGetResponse getAvatarList(User user) { Byte representativeAvatarId = user.getAvatarId(); List avatars = avatarRepository.findAll(); List avatarGetResponses = avatars.stream() - .filter(avatar -> avatar.getAvatarId() >= 0) + .filter(avatar -> 0 <= avatar.getAvatarId() && avatar.getAvatarId() <= 3) .map(avatar -> { List avatarLines = avatar.getAvatarLines(); return AvatarGetResponse.of(avatar, getRandomAvatarLine(avatarLines), representativeAvatarId); From 292adac9f404e838a7c9b8f077940255c0f4cefc Mon Sep 17 00:00:00 2001 From: GiJungPark Date: Sun, 14 Dec 2025 12:23:00 +0900 Subject: [PATCH 2/3] =?UTF-8?q?[REFACTOR]=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EC=8B=A0=EA=B7=9C=20API?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=ED=95=98=EC=9C=84=20?= =?UTF-8?q?=ED=98=B8=ED=99=98=EC=84=B1=20=EB=B3=B4=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 구버전 프로필 업데이트 API 요청 시, ID 매핑을 통해서 하위 호환성을 보장하도록 수정 --- .../WSSServer/controller/UserController.java | 12 ++++++++++ .../dto/user/UpdateMyProfileRequest.java | 14 +++++++++++ .../websoso/WSSServer/user/domain/User.java | 17 +++++++++++++- .../WSSServer/user/service/UserService.java | 23 ++++++++++++++++++- 4 files changed, 64 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/websoso/WSSServer/controller/UserController.java b/src/main/java/org/websoso/WSSServer/controller/UserController.java index 4bc386ba..dafd9315 100644 --- a/src/main/java/org/websoso/WSSServer/controller/UserController.java +++ b/src/main/java/org/websoso/WSSServer/controller/UserController.java @@ -114,6 +114,7 @@ public ResponseEntity getMyProfileInfo(@AuthenticationPrincip .body(userService.getMyProfileInfo(user)); } + @Deprecated @PatchMapping("/my-profile") @PreAuthorize("isAuthenticated()") public ResponseEntity updateMyProfileInfo(@AuthenticationPrincipal User user, @@ -124,6 +125,17 @@ public ResponseEntity updateMyProfileInfo(@AuthenticationPrincipal User us .build(); } + @PatchMapping("/profile") + @PreAuthorize("isAuthenticated()") + @Deprecated + public ResponseEntity updateProfileInfo(@AuthenticationPrincipal User user, + @RequestBody @Valid UpdateMyProfileRequest updateMyProfileRequest) { + userService.updateProfileInfo(user, updateMyProfileRequest); + return ResponseEntity + .status(NO_CONTENT) + .build(); + } + @GetMapping("/profile-status") @PreAuthorize("isAuthenticated()") public ResponseEntity getProfileStatus(@AuthenticationPrincipal User user) { diff --git a/src/main/java/org/websoso/WSSServer/dto/user/UpdateMyProfileRequest.java b/src/main/java/org/websoso/WSSServer/dto/user/UpdateMyProfileRequest.java index 33a59eac..ca065d7e 100644 --- a/src/main/java/org/websoso/WSSServer/dto/user/UpdateMyProfileRequest.java +++ b/src/main/java/org/websoso/WSSServer/dto/user/UpdateMyProfileRequest.java @@ -17,4 +17,18 @@ public record UpdateMyProfileRequest( @NotNull(message = "선호 장르는 null일 수 없습니다.") List genrePreferences ) { + @Deprecated + public Long getMappedAvatarId() { + if (this.avatarId == null) { + return null; + } + + return switch (this.avatarId.intValue()) { + case 1 -> 1L; + case 2 -> 4L; + case 3 -> 5L; + + default -> null; + }; + } } diff --git a/src/main/java/org/websoso/WSSServer/user/domain/User.java b/src/main/java/org/websoso/WSSServer/user/domain/User.java index 2a5ac0fe..d5e63e2b 100644 --- a/src/main/java/org/websoso/WSSServer/user/domain/User.java +++ b/src/main/java/org/websoso/WSSServer/user/domain/User.java @@ -122,9 +122,12 @@ public void updateProfileStatus(Boolean profileStatus) { this.isProfilePublic = profileStatus; } + // TODO: DTO에 의존적인 DDD 로직 (기중) + @Deprecated public void updateUserProfile(UpdateMyProfileRequest updateMyProfileRequest) { if (updateMyProfileRequest.avatarId() != null) { - this.avatarProfileId = updateMyProfileRequest.avatarId(); + this.avatarId = updateMyProfileRequest.avatarId().byteValue(); + this.avatarProfileId = updateMyProfileRequest.getMappedAvatarId(); } if (updateMyProfileRequest.nickname() != null) { this.nickname = updateMyProfileRequest.nickname(); @@ -134,6 +137,18 @@ public void updateUserProfile(UpdateMyProfileRequest updateMyProfileRequest) { } } + public void updateUserProfile(Long avatarProfileId, String nickname, String intro) { + if (avatarProfileId != null) { + this.avatarProfileId = avatarProfileId; + } + if (nickname != null) { + this.nickname = nickname; + } + if (intro != null) { + this.intro = intro; + } + } + public void updateUserInfo(RegisterUserInfoRequest registerUserInfoRequest) { this.nickname = registerUserInfoRequest.nickname(); this.gender = Gender.valueOf(registerUserInfoRequest.gender()); diff --git a/src/main/java/org/websoso/WSSServer/user/service/UserService.java b/src/main/java/org/websoso/WSSServer/user/service/UserService.java index 3debea36..569ab429 100644 --- a/src/main/java/org/websoso/WSSServer/user/service/UserService.java +++ b/src/main/java/org/websoso/WSSServer/user/service/UserService.java @@ -109,8 +109,9 @@ public MyProfileResponse getMyProfileInfo(User user) { } // TODO: 멱등성을 보장하는데, Exception이 발생하는게 맞나? (기중) + @Deprecated public void updateMyProfileInfo(User user, UpdateMyProfileRequest updateMyProfileRequest) { - checkIfAlreadySetOrThrow(user.getAvatarProfileId(), updateMyProfileRequest.avatarId(), + checkIfAlreadySetOrThrow(user.getAvatarId(), updateMyProfileRequest.avatarId(), ALREADY_SET_AVATAR, "avatarId with given is already set"); checkIfAlreadySetOrThrow(user.getNickname(), updateMyProfileRequest.nickname(), @@ -129,6 +130,26 @@ public void updateMyProfileInfo(User user, UpdateMyProfileRequest updateMyProfil user.updateUserProfile(updateMyProfileRequest); } + public void updateProfileInfo(User user, UpdateMyProfileRequest updateMyProfileRequest) { + checkIfAlreadySetOrThrow(user.getAvatarProfileId(), updateMyProfileRequest.avatarId(), + ALREADY_SET_AVATAR, "avatarId with given is already set"); + + checkIfAlreadySetOrThrow(user.getNickname(), updateMyProfileRequest.nickname(), + ALREADY_SET_NICKNAME, "nickname with given is already set"); + checkNicknameIfAlreadyExist(updateMyProfileRequest.nickname()); + + checkIfAlreadySetOrThrow(user.getIntro(), updateMyProfileRequest.intro(), + ALREADY_SET_INTRO, "intro with given is already set"); + + genrePreferenceRepository.deleteAllByUser(user); + + List newPreferGenres = createGenrePreferences(user, updateMyProfileRequest.genrePreferences()); + genrePreferenceRepository.saveAll(newPreferGenres); + + user.updateUserProfile(updateMyProfileRequest.avatarId(), updateMyProfileRequest.nickname(), + updateMyProfileRequest.intro()); + } + public void registerUserInfo(User user, RegisterUserInfoRequest registerUserInfoRequest) { checkNicknameIfAlreadyExist(registerUserInfoRequest.nickname()); user.updateUserInfo(registerUserInfoRequest); From 21b12ba624831efb8b0099de8368e29094a92ecf Mon Sep 17 00:00:00 2001 From: GiJungPark Date: Sun, 14 Dec 2025 12:25:49 +0900 Subject: [PATCH 3/3] =?UTF-8?q?[REFACTOR]=20URL=EB=AA=85=20=ED=86=B5?= =?UTF-8?q?=EC=9D=BC=EC=9D=84=20=EC=9C=84=ED=95=9C=20GET=20/profile=20?= =?UTF-8?q?=EC=97=94=EB=93=9C=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - GET /my-profile과 동일한 결과값을 반환함 --- .../websoso/WSSServer/controller/UserController.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/main/java/org/websoso/WSSServer/controller/UserController.java b/src/main/java/org/websoso/WSSServer/controller/UserController.java index dafd9315..a2371d34 100644 --- a/src/main/java/org/websoso/WSSServer/controller/UserController.java +++ b/src/main/java/org/websoso/WSSServer/controller/UserController.java @@ -106,6 +106,7 @@ public ResponseEntity getProfileInfo(@AuthenticationPrincipa .body(userService.getProfileInfo(user, userId)); } + @Deprecated @GetMapping("/my-profile") @PreAuthorize("isAuthenticated()") public ResponseEntity getMyProfileInfo(@AuthenticationPrincipal User user) { @@ -114,6 +115,15 @@ public ResponseEntity getMyProfileInfo(@AuthenticationPrincip .body(userService.getMyProfileInfo(user)); } + @GetMapping("/profile") + @PreAuthorize("isAuthenticated()") + public ResponseEntity getProfileInfo(@AuthenticationPrincipal User user) { + return ResponseEntity + .status(OK) + .body(userService.getMyProfileInfo(user)); + } + + @Deprecated @PatchMapping("/my-profile") @PreAuthorize("isAuthenticated()")