diff --git a/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java b/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java index 1ffc5b8..3e815e9 100644 --- a/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java +++ b/src/main/java/com/example/api/chat/adapter/in/rest/ChatController.java @@ -42,7 +42,7 @@ public class ChatController { * @param message (메시지) */ @Operation(summary = "Send message", description = "채팅방에 메시지를 보낸다.") - @MessageMapping(value = "/chat/{roomId}") + @MessageMapping("/chat/{roomId}") public void sendMessage(@DestinationVariable String roomId, @Header("userId") UUID userId, AddChatDto message) { message.setSenderId(userId); sendChatUsecase.send(roomId, message); @@ -57,7 +57,7 @@ public void sendMessage(@DestinationVariable String roomId, @Header("userId") UU @PostMapping("/chat/image") public String upload(@RequestBody MultipartFile file) { if (file == null) { - log.error("ChatController::sendMessage: image is not found"); + log.error("ChatController::upload: image is not found"); throw new CustomException(ErrorCodeEnum.IMAGE_NOT_FOUND); } return fileUploadUsecase.upload(file); diff --git a/src/main/java/com/example/api/social/adapter/out/persistence/SocialMapper.java b/src/main/java/com/example/api/social/adapter/out/persistence/SocialMapper.java index 63c98d0..c09707f 100644 --- a/src/main/java/com/example/api/social/adapter/out/persistence/SocialMapper.java +++ b/src/main/java/com/example/api/social/adapter/out/persistence/SocialMapper.java @@ -1,6 +1,5 @@ package com.example.api.social.adapter.out.persistence; - import com.example.api.social.dto.AddSocialDto; import org.mapstruct.InjectionStrategy; import org.mapstruct.Mapper; @@ -46,4 +45,4 @@ public interface SocialMapper { @Mapping(target = "appleId", constant = "''") @Mapping(target = "googleId", constant = "''") SocialEntity toEntityNaver(AddSocialDto addSocialDto); -} +} \ No newline at end of file diff --git a/src/main/java/com/example/api/user/adapter/in/rest/UserController.java b/src/main/java/com/example/api/user/adapter/in/rest/UserController.java index f0eb41f..a4166a9 100644 --- a/src/main/java/com/example/api/user/adapter/in/rest/UserController.java +++ b/src/main/java/com/example/api/user/adapter/in/rest/UserController.java @@ -24,6 +24,7 @@ import org.springframework.core.io.InputStreamResource; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.messaging.handler.annotation.DestinationVariable; import org.springframework.validation.BindingResult; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.WebDataBinder; @@ -103,6 +104,21 @@ public List getAll() { return findUserUsecase.getAll(); } + /** + * 로그인한 사용자 ID 조회 + * @return user ID + */ + @Operation(summary = "Get userId", description = "사용자 ID를 조회한다.") + @GetMapping("/user/id") + public UUID getUserId() { + SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); + if (securityUser == null) { + log.error("UserController::getUserId: Login is needed"); + throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); + } + return securityUser.getUserId(); + } + /** * 개별 사용자 조회 * @return User data @@ -118,6 +134,21 @@ public FindUserDto getUser() { return findUserUsecase.getUser(securityUser.getUserId()); } + /** + * ID로 사용자 조회 + * @return User data + */ + @Operation(summary = "Get user by userId", description = "ID가 userId인 사용자를 조회한다.") + @GetMapping("/user/{userId}") + public FindUserDto getUserByUserId(@PathVariable UUID userId) { + SecurityUser securityUser = AuthenticationUtils.getCurrentUserAuthentication(); + if (securityUser == null) { + log.error("UserController::getUserByUserId: Login is needed"); + throw new CustomException(ErrorCodeEnum.LOGIN_IS_NOT_DONE); + } + return findUserUsecase.getUser(userId); + } + /** * ID가 userId인 사용자의 추천 매칭 목록 조회 * @return Recommended matching list