pipeline-sdlc/wwwroot/api/human_task_create.dspy

28 lines
1.2 KiB
Plaintext
Raw 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.

# human_task_create.dspy - 派发项目级人类任务(仅项目 owner
user_id = await get_user()
if not user_id:
return json.dumps({"success": False, "error": "未登录"}, ensure_ascii=False)
project_id = params_kw.get('project_id', '').strip()
title = params_kw.get('title', '').strip()
description = params_kw.get('description', '')
assignee_role = params_kw.get('assignee_role', '').strip()
assignee_id = params_kw.get('assignee_id', '').strip()
if not project_id or not title:
return json.dumps({"success": False, "error": "缺少 project_id 或 title"}, ensure_ascii=False)
dbname = get_module_dbname('pipeline-sdlc')
async with DBPools().sqlorContext(dbname) as sor:
ok, emsg = await check_project_owner(project_id, user_id, sor)
if not ok:
return json.dumps({"success": False, "error": emsg}, ensure_ascii=False)
ok, msg = await create_human_task(project_id, title, description,
assignee_role=assignee_role, assignee_id=assignee_id,
created_by=user_id)
if ok:
return json.dumps({"success": True, "id": msg}, ensure_ascii=False)
return json.dumps({"success": False, "error": msg}, ensure_ascii=False)