|
15 | 15 | AppointmentDetailResponse, |
16 | 16 | AppointmentListResponse, |
17 | 17 | SyncMySchedulesResponse, |
| 18 | + ConfirmAppointmentRequest, |
| 19 | + ConfirmAppointmentResponse, |
18 | 20 | ) |
19 | 21 | from app.utils.jwt import get_current_user |
20 | 22 |
|
@@ -246,3 +248,37 @@ async def sync_my_schedules( |
246 | 248 | raise HTTPException(status_code=400, detail=str(e)) |
247 | 249 | except Exception as e: |
248 | 250 | raise HTTPException(status_code=500, detail=f"일정 동기화 실패: {str(e)}") |
| 251 | + |
| 252 | + |
| 253 | +@router.post("/{invite_code}/confirm", response_model=ConfirmAppointmentResponse) |
| 254 | +async def confirm_appointment( |
| 255 | + invite_code: str, |
| 256 | + request: ConfirmAppointmentRequest, |
| 257 | + db: AsyncSession = Depends(get_db), |
| 258 | + current_user: dict = Depends(get_current_user), |
| 259 | +): |
| 260 | + # 약속 확정 |
| 261 | + try: |
| 262 | + appointment = await AppointmentService.confirm_appointment( |
| 263 | + invite_code=invite_code, |
| 264 | + confirmed_date=request.confirmed_date, |
| 265 | + confirmed_start_time=request.confirmed_start_time, |
| 266 | + confirmed_end_time=request.confirmed_end_time, |
| 267 | + user_id=current_user["sub"], |
| 268 | + db=db, |
| 269 | + ) |
| 270 | + |
| 271 | + return ConfirmAppointmentResponse( |
| 272 | + id=appointment.id, |
| 273 | + name=appointment.name, |
| 274 | + status=appointment.status, |
| 275 | + confirmed_date=appointment.confirmed_date, |
| 276 | + confirmed_start_time=appointment.confirmed_start_time, |
| 277 | + confirmed_end_time=appointment.confirmed_end_time, |
| 278 | + confirmed_at=appointment.confirmed_at, |
| 279 | + ) |
| 280 | + |
| 281 | + except ValueError as e: |
| 282 | + raise HTTPException(status_code=400, detail=str(e)) |
| 283 | + except Exception as e: |
| 284 | + raise HTTPException(status_code=500, detail=f"약속 확정 실패: {str(e)}") |
0 commit comments