Optimo 프로젝트의 User 조회 서비스 레포지토리입니다.
- 해당 서비스는 3rd Party Oauth2.0과 자체 발급 Jwt로 검증 후, User 정보를 조회하는 서비스입니다.
- 아래와 같은 경로로 URL 요청을 할 경우, User 정보를 반환합니다.
- JDK 17, SpringBoot 3.5, Java + Gradle
- PostgeSQL
- 환경 변수
POSTGRES_USERNAME: PostgreSQL IDPOSTGRES_PASSWORD: PostgreSQL PW
- 환경 변수
# 이전 빌드 제거 및 빌드 명령어
./gradlew clean bootJar
# 빌드된 jar 파일 실행 명령어
java -jar ./build/libs/Optimo_User_BE-0.0.1-SNAPSHOT.jar
- 제목: Optmo User API
- 버전: 1.0.0
- 설명: 사용자 관리 및 전기 사용량 추적 API
URL: /api/user
Method: GET
요청 파라미터:
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| String | O | 사용자 이메일 |
요청 헤더:
Authorization: Bearer [JWT 토큰]
응답:
- 성공 (200):
- 헤더:
Authorization: Bearer [JWT 토큰]
- 본문:
- 헤더:
{
"id": 12345,
"email": "user@example.com",
"name": "홍길동",
"profileImage": "https://example.com/profile.jpg",
"provider": "EMAIL",
"totalUseElecEstimate": 1500,
"totalLlmElecEstimate": 500
}- 실패 (400):
Email parameter is required
- 실패 (401):
Invalid JWT: [error details]
- 실패 (500):
Internal error: [error details]
URL: /api/user/oauth
Method: POST
요청 파라미터:
| 파라미터 | 타입 | 필수 | 설명 |
|---|---|---|---|
| provider | String | O | OAuth 제공자 (GOOGLE, KAKAO, NAVER 등) |
요청 헤더:
Authorization: Bearer [OAuth 토큰]
응답:
- 성공 (200):
- 헤더:
Authorization: Bearer [JWT 토큰]
- 본문:
- 헤더:
{
"id": 12345,
"email": "user@example.com",
"name": "홍길동",
"profileImage": "https://example.com/profile.jpg",
"provider": "GOOGLE",
"totalUseElecEstimate": 1500,
"totalLlmElecEstimate": 500
}- 실패 (401):
Invalid JWT: [error details]
- 실패 (404):
User Not Found: [error details]
- 실패 (500):
Internal error: [error details]
URL: /api/user/jwt
Method: GET
요청 헤더:
Authorization: Bearer [JWT 토큰]
응답:
- 성공 (200):
- 본문:
{
"id": 12345,
"email": "user@example.com",
"name": "홍길동",
"profileImage": "https://example.com/profile.jpg",
"provider": "EMAIL",
"totalUseElecEstimate": 1500,
"totalLlmElecEstimate": 500
}- 실패 (401):
Invalid JWT: [error details]
- 실패 (404):
User Not Found: [error details]
- 실패 (500):
Internal error: [error details]
URL: /api/user/electricity
Method: PATCH
요청 헤더:
Authorization: Bearer [JWT 토큰]
요청 본문:
{
"useElecEstimate": 100,
"llmElecEstimate": 50
}응답:
- 성공 (200):
- 본문:
Successfully Increased Elec and Cost Estimate
- 실패 (401):
Invalid JWT: [error details]
- 실패 (404):
User Not Found: [error details]
- 실패 (500):
Internal error: [error details]
| 필드 | 타입 | 예시 값 |
|---|---|---|
| id | Long | 12345 |
| String | user@example.com | |
| name | String | 홍길동 |
| profileImage | String | https://example.com/profile.jpg |
| provider | String | EMAIL, GOOGLE, KAKAO, NAVER |
| totalUseElecEstimate | Long | 1500 |
| totalLlmElecEstimate | Long | 500 |
| 필드 | 타입 | 예시 값 |
|---|---|---|
| useElecEstimate | Long | 100 |
| llmElecEstimate | Long | 50 |
- Authorization: Bearer 토큰 (JWT 또는 OAuth 토큰)
| 코드 | 설명 |
|---|---|
| 400 | 잘못된 요청 |
| 401 | 인증 실패 |
| 404 | 리소스 없음 |
| 500 | 서버 내부 오류 |