mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-22 05:02:57 +00:00
这是一次综合性的项目迭代,包含以下核心变更:
1. **目录与模块重构**
- 调整工作流节点类型模块目录结构,迁移节点类型相关代码
- 重命名platform模块为system模块,更新插件配置信息
- 重构代码生成模块导入路径
2. **数据库与CRUD优化**
- 统一所有CRUD类构造函数,新增数据库会话参数
- 修复权限过滤器数据库会话使用问题
- 更新模板生成器的CRUD代码模板
3. **认证与安全改进**
- 重构JWT密钥配置,移除默认密钥强制要求环境变量
- 重命名密码工具类,统一密码加密校验逻辑
- 优化OAuth认证流程,修复匿名认证使用问题
4. **前端与静态资源**
- 重构前端挂载逻辑,增加目录存在性校验
- 使用标准StaticFiles替换自定义前端挂载实现
5. **工具类与依赖更新**
- 修复导入工具的表名重复检测逻辑
- 优化限流回调代码,移除冗余依赖
- 更新用户、租户等模块的响应模型字段
6. **数据与配置修正**
- 修复系统版本数据字段命名不统一问题
- 简化枚举类校验逻辑,移除冗余注释
- 修复测试用例中的密码工具类导入错误
97 lines
4.5 KiB
Python
97 lines
4.5 KiB
Python
from typing import Annotated
|
|
|
|
from fastapi import APIRouter, Body, Depends, Path, Query, Security
|
|
from fastapi.responses import JSONResponse
|
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
|
|
from app.common.response import ResponseSchema, SuccessResponse
|
|
from app.core.base_schema import AuthSchema, PageResultSchema, PaginationQueryParam
|
|
from app.core.dependencies import AuthPermission, db_getter, get_current_user
|
|
from app.core.router_class import OperationLogRoute
|
|
|
|
from .schema import (
|
|
LoginLogDetailOutSchema,
|
|
LoginLogOutSchema,
|
|
LoginLogQueryParam,
|
|
OperationLogDetailOutSchema,
|
|
OperationLogOutSchema,
|
|
OperationLogQueryParam,
|
|
)
|
|
from .service import LoginLogService, OperationLogService
|
|
|
|
LogRouter = APIRouter(route_class=OperationLogRoute, prefix="/log", tags=["日志管理"])
|
|
|
|
|
|
@LogRouter.get("/login/detail/{id}", summary="获取登录日志详情", response_model=ResponseSchema[LoginLogDetailOutSchema])
|
|
async def get_log_detail_controller(
|
|
auth: Annotated[AuthSchema, Security(AuthPermission(["module_system:login_log:query"]))],
|
|
db: Annotated[AsyncSession, Depends(db_getter)],
|
|
id: Annotated[int, Path(description="登录日志ID", ge=1)],
|
|
) -> JSONResponse:
|
|
result_dict = await LoginLogService(auth, db).detail(id=id)
|
|
return SuccessResponse(data=result_dict, msg="获取登录日志详情成功")
|
|
|
|
|
|
@LogRouter.get("/login/list", summary="查询登录日志列表", response_model=ResponseSchema[PageResultSchema[LoginLogOutSchema]])
|
|
async def get_log_list_controller(
|
|
auth: Annotated[AuthSchema, Security(AuthPermission(["module_system:login_log:query"]))],
|
|
db: Annotated[AsyncSession, Depends(db_getter)],
|
|
page: Annotated[PaginationQueryParam, Query(description="分页参数")],
|
|
search: Annotated[LoginLogQueryParam, Query(description="登录日志查询参数")],
|
|
) -> JSONResponse:
|
|
result_dict = await LoginLogService(auth, db).page(
|
|
page_no=page.page_no,
|
|
page_size=page.page_size,
|
|
search=search,
|
|
order_by=page.order_by,
|
|
)
|
|
return SuccessResponse(data=result_dict, msg="查询登录日志列表成功")
|
|
|
|
|
|
@LogRouter.delete("/login/delete", summary="删除登录日志", response_model=ResponseSchema)
|
|
async def delete_log_controller(
|
|
auth: Annotated[AuthSchema, Security(AuthPermission(["module_system:login_log:delete"]))],
|
|
db: Annotated[AsyncSession, Depends(db_getter)],
|
|
ids: Annotated[list[int], Body(description="ID列表")],
|
|
) -> JSONResponse:
|
|
await LoginLogService(auth, db).delete(ids=ids)
|
|
return SuccessResponse(msg="删除登录日志成功")
|
|
|
|
|
|
@LogRouter.get("/operation/detail/{id}", summary="获取操作日志详情", response_model=ResponseSchema[OperationLogDetailOutSchema], dependencies=[Security(AuthPermission(["module_system:log:query"]))])
|
|
async def get_operation_log_detail_controller(
|
|
auth: Annotated[AuthSchema, Depends(get_current_user)],
|
|
db: Annotated[AsyncSession, Depends(db_getter)],
|
|
id: Annotated[int, Path(description="操作日志ID", gt=0)],
|
|
) -> JSONResponse:
|
|
result_dict = await OperationLogService(auth, db).detail(id=id)
|
|
return SuccessResponse(data=result_dict, msg="获取操作日志详情成功")
|
|
|
|
|
|
@LogRouter.get(
|
|
"/operation/list", summary="获取操作日志列表", response_model=ResponseSchema[PageResultSchema[OperationLogOutSchema]], dependencies=[Security(AuthPermission(["module_system:log:query"]))],
|
|
)
|
|
async def get_operation_log_list_controller(
|
|
auth: Annotated[AuthSchema, Depends(get_current_user)],
|
|
db: Annotated[AsyncSession, Depends(db_getter)],
|
|
page: Annotated[PaginationQueryParam, Query(description="分页参数")],
|
|
search: Annotated[OperationLogQueryParam, Query(description="操作日志查询参数")],
|
|
) -> JSONResponse:
|
|
result_dict = await OperationLogService(auth, db).page(
|
|
page_no=page.page_no,
|
|
page_size=page.page_size,
|
|
search=search,
|
|
order_by=page.order_by,
|
|
)
|
|
return SuccessResponse(data=result_dict, msg="查询操作日志列表成功")
|
|
|
|
|
|
@LogRouter.delete("/operation/delete", summary="删除操作日志", response_model=ResponseSchema, dependencies=[Security(AuthPermission(["module_system:log:delete"]))])
|
|
async def delete_operation_log_controller(
|
|
auth: Annotated[AuthSchema, Depends(get_current_user)],
|
|
db: Annotated[AsyncSession, Depends(db_getter)],
|
|
ids: Annotated[list[int], Body(description="ID列表")],
|
|
) -> JSONResponse:
|
|
await OperationLogService(auth, db).delete(ids=ids)
|
|
return SuccessResponse(msg="删除操作日志成功")
|