refactor: 完成项目大规模代码重构与依赖清理

这是一次综合性的重构更新,包含以下主要变更:
1.  升级Python版本到3.12,更新依赖配置
2.  替换旧的.j2模板为.jinja2格式,新增代码生成模板
3.  重构权限过滤策略,更新权限枚举与模型配置
4.  移除Prefect依赖,替换为自研拓扑并行执行引擎
5.  重构认证与上下文管理,拆分租户/请求上下文
6.  简化响应模型、CRUD与服务层代码
7.  清理废弃的支付网关模块,重构订单定时任务
8.  更新在线用户、监控等模块的接口与路由
9.  优化邮件模板与工具类,新增邮件模板文件
10. 修复数据库会话配置与类型提示
This commit is contained in:
zhangtao
2026-06-21 06:02:05 +08:00
parent 4e2b668d7b
commit 211fddd6e0
121 changed files with 2869 additions and 11379 deletions
@@ -18,7 +18,7 @@ from .schema import (
)
from .service import NodeService
NodeRouter = APIRouter(route_class=OperationLogRoute, prefix="/cronjob/node", tags=["节点管理"])
NodeRouter = APIRouter(route_class=OperationLogRoute, prefix="/cronjob/node", tags=["任务调度", "节点管理"])
@NodeRouter.get(
@@ -29,16 +29,8 @@ NodeRouter = APIRouter(route_class=OperationLogRoute, prefix="/cronjob/node", ta
async def get_node_options_controller(
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_task:cronjob:node:query"]))],
) -> JSONResponse:
"""
获取数据库中的定时任务节点定义(task_node),与编排节点类型无关。
参数:
- auth (AuthSchema): 认证信息。
返回:
- JSONResponse: 成功响应,data 为选项列表。
"""
result = await NodeService.get_node_options_service(auth=auth)
service = NodeService(auth)
result = await service.options()
return SuccessResponse(data=result, msg="获取定时任务节点选项成功")
@@ -51,17 +43,8 @@ async def get_obj_detail_controller(
id: Annotated[int, Path(description="节点ID")],
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_task:cronjob:node:detail"]))],
) -> JSONResponse:
"""
获取节点详情
参数:
- id (int): 节点ID
- auth (AuthSchema): 认证信息模型
返回:
- JSONResponse: 包含节点详情的JSON响应
"""
result_dict = await NodeService.get_node_detail_service(id=id, auth=auth)
service = NodeService(auth)
result_dict = await service.detail(id=id)
return SuccessResponse(data=result_dict, msg="获取节点详情成功")
@@ -75,19 +58,8 @@ async def get_obj_list_controller(
search: Annotated[NodeQueryParam, Depends()],
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_task:cronjob:node:query"]))],
) -> JSONResponse:
"""
查询节点
参数:
- page (PaginationQueryParam): 分页查询参数模型
- search (NodeQueryParam): 查询参数模型
- auth (AuthSchema): 认证信息模型
返回:
- JSONResponse: 包含分页后的节点列表的JSON响应
"""
result_dict = await NodeService.get_node_page_service(
auth=auth,
service = NodeService(auth)
result_dict = await service.page(
page_no=page.page_no,
page_size=page.page_size,
search=search,
@@ -105,17 +77,8 @@ async def create_obj_controller(
data: NodeCreateSchema,
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_task:cronjob:node:create"]))],
) -> JSONResponse:
"""
创建节点
参数:
- data (NodeCreateSchema): 创建参数模型
- auth (AuthSchema): 认证信息模型
返回:
- JSONResponse: 包含创建节点结果的JSON响应
"""
result_dict = await NodeService.create_node_service(auth=auth, data=data)
service = NodeService(auth)
result_dict = await service.create(data=data)
return SuccessResponse(data=result_dict, msg="创建节点成功")
@@ -129,18 +92,8 @@ async def update_obj_controller(
id: Annotated[int, Path(description="节点ID")],
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_task:cronjob:node:update"]))],
) -> JSONResponse:
"""
修改节点
参数:
- data (NodeUpdateSchema): 更新参数模型
- id (int): 节点ID
- auth (AuthSchema): 认证信息模型
返回:
- JSONResponse: 包含修改节点结果的JSON响应
"""
result_dict = await NodeService.update_node_service(auth=auth, id=id, data=data)
service = NodeService(auth)
result_dict = await service.update(id=id, data=data)
return SuccessResponse(data=result_dict, msg="修改节点成功")
@@ -153,17 +106,8 @@ async def delete_obj_controller(
ids: Annotated[list[int], Body(description="ID列表")],
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_task:cronjob:node:delete"]))],
) -> JSONResponse:
"""
删除节点
参数:
- ids (list[int]): ID列表
- auth (AuthSchema): 认证信息模型
返回:
- JSONResponse: 包含删除节点结果的JSON响应
"""
await NodeService.delete_node_service(auth=auth, ids=ids)
service = NodeService(auth)
await service.delete(ids=ids)
return SuccessResponse(msg="删除节点成功")
@@ -175,16 +119,8 @@ async def delete_obj_controller(
async def clear_obj_controller(
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_task:cronjob:node:delete"]))],
) -> JSONResponse:
"""
清空所有节点
参数:
- auth (AuthSchema): 认证信息模型
返回:
- JSONResponse: 包含清空节点结果的JSON响应
"""
await NodeService.clear_node_service(auth=auth)
service = NodeService(auth)
await service.clear()
return SuccessResponse(msg="清空节点成功")
@@ -198,18 +134,8 @@ async def execute_job_controller(
data: NodeExecuteSchema,
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_task:cronjob:node:execute"]))],
) -> JSONResponse:
"""
调试节点
参数:
- id (int): 节点ID
- data (NodeExecuteSchema): 执行参数模型
- auth (AuthSchema): 认证信息模型
返回:
- JSONResponse: 包含调试结果的JSON响应
"""
result = await NodeService.execute_node_service(auth=auth, id=id, execute_data=data)
service = NodeService(auth)
result = await service.execute(id=id, execute_data=data)
return SuccessResponse(data=result, msg="调试节点成功")
@@ -223,16 +149,6 @@ async def batch_set_status_controller(
status: Annotated[str, Body(description="状态值")],
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_task:cronjob:node:update"]))],
) -> JSONResponse:
"""
批量设置节点状态
参数:
- ids (list[int]): 节点ID列表
- status (str): 状态值
- auth (AuthSchema): 认证信息模型
返回:
- JSONResponse: 成功响应
"""
await NodeService.batch_set_status_service(auth=auth, ids=ids, status=status)
service = NodeService(auth)
await service.batch_set_status(ids=ids, status=status)
return SuccessResponse(msg="批量设置节点状态成功")