mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-22 05:02:57 +00:00
- 将工作流相关模块从module_application迁移到module_task目录 - 新增节点类型模型、服务和API接口 - 添加动态节点组件和节点操作工具函数 - 更新前端工作流编辑器支持动态节点配置 - 移除旧的module_application工作流相关文件 - 升级element-plus到2.11.0版本 - 优化性能工具函数(防抖和节流) - 清理不再使用的依赖项(langchain-anthropic和langchain-mcp-adapters)
117 lines
3.0 KiB
Python
117 lines
3.0 KiB
Python
from typing import Any
|
|
|
|
from app.api.v1.module_system.auth.schema import AuthSchema
|
|
from app.core.base_crud import CRUDBase
|
|
|
|
from .model import NodeModel
|
|
from .schema import (
|
|
NodeCreateSchema,
|
|
NodeOutSchema,
|
|
NodeUpdateSchema,
|
|
)
|
|
|
|
|
|
class NodeCRUD(CRUDBase[NodeModel, NodeCreateSchema, NodeUpdateSchema]):
|
|
"""节点数据层"""
|
|
|
|
def __init__(self, auth: AuthSchema) -> None:
|
|
self.auth = auth
|
|
super().__init__(model=NodeModel, auth=auth)
|
|
|
|
async def get_by_id_crud(
|
|
self, id: int, preload: list[str | Any] | None = None
|
|
) -> NodeModel | None:
|
|
"""
|
|
获取节点类型详情
|
|
|
|
参数:
|
|
- id (int): 节点类型ID
|
|
- preload (list[str | Any] | None): 预加载关联数据
|
|
|
|
返回:
|
|
- NodeTypeModel | None: 节点类型模型实例
|
|
"""
|
|
return await self.get(id=id, preload=preload)
|
|
|
|
async def get_by_code_crud(self, code: str) -> NodeModel | None:
|
|
"""
|
|
根据编码获取节点类型
|
|
|
|
参数:
|
|
- code (str): 节点类型编码
|
|
|
|
返回:
|
|
- NodeModel | None: 节点模型实例
|
|
"""
|
|
return await self.get(code=code)
|
|
|
|
async def page_crud(
|
|
self,
|
|
offset: int,
|
|
limit: int,
|
|
order_by: list[dict] | None = None,
|
|
search: dict | None = None,
|
|
preload: list | None = None,
|
|
) -> dict:
|
|
"""
|
|
分页查询节点类型
|
|
|
|
参数:
|
|
- offset (int): 偏移量
|
|
- limit (int): 限制数量
|
|
- order_by (list[dict] | None): 排序条件
|
|
- search (dict | None): 查询条件
|
|
- preload (list | None): 预加载关联数据
|
|
|
|
返回:
|
|
- dict: 分页查询结果
|
|
"""
|
|
order_by_list = order_by or [{"sort_order": "asc"}, {"id": "desc"}]
|
|
search_dict = search or {}
|
|
|
|
return await self.page(
|
|
offset=offset,
|
|
limit=limit,
|
|
order_by=order_by_list,
|
|
search=search_dict,
|
|
out_schema=NodeOutSchema,
|
|
preload=preload,
|
|
)
|
|
|
|
async def create_crud(self, data: NodeCreateSchema) -> NodeModel | None:
|
|
"""
|
|
创建节点类型
|
|
|
|
参数:
|
|
- data (NodeCreateSchema): 节点类型创建模型
|
|
|
|
返回:
|
|
- NodeModel | None: 节点类型模型实例
|
|
"""
|
|
return await self.create(data=data)
|
|
|
|
async def update_crud(self, id: int, data: NodeUpdateSchema) -> NodeModel | None:
|
|
"""
|
|
更新节点类型
|
|
|
|
参数:
|
|
- id (int): 节点类型ID
|
|
- data (NodeUpdateSchema): 节点类型更新模型
|
|
|
|
返回:
|
|
- NodeModel | None: 节点类型模型实例
|
|
"""
|
|
return await self.update(id=id, data=data)
|
|
|
|
async def delete_crud(self, ids: list[int]) -> None:
|
|
"""
|
|
删除节点类型
|
|
|
|
参数:
|
|
- ids (list[int]): 节点类型ID列表
|
|
|
|
返回:
|
|
- None
|
|
"""
|
|
await self.delete(ids=ids)
|