重构工作流相关API,支持异步操作并引入异步数据库管理

This commit is contained in:
jxxghp
2025-07-30 18:21:13 +08:00
parent 5f6310f5d6
commit cd8661abc1
4 changed files with 306 additions and 66 deletions
+26 -2
View File
@@ -1,6 +1,6 @@
from typing import List, Tuple, Optional
from typing import List, Tuple, Optional, Any, Coroutine, Sequence
from app.db import DbOper
from app.db import DbOper, AsyncDbOper
from app.db.models.workflow import Workflow
@@ -84,3 +84,27 @@ class WorkflowOper(DbOper):
重置
"""
return Workflow.reset(self._db, wid, reset_count=reset_count)
class AsyncWorkflowOper(AsyncDbOper):
"""
异步工作流管理
"""
async def get(self, wid: int) -> Workflow:
"""
异步查询单个工作流
"""
return await Workflow.async_get(self._db, wid)
async def list(self) -> Coroutine[Any, Any, Sequence[Any]]:
"""
异步获取所有工作流列表
"""
return await Workflow.async_list(self._db)
async def get_by_name(self, name: str) -> Workflow:
"""
异步按名称获取工作流
"""
return await Workflow.async_get_by_name(self._db, name)