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
@@ -13,11 +13,10 @@ from app.core.router_class import OperationLogRoute
from .schema import DeptCreateSchema, DeptOutSchema, DeptQueryParam, DeptUpdateSchema
from .service import DeptService
DeptRouter = APIRouter(route_class=OperationLogRoute, prefix="/dept", tags=["部门管理"])
DeptRouter = APIRouter(route_class=OperationLogRoute, prefix="/dept", tags=["系统管理", "部门管理"])
_DEPT_NS = "dept"
@DeptRouter.get(
"/tree",
summary="查询部门树",
@@ -28,23 +27,9 @@ async def get_dept_tree_controller(
search: Annotated[DeptQueryParam, Depends()],
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:dept:query"]))],
) -> JSONResponse:
"""
查询部门树
参数:
- search (DeptQueryParam): 查询参数模型
- auth (AuthSchema): 认证信息模型
返回:
- JSONResponse: 包含部门树的响应模型
异常:
- CustomException: 查询部门树失败时抛出异常。
"""
order_by = [{"order": "asc"}]
result_dict_list = await DeptService.tree_service(search=search, auth=auth, order_by=order_by)
return SuccessResponse(data=result_dict_list, msg="查询部门树成功")
result_dict_tree = await DeptService(auth).tree(search=search, order_by=order_by)
return SuccessResponse(data=result_dict_tree, msg="查询部门树成功")
@DeptRouter.get(
"/detail/{id}",
@@ -55,23 +40,9 @@ async def get_obj_detail_controller(
id: Annotated[int, Path(description="部门ID")],
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:dept:detail"]))],
) -> JSONResponse:
"""
查询部门详情
参数:
- id (int): 部门ID
- auth (AuthSchema): 认证信息模型
返回:
- JSONResponse: 包含部门详情的响应模型
异常:
- CustomException: 查询部门详情失败时抛出异常。
"""
result_dict = await DeptService.detail_service(id=id, auth=auth)
result_dict = await DeptService(auth).detail(id=id)
return SuccessResponse(data=result_dict, msg="查询部门详情成功")
@DeptRouter.post(
"/create",
summary="创建部门",
@@ -81,24 +52,10 @@ async def create_obj_controller(
data: DeptCreateSchema,
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:dept:create"]))],
) -> JSONResponse:
"""
创建部门
参数:
- data (DeptCreateSchema): 创建部门负载模型
- auth (AuthSchema): 认证信息模型
返回:
- JSONResponse: 包含创建部门结果的响应模型
异常:
- CustomException: 创建部门失败时抛出异常。
"""
result_dict = await DeptService.create_service(data=data, auth=auth)
result_dict = await DeptService(auth).create(data=data)
await FastAPICache.clear(namespace=_DEPT_NS)
return SuccessResponse(data=result_dict, msg="创建部门成功")
@DeptRouter.put(
"/update/{id}",
summary="修改部门",
@@ -109,25 +66,10 @@ async def update_obj_controller(
id: Annotated[int, Path(description="部门ID")],
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:dept:update"]))],
) -> JSONResponse:
"""
修改部门
参数:
- data (DeptUpdateSchema): 修改部门负载模型
- id (int): 部门ID
- auth (AuthSchema): 认证信息模型
返回:
- JSONResponse: 包含修改部门结果的响应模型
异常:
- CustomException: 修改部门失败时抛出异常。
"""
result_dict = await DeptService.update_service(auth=auth, id=id, data=data)
result_dict = await DeptService(auth).update(id=id, data=data)
await FastAPICache.clear(namespace=_DEPT_NS)
return SuccessResponse(data=result_dict, msg="修改部门成功")
@DeptRouter.delete(
"/delete",
summary="删除部门",
@@ -137,24 +79,10 @@ async def delete_obj_controller(
ids: Annotated[list[int], Body(description="ID列表")],
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:dept:delete"]))],
) -> JSONResponse:
"""
删除部门
参数:
- ids (list[int]): 部门ID列表
- auth (AuthSchema): 认证信息模型
返回:
- JSONResponse: 包含删除部门结果的响应模型
异常:
- CustomException: 删除部门失败时抛出异常。
"""
await DeptService.delete_service(ids=ids, auth=auth)
await DeptService(auth).delete(ids=ids)
await FastAPICache.clear(namespace=_DEPT_NS)
return SuccessResponse(msg="删除部门成功")
@DeptRouter.patch(
"/status/batch",
summary="批量修改部门状态",
@@ -164,19 +92,6 @@ async def batch_set_available_obj_controller(
data: BatchSetAvailable,
auth: Annotated[AuthSchema, Depends(AuthPermission(["module_system:dept:patch"]))],
) -> JSONResponse:
"""
批量修改部门状态
参数:
- data (BatchSetAvailable): 批量修改部门状态负载模型
- auth (AuthSchema): 认证信息模型
返回:
- JSONResponse: 包含批量修改部门状态结果的响应模型
异常:
- CustomException: 批量修改部门状态失败时抛出异常。
"""
await DeptService.batch_set_available_service(data=data, auth=auth)
await DeptService(auth).batch_set_available(data=data)
await FastAPICache.clear(namespace=_DEPT_NS)
return SuccessResponse(msg="批量修改部门状态成功")