- 从服务器拉取完整代码 - 按框架规范整理项目结构 - 配置 Drone CI 测试环境部署 - 包含后端(FastAPI)、前端(Vue3)、管理端 技术栈: Vue3 + TypeScript + FastAPI + MySQL
60 lines
2.0 KiB
Python
60 lines
2.0 KiB
Python
"""
|
||
系统日志 Schema
|
||
"""
|
||
from datetime import datetime
|
||
from typing import Optional
|
||
from pydantic import BaseModel, Field
|
||
|
||
|
||
class SystemLogBase(BaseModel):
|
||
"""系统日志基础Schema"""
|
||
level: str = Field(..., description="日志级别: debug, info, warning, error")
|
||
type: str = Field(..., description="日志类型: system, user, api, error, security")
|
||
user: Optional[str] = Field(None, description="操作用户")
|
||
user_id: Optional[int] = Field(None, description="用户ID")
|
||
ip: Optional[str] = Field(None, description="IP地址")
|
||
message: str = Field(..., description="日志消息")
|
||
user_agent: Optional[str] = Field(None, description="User Agent")
|
||
path: Optional[str] = Field(None, description="请求路径")
|
||
method: Optional[str] = Field(None, description="请求方法")
|
||
extra_data: Optional[str] = Field(None, description="额外数据(JSON格式)")
|
||
|
||
|
||
class SystemLogCreate(SystemLogBase):
|
||
"""创建系统日志Schema"""
|
||
pass
|
||
|
||
|
||
class SystemLogResponse(SystemLogBase):
|
||
"""系统日志响应Schema"""
|
||
id: int
|
||
created_at: datetime
|
||
updated_at: datetime
|
||
|
||
class Config:
|
||
from_attributes = True
|
||
|
||
|
||
class SystemLogQuery(BaseModel):
|
||
"""系统日志查询参数"""
|
||
level: Optional[str] = Field(None, description="日志级别筛选")
|
||
type: Optional[str] = Field(None, description="日志类型筛选")
|
||
user: Optional[str] = Field(None, description="用户筛选")
|
||
keyword: Optional[str] = Field(None, description="关键词搜索(搜索message字段)")
|
||
start_date: Optional[datetime] = Field(None, description="开始日期")
|
||
end_date: Optional[datetime] = Field(None, description="结束日期")
|
||
page: int = Field(1, ge=1, description="页码")
|
||
page_size: int = Field(20, ge=1, le=100, description="每页数量")
|
||
|
||
|
||
class SystemLogListResponse(BaseModel):
|
||
"""系统日志列表响应"""
|
||
items: list[SystemLogResponse]
|
||
total: int
|
||
page: int
|
||
page_size: int
|
||
total_pages: int
|
||
|
||
|
||
|