Skip to content

Commit

Permalink
Merge pull request #208 from swm-nodriversomabus/BUS-209-MVP1-bugfix
Browse files Browse the repository at this point in the history
feat(BE): 개별 사용자 ID 조회/ID로 사용자 조회 BUS-209-MVP1-bugfix
  • Loading branch information
Lemonade255 authored Nov 14, 2023
2 parents 772d300 + 72b95c9 commit c8f1e8b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -46,4 +45,4 @@ public interface SocialMapper {
@Mapping(target = "appleId", constant = "''")
@Mapping(target = "googleId", constant = "''")
SocialEntity toEntityNaver(AddSocialDto addSocialDto);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -103,6 +104,21 @@ public List<FindUserDto> 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
Expand All @@ -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
Expand Down

0 comments on commit c8f1e8b

Please sign in to comment.