Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] 프로필 조회 API 구현 #40

Merged
merged 5 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.doorip.user.dto.request.UserReissueRequest;
import org.doorip.user.dto.request.UserSignInRequest;
import org.doorip.user.dto.request.UserSignUpRequest;
import org.doorip.user.dto.response.ProfileGetResponse;
import org.doorip.user.dto.response.UserResponse;
import org.doorip.user.service.UserService;
import org.springframework.http.ResponseEntity;
Expand Down Expand Up @@ -54,4 +55,10 @@ public ResponseEntity<ApiResponse<?>> reissue(@RequestHeader(AUTHORIZATION) fina
UserResponse response = userService.reissue(refreshtoken, request);
return ApiResponseUtil.success(SuccessMessage.OK, response);
}

@GetMapping("/profile")
public ResponseEntity<ApiResponse<?>> getProfile(@UserId final Long userId) {
final ProfileGetResponse response = userService.getProfile(userId);
return ApiResponseUtil.success(SuccessMessage.OK, response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.doorip.user.dto.response;

import org.doorip.user.domain.User;

public record ProfileGetResponse(
String name,
String intro,
int result
) {

public static ProfileGetResponse of(User user) {
return new ProfileGetResponse(
user.getName(),
user.getIntro(),
user.getResult()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import org.doorip.user.dto.request.UserReissueRequest;
import org.doorip.user.dto.request.UserSignInRequest;
import org.doorip.user.dto.request.UserSignUpRequest;
import org.doorip.user.dto.response.ProfileGetResponse;
import org.doorip.user.dto.response.UserResponse;
import org.doorip.user.repository.RefreshTokenRepository;
import org.doorip.user.repository.UserRepository;
Expand Down Expand Up @@ -78,6 +79,11 @@ public UserResponse reissue(String refreshToken, UserReissueRequest request) {
return UserResponse.of(issueToken);
}

public ProfileGetResponse getProfile(Long userId) {
User findUser = getUser(userId);
return ProfileGetResponse.of(findUser);
}

private String getPlatformId(String token, Platform platform) {
if (platform == APPLE) {
return appleOAuthProvider.getApplePlatformId(token);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public enum ErrorMessage {
REFRESH_TOKEN_NOT_FOUND(HttpStatus.NOT_FOUND, "e4042", "리프레쉬 토큰을 찾을 수 없습니다."),
TRIP_NOT_FOUND(HttpStatus.NOT_FOUND, "e4043", "존재하지 않는 여행입니다."),
PARTICIPANT_NOT_FOUND(HttpStatus.NOT_FOUND, "e4044", "존재하지 않는 참여자입니다."),
RESULT_NOT_FOUND(HttpStatus.NOT_FOUND, "e4045", "유저의 성향 결과 값을 찾을 수 없습니다."),

/**
* 405 Method Not Allowed
Expand Down