diff --git a/src/main/java/shop/fevertime/backend/api/UserApiController.java b/src/main/java/shop/fevertime/backend/api/UserApiController.java index d9ef223..69b2159 100644 --- a/src/main/java/shop/fevertime/backend/api/UserApiController.java +++ b/src/main/java/shop/fevertime/backend/api/UserApiController.java @@ -87,4 +87,12 @@ public ResultResponseDto updateUsername(@ModelAttribute UserRequestDto requestDt public List getChallengesByUser(@AuthenticationPrincipal UserDetailsImpl userDetails) { return challengeHistoryService.getChallengesByUser(userDetails.getUser()); } + + /** + * 유저 카카오 아이디로 정보 조회 API + */ + @GetMapping("/user/{kakaoId}") + public UserResponseDto getChatUser(@PathVariable String kakaoId) { + return userService.getChatUser(kakaoId); + } } diff --git a/src/main/java/shop/fevertime/backend/dto/ChatMessageDto.java b/src/main/java/shop/fevertime/backend/dto/ChatMessageDto.java index 1b204d0..b3fab72 100644 --- a/src/main/java/shop/fevertime/backend/dto/ChatMessageDto.java +++ b/src/main/java/shop/fevertime/backend/dto/ChatMessageDto.java @@ -7,5 +7,6 @@ @Setter public class ChatMessageDto { private String roomId; + private String sender; private String message; } diff --git a/src/main/java/shop/fevertime/backend/dto/response/ChatRoomResponseDto.java b/src/main/java/shop/fevertime/backend/dto/response/ChatRoomResponseDto.java index 7751425..e0ba15d 100644 --- a/src/main/java/shop/fevertime/backend/dto/response/ChatRoomResponseDto.java +++ b/src/main/java/shop/fevertime/backend/dto/response/ChatRoomResponseDto.java @@ -14,11 +14,13 @@ public class ChatRoomResponseDto { private Long roomId; private String name; private String createdDate; + private String creator; public ChatRoomResponseDto(ChatRoom chatRoom) { this.roomId = chatRoom.getId(); this.name= chatRoom.getName(); - this.createdDate = chatRoom.getCreatedDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));; + this.createdDate = chatRoom.getCreatedDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")); + this.creator = chatRoom.getUser().getKakaoId(); } } diff --git a/src/main/java/shop/fevertime/backend/service/UserService.java b/src/main/java/shop/fevertime/backend/service/UserService.java index 39851d7..6b9e6ca 100644 --- a/src/main/java/shop/fevertime/backend/service/UserService.java +++ b/src/main/java/shop/fevertime/backend/service/UserService.java @@ -9,6 +9,7 @@ import shop.fevertime.backend.dto.response.FeedResponseDto; import shop.fevertime.backend.dto.response.UserChallengeResponseDto; +import shop.fevertime.backend.dto.response.UserResponseDto; import shop.fevertime.backend.exception.ApiRequestException; import shop.fevertime.backend.repository.ChallengeHistoryRepository; import shop.fevertime.backend.repository.ChallengeRepository; @@ -93,4 +94,14 @@ public void updateUsername(User user, UserRequestDto requestDto) { findUser.updateUsername(requestDto.getUsername()); } + + //카카오 아이디로 유저 정보 가져오기 + @Transactional + public UserResponseDto getChatUser(String kakaoId) { + User findUser = userRepository.findByKakaoId(kakaoId).orElseThrow( + () -> new ApiRequestException("해당 아이디가 존재하지 않습니다.") + ); + return new UserResponseDto(findUser); + } + }