Skip to content

Commit

Permalink
Merge pull request #78 from FX-BAOBAB/feat/userInfo
Browse files Browse the repository at this point in the history
SB-316 (feat) : ์œ ์ € ๊ณ ์œ  ์•„์ด๋””๋กœ ํšŒ์› ์ •๋ณด ์กฐํšŒ
  • Loading branch information
shinywoon authored Sep 11, 2024
2 parents 93d9dd0 + 0ee2119 commit f1b759d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions users/src/main/java/users/business/UsersBusiness.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ public UserResponse getUserInformation(String email) {
return usersConverter.toResponse(userEntity);
}

public UserResponse getUserInformation(Long userId) {
UserEntity userEntity = usersService.getUserByUserIdWithThrow(userId);
return usersConverter.toResponse(userEntity);
}

public MessageResponse unregister(String email) {
usersService.unregister(email);
return MessageResponse.builder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.Errors;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
Expand All @@ -14,6 +16,7 @@
import users.controller.model.duplicaiton.DuplicationNameRequest;
import users.controller.model.duplicaiton.DuplicationResponse;
import users.controller.model.login.UserLoginRequest;
import users.controller.model.login.UserResponse;
import users.controller.model.register.UsersRegisterRequest;
import users.controller.model.register.UsersRegisteredResponse;
import users.security.jwt.model.TokenResponse;
Expand Down Expand Up @@ -62,6 +65,11 @@ public Api<DuplicationResponse> duplicationNameCheck(
return Api.OK(response);
}


@GetMapping("/{userId}")
@Operation(summary = "[์‚ฌ์šฉ์ž ๊ณ ์œ  ์•„์ด๋””๋กœ ์‚ฌ์šฉ์ž ์ •๋ณด ์กฐํšŒ]")
public Api<UserResponse> getUserInfo(@PathVariable Long userId){
UserResponse response = usersBusiness.getUserInformation(userId);
return Api.OK(response);
}

}
4 changes: 4 additions & 0 deletions users/src/main/java/users/service/UsersService.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,8 @@ public void unregister(String email) {
}

}

public UserEntity getUserByUserIdWithThrow(Long userId) {
return usersRepository.findFirstByIdAndStatusOrderByIdDesc(userId,UserStatus.REGISTERED).orElseThrow(() -> new UserNotFoundException(UserErrorCode.USER_NOT_FOUND));
}
}

0 comments on commit f1b759d

Please sign in to comment.