Created
April 20, 2026 06:24
-
-
Save koorukuroo/2ad5e577d652f3d9fc98eed7dd76bd45 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.put("/api/v1/requests/{request_id}/status", | |
| response_model=RequestResponse, | |
| tags=["점검 요청"]) | |
| def update_status(request_id: int, | |
| update: StatusUpdate, | |
| db: Session = Depends(get_db)): | |
| req = db.query(InspectionRequest) \ | |
| .filter(InspectionRequest.id == request_id) \ | |
| .first() | |
| if not req: | |
| raise HTTPException( | |
| status_code=404, | |
| detail="점검 요청을 찾을 수 없습니다") | |
| # 상태 전이 검증 | |
| allowed = VALID_TRANSITIONS.get(req.status, []) | |
| if update.status not in allowed: | |
| raise HTTPException( | |
| status_code=400, | |
| detail=f"'{req.status}'에서 " | |
| f"'{update.status}'로 변경 불가. " | |
| f"가능: {allowed}") | |
| # 상태 이력 기록 + 업데이트 | |
| history = StatusHistory( | |
| request_id=req.id, | |
| from_status=req.status, | |
| to_status=update.status, | |
| changed_by=update.changed_by, | |
| comment=update.comment) | |
| req.status = update.status | |
| if update.assignee_id: | |
| req.assignee_id = update.assignee_id | |
| db.add(history) | |
| db.commit() | |
| db.refresh(req) | |
| return req |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment