|
1 | 1 | from fastapi import APIRouter, Depends, HTTPException, status |
2 | 2 | from sqlalchemy.ext.asyncio import AsyncSession |
3 | | -from app.schemas.user import UserResponse, UserUpdate |
| 3 | +from app.schemas.user import UserResponse, UserUpdate, UserInformationResponse |
4 | 4 | from app.schemas.base import ResponseBase |
5 | 5 | from app.services.user import ( |
6 | 6 | select_users, |
@@ -33,16 +33,14 @@ async def get_users( |
33 | 33 | ) |
34 | 34 |
|
35 | 35 |
|
36 | | -@router.get("/{user_id}", response_model=ResponseBase[UserResponse]) |
37 | | -async def get_user_by_id( |
38 | | - user_id: UUID, |
39 | | - db: AsyncSession = Depends(get_db), |
40 | | -) -> ResponseBase[UserResponse]: |
| 36 | +# 프론트엔드에서 사용할 유저 정보 조회 API |
| 37 | +@router.get("/{user_id}", response_model=ResponseBase[UserInformationResponse]) |
| 38 | +async def get_user_by_id(user_id: UUID, db: AsyncSession = Depends(get_db)): |
41 | 39 | try: |
42 | | - user = await select_user_by_id(db, user_id) |
43 | | - return ResponseBase(status_code=status.HTTP_200_OK, data=user) |
| 40 | + user_info = await select_user_by_id(db, user_id) |
| 41 | + return ResponseBase(status_code=status.HTTP_200_OK, data=user_info) |
44 | 42 | except HTTPException as e: |
45 | | - return ResponseBase(status_code=e.status_code, error=e.detail) |
| 43 | + raise ResponseBase(status_code=e.status_code, error=e.detail) |
46 | 44 | except Exception as e: |
47 | 45 | return ResponseBase( |
48 | 46 | status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, error=str(e) |
|
0 commit comments