mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 20:55:14 +00:00
- 修改alembic配置以使用异步数据库URI和更新Base类引用 - 新增数据库Schema优化脚本,统一字段长度,添加索引,规范外键策略 - 重构API路由管理,按模块类型分组并统一前缀 - 删除示例、监控及系统各子模块的模型定义,减少冗余代码 - 将mcp_server相关代码迁移到module_ai模块下,规范模块目录结构 - 迁移example控制器至module_application.application模块,并重命名相关服务和参数名 - 优化示例控制器中的依赖和响应结构,统一命名规范
47 lines
1.4 KiB
Python
47 lines
1.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from typing import Dict, List, Optional, Sequence
|
|
|
|
from app.core.base_crud import CRUDBase
|
|
from ..auth.schema import AuthSchema
|
|
from .model import OperationLogModel
|
|
from .schema import OperationLogCreateSchema
|
|
|
|
|
|
class OperationLogCRUD(CRUDBase[OperationLogModel, OperationLogCreateSchema, None]):
|
|
"""操作日志数据层"""
|
|
|
|
def __init__(self, auth: AuthSchema) -> None:
|
|
"""初始化操作日志CRUD"""
|
|
self.auth = auth
|
|
super().__init__(model=OperationLogModel, auth=auth)
|
|
|
|
async def create_crud(self, data: OperationLogCreateSchema) -> Optional[OperationLogModel]:
|
|
"""
|
|
创建操作日志记录
|
|
|
|
:param data: 操作日志创建模型
|
|
:return: 操作日志记录
|
|
"""
|
|
return await self.create(data=data.model_dump())
|
|
|
|
async def get_by_id_crud(self, id: int) -> Optional[OperationLogModel]:
|
|
"""
|
|
根据ID获取操作日志详情
|
|
|
|
:param id: 操作日志ID
|
|
:return: 操作日志记录
|
|
"""
|
|
return await self.get(id=id)
|
|
|
|
async def get_list_crud(self, search: Dict = None, order_by: List[Dict[str, str]] = None) -> Sequence[OperationLogModel]:
|
|
"""
|
|
获取操作日志列表
|
|
|
|
:param search: 搜索条件
|
|
:param order_by: 排序字段
|
|
:return: 操作日志列表
|
|
"""
|
|
return await self.list(search=search, order_by=order_by)
|
|
|