mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-01 00:05:17 +00:00
发布v2.0.0分支
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
from typing import Optional, Literal
|
||||
from fastapi import Query
|
||||
|
||||
from app.core.validator import DateTimeStr
|
||||
|
||||
class MenuQueryParams:
|
||||
"""菜单管理查询参数"""
|
||||
@@ -14,7 +15,9 @@ class MenuQueryParams:
|
||||
component_path: Optional[str] = Query(None, description="组件路径"),
|
||||
type: Optional[Literal['M', 'C', 'F']] = Query(None, description="菜单类型(M目录 C菜单 F按钮)"),
|
||||
permission: Optional[str] = Query(None, description="权限标识"),
|
||||
available: Optional[bool] = Query(None, description="菜单状态(True正常 False停用)"),
|
||||
status: Optional[bool] = Query(None, description="菜单状态(True正常 False停用)"),
|
||||
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__()
|
||||
|
||||
@@ -26,4 +29,11 @@ class MenuQueryParams:
|
||||
|
||||
# 精确查询字段
|
||||
self.type = type
|
||||
self.available = available
|
||||
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))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user