wujie应用联调

This commit is contained in:
董宏凯 committed 2026-06-11 17:11:28 +08:00
1 parent 0784f30e23
commit f3ca996116
35 files changed
+1590 -334

No files matched your search

@@ -53,6 +53,7 @@ class RoundtableDraftRepository:
"""Lightweight projection for the history dropdown (no big blobs)."""
return {
"id": row.id,
"task_id": row.task_id,
"title": row.title,
"furthest_step": row.furthest_step,
"created_at": row.created_at.isoformat() if isinstance(row.created_at, datetime) else row.created_at,
@@ -81,15 +82,30 @@ class RoundtableDraftRepository:
async def get_draft(self, draft_id: str, user_id: str) -> dict[str, Any] | None:
async with self._sf() as session:
row = await session.get(RoundtableDraftRow, draft_id)
if row is None or row.user_id != user_id:
# task 绑定的草稿共享:放开 user 归属校验(不分权);非 task 草稿仍按 user 隔离。
if row is None or (row.user_id != user_id and not row.task_id):
return None
return self._draft_to_dict(row)
async def get_latest_draft_by_task(self, task_id: str) -> dict[str, Any] | None:
"""按外部任务 id 取最新一条草稿(**忽略 user_id**,不分权)。无则 None。"""
stmt = (
select(RoundtableDraftRow)
.where(RoundtableDraftRow.task_id == task_id)
.order_by(RoundtableDraftRow.updated_at.desc())
.limit(1)
)
async with self._sf() as session:
result = await session.execute(stmt)
row = result.scalars().first()
return self._draft_to_dict(row) if row is not None else None
async def create_draft(self, user_id: str, data: dict[str, Any]) -> dict[str, Any]:
now = datetime.now(UTC)
row = RoundtableDraftRow(
id=data["id"],
user_id=user_id,
task_id=(data.get("task_id") or None),
title=(data.get("title") or "").strip(),
furthest_step=int(data.get("furthest_step") or 1),
step1=_dumps(data.get("step1")),
@@ -114,11 +130,15 @@ class RoundtableDraftRepository:
step1=_UNSET,
step2=_UNSET,
step3=_UNSET,
task_id=_UNSET,
) -> dict[str, Any] | None:
async with self._sf() as session:
row = await session.get(RoundtableDraftRow, draft_id)
if row is None or row.user_id != user_id:
# task 绑定的草稿共享:放开 user 归属校验(不分权)。
if row is None or (row.user_id != user_id and not row.task_id):
return None
if task_id is not _UNSET and task_id is not None:
row.task_id = str(task_id)
if title is not _UNSET and title is not None:
row.title = str(title).strip()
if furthest_step is not _UNSET and furthest_step is not None:
@@ -137,7 +157,8 @@ class RoundtableDraftRepository:
async def delete_draft(self, draft_id: str, user_id: str) -> bool:
async with self._sf() as session:
row = await session.get(RoundtableDraftRow, draft_id)
if row is None or row.user_id != user_id:
# task 绑定的草稿共享:放开 user 归属校验(不分权)。
if row is None or (row.user_id != user_id and not row.task_id):
return False
await session.delete(row)
await session.commit()