mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-25 21:57:48 +00:00
refactor(menu): 重构菜单类型枚举和权限数据结构 fix(log): 修复日志类型显示和查询问题 style(common): 重命名部门树格式化函数为通用树格式化函数 perf(store): 移除控制台日志输出 docs(tsconfig): 添加Vite客户端类型注释 chore(package): 调整依赖项顺序
40 lines
1.7 KiB
Python
40 lines
1.7 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from typing import Optional
|
|
from fastapi import Query
|
|
from datetime import datetime
|
|
|
|
from app.core.validator import DateTimeStr
|
|
|
|
class OperationLogQueryParams:
|
|
"""操作日志查询参数"""
|
|
|
|
def __init__(
|
|
self,
|
|
type: Optional[int] = Query(None, description="日志类型(1:登录日志, 2:操作日志)"),
|
|
request_path: Optional[str] = Query(None, description="请求路径"),
|
|
request_method: Optional[str] = Query(None, description="请求方法"),
|
|
request_ip: Optional[str] = Query(None, description="请求IP"),
|
|
response_code: Optional[int] = Query(None, description="响应状态码"),
|
|
creator: Optional[int] = Query(None, description="创建人"),
|
|
start_time: Optional[DateTimeStr] = Query(None, description="开始时间", example="2023-01-01 00:00:00"),
|
|
end_time: Optional[DateTimeStr] = Query(None, description="结束时间", example="2023-12-31 23:59:59"),
|
|
) -> None:
|
|
super().__init__()
|
|
|
|
# 模糊查询字段
|
|
self.request_path = ("like", f"%{request_path}%") if request_path else None
|
|
|
|
# 精确查询字段
|
|
self.creator_id = creator
|
|
self.request_method = request_method
|
|
self.request_ip = request_ip
|
|
self.response_code = response_code
|
|
self.type = type
|
|
|
|
# 时间范围查询
|
|
if start_time and end_time:
|
|
start_datetime = datetime.strptime(str(start_time), '%Y-%m-%d %H:%M:%S')
|
|
end_datetime = datetime.strptime(str(end_time), '%Y-%m-%d %H:%M:%S')
|
|
self.created_at = ("between", (start_datetime, end_datetime))
|