Created
April 20, 2026 06:21
-
-
Save koorukuroo/c4d2e249611facc4211e563704260bef 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.post("/api/v1/requests", | |
| response_model=RequestResponse, | |
| status_code=201, tags=["점검 요청"]) | |
| def create_request(req: RequestCreate, | |
| db: Session = Depends(get_db)): | |
| # 설비 존재 여부 확인 | |
| equipment = db.query(Equipment) \ | |
| .filter(Equipment.id == req.equipment_id).first() | |
| if not equipment: | |
| raise HTTPException( | |
| status_code=404, | |
| detail="설비를 찾을 수 없습니다") | |
| # 새 요청 생성 | |
| new_request = InspectionRequest(**req.model_dump()) | |
| db.add(new_request) | |
| db.commit() | |
| db.refresh(new_request) | |
| # 상태 이력 기록 | |
| history = StatusHistory( | |
| request_id=new_request.id, | |
| from_status=None, to_status="PENDING", | |
| changed_by=req.requester_id, | |
| comment="점검 요청 접수") | |
| db.add(history) | |
| db.commit() | |
| return new_request |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment