mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-26 06:19:04 +00:00
refactor: 重构文件导入组件为通用组件 fix: 修复导出文件名统一问题 docs: 更新README添加二次开发教程 style: 统一系统管理页面的日期选择器实现 chore: 更新数据库迁移脚本和初始化数据 perf: 优化前端页面日期范围选择交互 test: 添加演示模块相关测试文件 build: 更新依赖项配置 ci: 调整CI/CD脚本配置
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
# -*- coding: utf-8 -*-
|
|
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
from fastapi import Query
|
|
|
|
from app.core.validator import DateTimeStr
|
|
|
|
class ExampleQueryParams:
|
|
"""示例查询参数"""
|
|
|
|
def __init__(
|
|
self,
|
|
name: Optional[str] = Query(None, description="名称"),
|
|
status: Optional[bool] = 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.name = ("like", name)
|
|
|
|
# 精确查询字段
|
|
self.creator_id = creator
|
|
self.status = status
|
|
|
|
# 时间范围查询
|
|
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))
|
|
|
|
|