From 4bee3d442b7984d23d8245647d068ba74852127b Mon Sep 17 00:00:00 2001 From: minju Date: Thu, 13 Nov 2025 14:46:26 +0900 Subject: [PATCH 1/8] =?UTF-8?q?docs:=20=EC=B9=9C=EA=B5=AC=20=EB=94=B0?= =?UTF-8?q?=EB=9D=BC=EA=B0=80=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20Swagger=20?= =?UTF-8?q?=EB=AA=85=EC=84=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Gotcha/domain/friend/api/FriendApi.java | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/gotcha/src/main/java/Gotcha/domain/friend/api/FriendApi.java b/gotcha/src/main/java/Gotcha/domain/friend/api/FriendApi.java index 2070dc6e..1e0ff6b6 100644 --- a/gotcha/src/main/java/Gotcha/domain/friend/api/FriendApi.java +++ b/gotcha/src/main/java/Gotcha/domain/friend/api/FriendApi.java @@ -1,5 +1,6 @@ package Gotcha.domain.friend.api; +import Gotcha.domain.friend.dto.FriendFollowingReq; import Gotcha.domain.friend.dto.FriendReq; import gotcha_domain.auth.SecurityUserDetails; import io.swagger.v3.oas.annotations.Operation; @@ -23,7 +24,7 @@ public interface FriendApi { @ApiResponse(responseCode = "200", description = "친구 목록 조회 성공", content = @Content(mediaType = "application/json", examples = { @ExampleObject(value = """ - + """) })) }) @@ -50,7 +51,7 @@ public interface FriendApi { })) }) ResponseEntity searchUser(@AuthenticationPrincipal SecurityUserDetails userDetails, - @RequestParam(value = "keyword") String keyword); + @RequestParam(value = "keyword") String keyword); @Operation(summary = "친구 신청 목록 조회", description = "친구 신청 목록 조회 API") @ApiResponses({ @@ -200,7 +201,7 @@ ResponseEntity rejectFriend(@PathVariable(value = "id") Long friendRequestId, @ApiResponse(responseCode = "204", description = "친구 삭제 성공", content = @Content(mediaType = "application/json", examples = { @ExampleObject(value = """ - + """) })), @ApiResponse(responseCode = "400", description = "친구가 아닌 사용자", @@ -216,4 +217,38 @@ ResponseEntity rejectFriend(@PathVariable(value = "id") Long friendRequestId, }) ResponseEntity deleteFriend(@PathVariable(value = "uuid") String uuid, @AuthenticationPrincipal SecurityUserDetails userDetails); + + @Operation(summary = "친구 따라가기", description = "친구 따라가기 클릭 시, 해당 친구가 속한 ROOM_ID 반환 기능 API") + @ApiResponses({ + @ApiResponse(responseCode = "200", description = "친구가 속한 방 id 정상 반환", + content = @Content(mediaType = "application/json", examples = { + @ExampleObject(value = """ + { + "roomId": "1111" + } + """) + })), + @ApiResponse(responseCode = "403", description = "친구 관계가 아니라 따라가기 기능 불가.", + content = @Content(mediaType = "application/json", examples = { + @ExampleObject(value = """ + { + "code": "FRIEND-403-002", + "status": "FORBIDDEN", + "message": "친구 관계가 아닙니다. 친구 추가 후 다시 시도해주세요." + } + """) + })), + @ApiResponse(responseCode = "404", description = "친구가 방에 속해있지 않음.", + content = @Content(mediaType = "application/json", examples = { + @ExampleObject(value = """ + { + "code": "FRIEND-404-002", + "status": "NOT_FOUND, + "message": "친구가 방에 속해있지 않습니다." + } + """) + })) + }) + ResponseEntity followingFriend(@AuthenticationPrincipal SecurityUserDetails securityUserDetails, + @Valid @RequestBody FriendFollowingReq friendFollowingReq); } From c5119711c0aaf7a2726473458c610994fc636e66 Mon Sep 17 00:00:00 2001 From: minju Date: Thu, 13 Nov 2025 17:05:01 +0900 Subject: [PATCH 2/8] =?UTF-8?q?add=20:=20=EC=B9=9C=EA=B5=AC=20=EB=94=B0?= =?UTF-8?q?=EB=9D=BC=EA=B0=80=EA=B8=B0=20=EA=B8=B0=EB=8A=A5=20=EC=97=94?= =?UTF-8?q?=EB=93=9C=ED=8F=AC=EC=9D=B8=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/controller/FriendController.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gotcha/src/main/java/Gotcha/domain/friend/controller/FriendController.java b/gotcha/src/main/java/Gotcha/domain/friend/controller/FriendController.java index 82246206..c2a9dbd2 100644 --- a/gotcha/src/main/java/Gotcha/domain/friend/controller/FriendController.java +++ b/gotcha/src/main/java/Gotcha/domain/friend/controller/FriendController.java @@ -1,6 +1,7 @@ package Gotcha.domain.friend.controller; import Gotcha.domain.friend.api.FriendApi; +import Gotcha.domain.friend.dto.FriendFollowingReq; import Gotcha.domain.friend.dto.FriendReq; import Gotcha.domain.friend.service.FriendService; import gotcha_common.dto.SuccessRes; @@ -14,6 +15,7 @@ import org.springframework.web.bind.annotation.GetMapping; 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.RequestParam; @@ -22,7 +24,7 @@ @RestController @RequiredArgsConstructor @RequestMapping("/api/v1/friends") -public class FriendController implements FriendApi{ +public class FriendController implements FriendApi { private final FriendService friendService; @GetMapping() @@ -32,7 +34,7 @@ public ResponseEntity getFriends(@AuthenticationPrincipal SecurityUserDetails @GetMapping("/search") public ResponseEntity searchUser(@AuthenticationPrincipal SecurityUserDetails userDetails, - @RequestParam(value = "keyword") String keyword) { + @RequestParam(value = "keyword") String keyword) { return ResponseEntity.ok(friendService.searchUser(userDetails.getId(), keyword)); } @@ -68,4 +70,12 @@ public ResponseEntity deleteFriend(@PathVariable(value = "uuid") String frien friendService.deleteFriend(userDetails.getId(), friendUuid); return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); } + + @PutMapping("/follow") + public ResponseEntity followingFriend(@AuthenticationPrincipal SecurityUserDetails securityUserDetails, + @Valid @RequestBody FriendFollowingReq friendFollowingReq) { + return ResponseEntity.ok(friendService.followFriend(friendFollowingReq)); + } + + } From aafdcad1bd13115bdfd255ffd922018db79fea0e Mon Sep 17 00:00:00 2001 From: minju Date: Thu, 13 Nov 2025 17:06:37 +0900 Subject: [PATCH 3/8] =?UTF-8?q?feat:=20=EC=B9=9C=EA=B5=AC=20=EB=94=B0?= =?UTF-8?q?=EB=9D=BC=EA=B0=80=EA=B8=B0=20=EA=B4=80=EB=A0=A8=20=EC=97=90?= =?UTF-8?q?=EB=9F=AC=20enum=20=EC=B6=94=EA=B0=80=20style:=20error=20status?= =?UTF-8?q?=20=EC=BD=94=EB=93=9C=20=EC=98=A4=EB=A6=84=EC=B0=A8=EC=88=9C=20?= =?UTF-8?q?=EC=A0=95=EB=A0=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/friend/exception/FriendExceptionCode.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gotcha/src/main/java/Gotcha/domain/friend/exception/FriendExceptionCode.java b/gotcha/src/main/java/Gotcha/domain/friend/exception/FriendExceptionCode.java index c1710937..7b5d7ae7 100644 --- a/gotcha/src/main/java/Gotcha/domain/friend/exception/FriendExceptionCode.java +++ b/gotcha/src/main/java/Gotcha/domain/friend/exception/FriendExceptionCode.java @@ -5,14 +5,15 @@ import org.springframework.http.HttpStatus; @AllArgsConstructor -public enum FriendExceptionCode implements ExceptionCode { +public enum FriendExceptionCode implements ExceptionCode { SELF_REQUEST_NOT_ALLOWED(HttpStatus.BAD_REQUEST, "FRIEND-400-001", "자기 자신에게는 친구 요청을 보낼 수 없습니다."), NOT_FRIEND(HttpStatus.BAD_REQUEST, "FRIEND-400-002", "해당 사용자와는 친구가 아닙니다."), + INVALID_REQUEST_ACCESS(HttpStatus.FORBIDDEN, "FRIEND-403-001", "해당 친구 요청에 접근 권한이 없습니다."), + FRIENDSHIP_REQUIRED(HttpStatus.FORBIDDEN, "FRIEND-403-002", "친구 관계가 아닙니다. 친구 추가 후 다시 시도해주세요."), + FRIEND_REQUEST_NOT_FOUND(HttpStatus.NOT_FOUND, "FRIEND-404-001", "친구 요청을 찾을 수 없습니다."), + FRIEND_NOT_IN_ROOM(HttpStatus.NOT_FOUND, "FRIEND-404-002", "친구가 방에 속해있지 않습니다."), FRIEND_REQUEST_ALREADY_EXISTS(HttpStatus.CONFLICT, "FRIEND-409-001", "이미 친구 요청을 보낸 상태입니다."), - FRIEND_REQUEST_NOT_FOUND(HttpStatus.NOT_FOUND, "FIREND-404-001", "친구 요청을 찾을 수 없습니다."), - ALREADY_FRIENDS(HttpStatus.CONFLICT, "FRIEND-409-002", "이미 친구인 사용자입니다."), - INVALID_REQUEST_ACCESS(HttpStatus.FORBIDDEN,"FRIEND-403-001", "해당 친구 요청에 접근 권한이 없습니다."); - + ALREADY_FRIENDS(HttpStatus.CONFLICT, "FRIEND-409-002", "이미 친구인 사용자입니다."); private final HttpStatus status; private final String code; From a7097c5c605c84cd2a8c201ea6b3ed47dd40c767 Mon Sep 17 00:00:00 2001 From: minju Date: Thu, 13 Nov 2025 17:07:08 +0900 Subject: [PATCH 4/8] =?UTF-8?q?feat=20:=20=EC=9D=91=EB=8B=B5=20=EC=9A=94?= =?UTF-8?q?=EC=B2=AD=20=EC=8B=9C,=20=EC=9D=91=EB=8B=B5=20=EB=B0=98?= =?UTF-8?q?=ED=99=98=20=EC=8B=9C=20=EC=82=AC=EC=9A=A9=EB=90=A0=20dto=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Gotcha/domain/friend/dto/FriendFollowingReq.java | 11 +++++++++++ .../Gotcha/domain/friend/dto/FriendFollowingRes.java | 9 +++++++++ 2 files changed, 20 insertions(+) create mode 100644 gotcha/src/main/java/Gotcha/domain/friend/dto/FriendFollowingReq.java create mode 100644 gotcha/src/main/java/Gotcha/domain/friend/dto/FriendFollowingRes.java diff --git a/gotcha/src/main/java/Gotcha/domain/friend/dto/FriendFollowingReq.java b/gotcha/src/main/java/Gotcha/domain/friend/dto/FriendFollowingReq.java new file mode 100644 index 00000000..1c6b8aa6 --- /dev/null +++ b/gotcha/src/main/java/Gotcha/domain/friend/dto/FriendFollowingReq.java @@ -0,0 +1,11 @@ +package Gotcha.domain.friend.dto; + +import jakarta.validation.constraints.NotNull; + +public record FriendFollowingReq( + @NotNull(message = "따라갈 상대방 유저의 uuid는 필수 요소입니다.") + String followerUuid, + @NotNull(message = "따라가기를 클릭한 유저의 uuid는 필수 요소입니다.") + String followingUuid +) { +} diff --git a/gotcha/src/main/java/Gotcha/domain/friend/dto/FriendFollowingRes.java b/gotcha/src/main/java/Gotcha/domain/friend/dto/FriendFollowingRes.java new file mode 100644 index 00000000..d2da3aa7 --- /dev/null +++ b/gotcha/src/main/java/Gotcha/domain/friend/dto/FriendFollowingRes.java @@ -0,0 +1,9 @@ +package Gotcha.domain.friend.dto; + +public record FriendFollowingRes( + String roomId +) { + public static FriendFollowingRes from(String roomId){ + return new FriendFollowingRes(roomId); + } +} From 495a8cf8433de1521c19318d3d54137c2c973d0f Mon Sep 17 00:00:00 2001 From: minju Date: Thu, 13 Nov 2025 17:07:36 +0900 Subject: [PATCH 5/8] =?UTF-8?q?feat=20:=20=EC=B9=9C=EA=B5=AC=20=EB=94=B0?= =?UTF-8?q?=EB=9D=BC=EA=B0=80=EA=B8=B0=20=EB=A1=9C=EC=A7=81=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 --- .../domain/friend/service/FriendService.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/gotcha/src/main/java/Gotcha/domain/friend/service/FriendService.java b/gotcha/src/main/java/Gotcha/domain/friend/service/FriendService.java index 6109db3b..dcf9c44f 100644 --- a/gotcha/src/main/java/Gotcha/domain/friend/service/FriendService.java +++ b/gotcha/src/main/java/Gotcha/domain/friend/service/FriendService.java @@ -1,5 +1,7 @@ package Gotcha.domain.friend.service; +import Gotcha.domain.friend.dto.FriendFollowingReq; +import Gotcha.domain.friend.dto.FriendFollowingRes; import Gotcha.domain.friend.dto.FriendReq; import Gotcha.domain.friend.dto.FriendRequestRes; import Gotcha.domain.friend.dto.FriendRes; @@ -20,6 +22,7 @@ import socket_server.domain.friend.service.FriendSocketService; import java.util.List; +import socket_server.domain.room.service.RoomUserService; @Service @RequiredArgsConstructor @@ -29,6 +32,7 @@ public class FriendService { private final UserService userService; private final FriendSocketService friendSocketService; private final RedisUtil redisUtil; + private final RoomUserService roomUserService; private static final String FRIEND_CACHE_PREFIX = "user:"; @@ -169,4 +173,23 @@ public void deleteFriend(Long userId, String friendUuid) { friendSocketService.sendFriendAlert(user.getUuid(), friendUuid, user.getUuid(), FriendEventType.DELETE); } + + public FriendFollowingRes followFriend(FriendFollowingReq friendFollowingReq) { + String followerUuid = friendFollowingReq.followerUuid(); + String followingUuid = friendFollowingReq.followingUuid(); + boolean isFriend = redisUtil.isSetMember("user:" + followingUuid + ":friends", followerUuid); + + if(!isFriend) { + throw new CustomException(FriendExceptionCode.NOT_FRIEND); + } + + String friendRoomId = roomUserService.findRoomIdByUserUuid(followerUuid); + + if(friendRoomId==null) { + throw new CustomException(FriendExceptionCode.FRIEND_NOT_IN_ROOM); + } + + return FriendFollowingRes.from(friendRoomId); + } + } From b86bc13f1f8a706a6463eb7108b0aa4327ac2355 Mon Sep 17 00:00:00 2001 From: minju Date: Thu, 13 Nov 2025 20:55:46 +0900 Subject: [PATCH 6/8] =?UTF-8?q?fix:=20Proxy=20=EC=97=94=ED=8B=B0=ED=8B=B0?= =?UTF-8?q?=EC=97=90=EC=84=9C=20equals()=EA=B0=80=20=EC=98=A4=EB=8F=99?= =?UTF-8?q?=EC=9E=91=ED=95=98=EB=8A=94=20=EB=AC=B8=EC=A0=9C=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/gotcha_domain/user/User.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gotcha-domain/src/main/java/gotcha_domain/user/User.java b/gotcha-domain/src/main/java/gotcha_domain/user/User.java index fc9be831..fb2d61f1 100644 --- a/gotcha-domain/src/main/java/gotcha_domain/user/User.java +++ b/gotcha-domain/src/main/java/gotcha_domain/user/User.java @@ -121,7 +121,7 @@ public class User extends BaseTimeEntity { private Set bugReports = new HashSet<>(); @Builder - public User(Long id, String email, String password, String nickname, Role role, String uuid){ + public User(Long id, String email, String password, String nickname, Role role, String uuid) { this.id = id; this.email = email; this.password = password; @@ -139,16 +139,22 @@ public void updateChatSettings(ChatOption chatOption, PrivateChatOption privateC this.privateChatOption = privateChatOption; } + @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (!(o instanceof User)) { + return false; + } User user = (User) o; - return id != null && id.equals(user.id); + + return id != null && id.equals(user.getId()); } @Override public int hashCode() { return (id != null) ? id.hashCode() : 0; } -} \ No newline at end of file +} From 465c2b32ea53fbe430839cd7973a130c527011a4 Mon Sep 17 00:00:00 2001 From: minju Date: Thu, 13 Nov 2025 20:56:22 +0900 Subject: [PATCH 7/8] =?UTF-8?q?feat=20:=20=EC=B9=9C=EA=B5=AC=20=EB=94=B0?= =?UTF-8?q?=EB=9D=BC=EA=B0=80=EA=B8=B0=20=EB=A1=9C=EC=A7=81=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=97=85=EB=A1=9C=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/Gotcha/domain/friend/api/FriendApi.java | 10 +++++----- .../friend/controller/FriendController.java | 10 ++++------ .../domain/friend/dto/FriendFollowingReq.java | 11 ----------- .../domain/friend/service/FriendService.java | 15 +++++++-------- 4 files changed, 16 insertions(+), 30 deletions(-) delete mode 100644 gotcha/src/main/java/Gotcha/domain/friend/dto/FriendFollowingReq.java diff --git a/gotcha/src/main/java/Gotcha/domain/friend/api/FriendApi.java b/gotcha/src/main/java/Gotcha/domain/friend/api/FriendApi.java index 1e0ff6b6..d98d7e3d 100644 --- a/gotcha/src/main/java/Gotcha/domain/friend/api/FriendApi.java +++ b/gotcha/src/main/java/Gotcha/domain/friend/api/FriendApi.java @@ -1,6 +1,5 @@ package Gotcha.domain.friend.api; -import Gotcha.domain.friend.dto.FriendFollowingReq; import Gotcha.domain.friend.dto.FriendReq; import gotcha_domain.auth.SecurityUserDetails; import io.swagger.v3.oas.annotations.Operation; @@ -159,7 +158,8 @@ ResponseEntity requestFriend(@AuthenticationPrincipal SecurityUserDetails use })) }) ResponseEntity acceptFriend(@PathVariable(value = "id") Long friendRequestId, - @AuthenticationPrincipal SecurityUserDetails userDetails); + @AuthenticationPrincipal SecurityUserDetails userDetails) + throws NoSuchMethodException; @Operation(summary = "친구 요청 거절", description = "친구 요청 거절 API") @ApiResponses({ @@ -243,12 +243,12 @@ ResponseEntity deleteFriend(@PathVariable(value = "uuid") String uuid, @ExampleObject(value = """ { "code": "FRIEND-404-002", - "status": "NOT_FOUND, + "status": "NOT_FOUND", "message": "친구가 방에 속해있지 않습니다." } """) })) }) - ResponseEntity followingFriend(@AuthenticationPrincipal SecurityUserDetails securityUserDetails, - @Valid @RequestBody FriendFollowingReq friendFollowingReq); + ResponseEntity followingFriend(@PathVariable(value = "uuid") String friendUuid, + @AuthenticationPrincipal SecurityUserDetails securityUserDetails); } diff --git a/gotcha/src/main/java/Gotcha/domain/friend/controller/FriendController.java b/gotcha/src/main/java/Gotcha/domain/friend/controller/FriendController.java index c2a9dbd2..15f6f456 100644 --- a/gotcha/src/main/java/Gotcha/domain/friend/controller/FriendController.java +++ b/gotcha/src/main/java/Gotcha/domain/friend/controller/FriendController.java @@ -1,7 +1,6 @@ package Gotcha.domain.friend.controller; import Gotcha.domain.friend.api.FriendApi; -import Gotcha.domain.friend.dto.FriendFollowingReq; import Gotcha.domain.friend.dto.FriendReq; import Gotcha.domain.friend.service.FriendService; import gotcha_common.dto.SuccessRes; @@ -15,7 +14,6 @@ import org.springframework.web.bind.annotation.GetMapping; 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.RequestParam; @@ -71,10 +69,10 @@ public ResponseEntity deleteFriend(@PathVariable(value = "uuid") String frien return ResponseEntity.status(HttpStatus.NO_CONTENT).build(); } - @PutMapping("/follow") - public ResponseEntity followingFriend(@AuthenticationPrincipal SecurityUserDetails securityUserDetails, - @Valid @RequestBody FriendFollowingReq friendFollowingReq) { - return ResponseEntity.ok(friendService.followFriend(friendFollowingReq)); + @PostMapping("/follow/{uuid}") + public ResponseEntity followingFriend(@PathVariable(value = "uuid") String friendUuid, + @AuthenticationPrincipal SecurityUserDetails userDetails) { + return ResponseEntity.ok(friendService.followFriend(userDetails.getUuid(), friendUuid)); } diff --git a/gotcha/src/main/java/Gotcha/domain/friend/dto/FriendFollowingReq.java b/gotcha/src/main/java/Gotcha/domain/friend/dto/FriendFollowingReq.java deleted file mode 100644 index 1c6b8aa6..00000000 --- a/gotcha/src/main/java/Gotcha/domain/friend/dto/FriendFollowingReq.java +++ /dev/null @@ -1,11 +0,0 @@ -package Gotcha.domain.friend.dto; - -import jakarta.validation.constraints.NotNull; - -public record FriendFollowingReq( - @NotNull(message = "따라갈 상대방 유저의 uuid는 필수 요소입니다.") - String followerUuid, - @NotNull(message = "따라가기를 클릭한 유저의 uuid는 필수 요소입니다.") - String followingUuid -) { -} diff --git a/gotcha/src/main/java/Gotcha/domain/friend/service/FriendService.java b/gotcha/src/main/java/Gotcha/domain/friend/service/FriendService.java index dcf9c44f..fcd3bf2f 100644 --- a/gotcha/src/main/java/Gotcha/domain/friend/service/FriendService.java +++ b/gotcha/src/main/java/Gotcha/domain/friend/service/FriendService.java @@ -1,6 +1,5 @@ package Gotcha.domain.friend.service; -import Gotcha.domain.friend.dto.FriendFollowingReq; import Gotcha.domain.friend.dto.FriendFollowingRes; import Gotcha.domain.friend.dto.FriendReq; import Gotcha.domain.friend.dto.FriendRequestRes; @@ -14,6 +13,7 @@ import gotcha_domain.user.User; import gotcha_user.service.UserService; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import gotcha_common.util.RedisUtil; import org.springframework.transaction.annotation.Transactional; @@ -24,6 +24,7 @@ import java.util.List; import socket_server.domain.room.service.RoomUserService; +@Slf4j @Service @RequiredArgsConstructor public class FriendService { @@ -174,18 +175,16 @@ public void deleteFriend(Long userId, String friendUuid) { friendSocketService.sendFriendAlert(user.getUuid(), friendUuid, user.getUuid(), FriendEventType.DELETE); } - public FriendFollowingRes followFriend(FriendFollowingReq friendFollowingReq) { - String followerUuid = friendFollowingReq.followerUuid(); - String followingUuid = friendFollowingReq.followingUuid(); - boolean isFriend = redisUtil.isSetMember("user:" + followingUuid + ":friends", followerUuid); + public FriendFollowingRes followFriend(String userUuid, String friendUuid) { + boolean isFriend = redisUtil.isSetMember("user:" + userUuid + ":friends", friendUuid); - if(!isFriend) { + if (!isFriend) { throw new CustomException(FriendExceptionCode.NOT_FRIEND); } - String friendRoomId = roomUserService.findRoomIdByUserUuid(followerUuid); + String friendRoomId = roomUserService.findRoomIdByUserUuid(friendUuid); - if(friendRoomId==null) { + if (friendRoomId == null) { throw new CustomException(FriendExceptionCode.FRIEND_NOT_IN_ROOM); } From 89e09c8b4d0fd18dd01b8aa9c41e878823dbf8e5 Mon Sep 17 00:00:00 2001 From: minju Date: Thu, 13 Nov 2025 21:05:53 +0900 Subject: [PATCH 8/8] =?UTF-8?q?fix:=20=EC=B9=9C=EA=B5=AC=20=EA=B8=B0?= =?UTF-8?q?=EB=8A=A5=20=EC=97=90=EB=9F=AC=20=EC=BD=94=EB=93=9C=20=EC=A0=95?= =?UTF-8?q?=EC=9D=98=20=EB=B6=88=EC=9D=BC=EC=B9=98=20=EB=AC=B8=EC=A0=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/Gotcha/domain/friend/service/FriendService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gotcha/src/main/java/Gotcha/domain/friend/service/FriendService.java b/gotcha/src/main/java/Gotcha/domain/friend/service/FriendService.java index fcd3bf2f..661656ea 100644 --- a/gotcha/src/main/java/Gotcha/domain/friend/service/FriendService.java +++ b/gotcha/src/main/java/Gotcha/domain/friend/service/FriendService.java @@ -179,7 +179,7 @@ public FriendFollowingRes followFriend(String userUuid, String friendUuid) { boolean isFriend = redisUtil.isSetMember("user:" + userUuid + ":friends", friendUuid); if (!isFriend) { - throw new CustomException(FriendExceptionCode.NOT_FRIEND); + throw new CustomException(FriendExceptionCode.FRIENDSHIP_REQUIRED); } String friendRoomId = roomUserService.findRoomIdByUserUuid(friendUuid);