Created
April 20, 2026 06:24
-
-
Save koorukuroo/960a213abc582c3705863f494ca78468 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @app.get("/api/v1/requests", | |
| response_model=list[RequestResponse]) | |
| def list_requests( | |
| status: Optional[str] = Query(None), | |
| priority: Optional[str] = Query(None), | |
| page: int = Query(1, ge=1, | |
| description="페이지 번호 (1부터 시작)"), | |
| limit: int = Query(10, ge=1, le=100, | |
| description="페이지당 항목 수 (최대 100)"), | |
| db: Session = Depends(get_db), | |
| ): | |
| query = db.query(InspectionRequest) | |
| if status: | |
| query = query.filter( | |
| InspectionRequest.status == status) | |
| if priority: | |
| query = query.filter( | |
| InspectionRequest.priority == priority) | |
| # offset/limit 계산 | |
| offset = (page - 1) * limit | |
| return query.order_by( | |
| InspectionRequest.created_at.desc() | |
| ).offset(offset).limit(limit).all() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment