pipeline-sdlc/wwwroot/api/flow_plan_confirm.dspy

37 lines
1.6 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# flow_plan_confirm.dspy - 产线流程裁剪计划的用户确认/驳回端点
#
# 入参form-encoded
# plan_id 流程计划 idpipeline_flow_plans.id
# decision confirm | reject
# comment 驳回意见reject 时必填confirm 可空)
#
# 安全:确认动作是用户专属(同机构 + owner.superuser/项目创建者校验在
# flow_plan_capability._check_confirm_operatoragent 无对应工具,无法代替确认。
# 驳回意见落 reject_comment会话 agent 用 get_flow_plan 读到后按意见修订重提version+1
user_id = await get_user()
if not user_id:
return json.dumps({"success": False, "error": "未登录"}, ensure_ascii=False)
plan_id = str((params_kw or {}).get('plan_id') or '').strip()
decision = str((params_kw or {}).get('decision') or '').strip().lower()
comment = str((params_kw or {}).get('comment') or '').strip()
if not plan_id:
return json.dumps({"success": False, "error": "缺少 plan_id"}, ensure_ascii=False)
if decision == 'confirm':
ok, msg = await flow_plan_confirm(plan_id, operator_id=user_id)
elif decision == 'reject':
if not comment:
return json.dumps({"success": False, "error": "驳回必须填写意见(助手按意见修订流程)"},
ensure_ascii=False)
ok, msg = await flow_plan_reject(plan_id, comment, operator_id=user_id)
else:
return json.dumps({"success": False, "error": "decision 必须是 confirm 或 reject"},
ensure_ascii=False)
if ok:
return json.dumps({"success": True, "message": msg}, ensure_ascii=False)
return json.dumps({"success": False, "error": msg}, ensure_ascii=False)