From cd5646f02bb5a3977c1a0ecfb5ed22fea34671de Mon Sep 17 00:00:00 2001 From: namhyo01 Date: Wed, 22 Nov 2023 03:24:02 +0900 Subject: [PATCH] =?UTF-8?q?hotfix(BE):=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=EC=8B=9C=20=EC=83=9D=EA=B8=B0=EB=8A=94=20?= =?UTF-8?q?=EC=98=A4=EB=A5=98=20=EC=B2=B4=ED=81=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/in/rest/ChatRoomController.java | 10 ++++------ .../api/chatroom/dto/CreateChatRoomDto.java | 8 ++++++-- .../friend/adapter/in/rest/FriendController.java | 15 +++++++++++++++ .../com/example/api/friend/dto/FriendDto.java | 2 +- .../com/example/api/member/dto/AddMemberDto.java | 4 ++++ 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/example/api/chatroom/adapter/in/rest/ChatRoomController.java b/src/main/java/com/example/api/chatroom/adapter/in/rest/ChatRoomController.java index 82c0346..45d1cee 100644 --- a/src/main/java/com/example/api/chatroom/adapter/in/rest/ChatRoomController.java +++ b/src/main/java/com/example/api/chatroom/adapter/in/rest/ChatRoomController.java @@ -37,11 +37,14 @@ public class ChatRoomController { @Operation(summary = "Create chatroom", description = "새로운 채팅방을 생성한다.") @PostMapping("/chatroom") public UUID createChatroom(@RequestBody @Valid CreateChatRoomDto createChatRoomDto) { + SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); if (securityUser == null) { log.error("ChatRoomController::createChatroom: Login is needed"); throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); } + + createChatRoomDto.setMasterId(securityUser.getUserId()); ChatRoom chatRoom = createChatRoomUsecase.createRoom(createChatRoomDto); return chatRoom.getChatroomId(); } @@ -64,12 +67,7 @@ public List chatRoomList(@PageableDefault(sort = "createdAt", directio @Operation(summary = "Delete chatroom", description = "채팅방을 삭제한다.") @DeleteMapping("/chatroom/{chatRoomId}") - public void outChatRoom(@PathVariable UUID chatRoomId) { - SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); - if (securityUser == null) { - log.error("ChatRoomController::outChatroom: Login is needed"); - throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); - } + public void outChatRoom(@PathVariable UUID chatRoomId){ log.info("chatroom = {}", chatRoomId); } } \ No newline at end of file diff --git a/src/main/java/com/example/api/chatroom/dto/CreateChatRoomDto.java b/src/main/java/com/example/api/chatroom/dto/CreateChatRoomDto.java index f34b2b7..4d5ef24 100644 --- a/src/main/java/com/example/api/chatroom/dto/CreateChatRoomDto.java +++ b/src/main/java/com/example/api/chatroom/dto/CreateChatRoomDto.java @@ -3,16 +3,20 @@ import com.example.api.chatroom.type.ChatRoomEnum; import jakarta.validation.constraints.NotBlank; import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import java.util.UUID; @Data @Builder +@NoArgsConstructor +@AllArgsConstructor public class CreateChatRoomDto { - @NotNull - private UUID masterId; // TODO 추후 jwt에서 얻을 수 있어 삭제 가능 +// @NotNull + private UUID masterId; @NotBlank private String chatroomName; diff --git a/src/main/java/com/example/api/friend/adapter/in/rest/FriendController.java b/src/main/java/com/example/api/friend/adapter/in/rest/FriendController.java index ed98fc1..943b208 100644 --- a/src/main/java/com/example/api/friend/adapter/in/rest/FriendController.java +++ b/src/main/java/com/example/api/friend/adapter/in/rest/FriendController.java @@ -13,9 +13,11 @@ import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.List; +import java.util.UUID; @RestController @RequiredArgsConstructor @@ -71,4 +73,17 @@ public void deleteFriend(FriendDto friendDto) { } deleteFriendUsecase.deleteFriend(friendDto); } + + @Operation(summary = "check friend", description = "친구 여부 확인") + @GetMapping("/friend/{friendId}") + public ResponseEntity findFriend(@PathVariable UUID friendId){ + SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); + if (securityUser == null) { + log.error("FriendController::findFriend: Login is needed"); + throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); + } + + return ResponseEntity.ok("yes"); + + } } \ No newline at end of file diff --git a/src/main/java/com/example/api/friend/dto/FriendDto.java b/src/main/java/com/example/api/friend/dto/FriendDto.java index 4915eb1..b7fbfa4 100644 --- a/src/main/java/com/example/api/friend/dto/FriendDto.java +++ b/src/main/java/com/example/api/friend/dto/FriendDto.java @@ -12,7 +12,7 @@ @NoArgsConstructor @AllArgsConstructor public class FriendDto { - @NotNull +// @NotNull private UUID userId; @NotNull diff --git a/src/main/java/com/example/api/member/dto/AddMemberDto.java b/src/main/java/com/example/api/member/dto/AddMemberDto.java index 4907525..ecee369 100644 --- a/src/main/java/com/example/api/member/dto/AddMemberDto.java +++ b/src/main/java/com/example/api/member/dto/AddMemberDto.java @@ -1,14 +1,18 @@ package com.example.api.member.dto; import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import java.util.List; import java.util.UUID; @Data @Builder +@AllArgsConstructor +@NoArgsConstructor public class AddMemberDto { @NotNull private UUID chatroomId;