feat: add recharge workflow models and schema statuses

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-09-26 20:55:15 +08:00
1 parent 94dd52832b
commit bdd67d44d9
7 files changed
+147 -26

No files matched your search

+26 -3
View File
@@ -67,7 +67,16 @@ def create_workflow(
nodes_data = data.pop("nodes", []) or []
workflow = WorkflowService.create(db, data, user=user)
if nodes_data:
WorkflowService.save_nodes(db, workflow.id, nodes_data, user=user)
try:
WorkflowService.save_nodes(db, workflow.id, nodes_data, user=user)
except ValueError as exc:
db.rollback()
code = (
status.HTTP_400_BAD_REQUEST
if "发放登记" in str(exc)
else status.HTTP_404_NOT_FOUND
)
raise HTTPException(status_code=code, detail=str(exc)) from exc
db.commit()
db.refresh(workflow)
return ApiResponse(data=WorkflowDefOut.model_validate(workflow))
@@ -87,7 +96,16 @@ def update_workflow(
if not workflow:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="工作流不存在")
if nodes_data is not None:
WorkflowService.save_nodes(db, workflow_id, nodes_data, user=user)
try:
WorkflowService.save_nodes(db, workflow_id, nodes_data, user=user)
except ValueError as exc:
db.rollback()
code = (
status.HTTP_400_BAD_REQUEST
if "发放登记" in str(exc)
else status.HTTP_404_NOT_FOUND
)
raise HTTPException(status_code=code, detail=str(exc)) from exc
db.commit()
db.refresh(workflow)
return ApiResponse(data=WorkflowDefOut.model_validate(workflow))
@@ -106,7 +124,12 @@ def save_workflow_nodes(
WorkflowService.save_nodes(db, workflow_id, nodes_data, user=user)
except ValueError as exc:
db.rollback()
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail=str(exc)) from exc
code = (
status.HTTP_400_BAD_REQUEST
if "发放登记" in str(exc)
else status.HTTP_404_NOT_FOUND
)
raise HTTPException(status_code=code, detail=str(exc)) from exc
workflow = WorkflowService.get_by_id(db, workflow_id, tenant_no, user=user)
if not workflow:
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="工作流不存在")