mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-02 00:27:16 +00:00
refactor: 重构查询参数模块,将param.py合并到schema.py中
feat: 为模型添加租户配额字段和字典表关联关系 fix: 修复部门树查询未应用租户隔离的问题 perf: 优化操作日志中间件的拦截逻辑和日志记录 style: 清理无用导入和重复代码 test: 添加基础测试文件 docs: 更新模型注释和字段说明
This commit is contained in:
@@ -12,13 +12,12 @@ from app.core.router_class import OperationLogRoute
|
||||
from app.core.base_schema import BatchSetAvailable
|
||||
from app.core.logger import log
|
||||
|
||||
|
||||
from app.api.v1.module_system.auth.schema import AuthSchema
|
||||
from .param import DemoQueryParam
|
||||
from .service import DemoService
|
||||
from .schema import (
|
||||
DemoCreateSchema,
|
||||
DemoUpdateSchema
|
||||
DemoUpdateSchema,
|
||||
DemoQueryParam
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from typing import Optional
|
||||
from fastapi import Query
|
||||
|
||||
from app.core.validator import DateTimeStr
|
||||
|
||||
|
||||
class DemoQueryParam:
|
||||
"""示例查询参数"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
name: Optional[str] = Query(None, description="名称"),
|
||||
status: Optional[bool] = Query(None, description="是否启用"),
|
||||
created_id: Optional[int] = Query(None, description="创建人"),
|
||||
start_time: Optional[DateTimeStr] = Query(None, description="开始时间", example="2025-01-01 00:00:00"),
|
||||
end_time: Optional[DateTimeStr] = Query(None, description="结束时间", example="2025-12-31 23:59:59"),
|
||||
) -> None:
|
||||
|
||||
# 模糊查询字段
|
||||
self.name = ("like", name)
|
||||
|
||||
# 精确查询字段
|
||||
self.created_id = created_id
|
||||
self.status = status
|
||||
|
||||
# 时间范围查询
|
||||
if start_time and end_time:
|
||||
self.created_time = ("between", (start_time, end_time))
|
||||
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
|
||||
from fastapi import Query
|
||||
|
||||
from app.core.base_schema import BaseSchema
|
||||
from app.core.validator import DateTimeStr
|
||||
from app.core.base_schema import BaseSchema, UserBySchema, TenantSchema, CustomerSchema
|
||||
|
||||
|
||||
class DemoCreateSchema(BaseModel):
|
||||
@@ -43,6 +45,32 @@ class DemoUpdateSchema(DemoCreateSchema):
|
||||
...
|
||||
|
||||
|
||||
class DemoOutSchema(DemoCreateSchema, BaseSchema):
|
||||
class DemoOutSchema(DemoCreateSchema, BaseSchema, UserBySchema, TenantSchema, CustomerSchema):
|
||||
"""响应模型"""
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class DemoQueryParam:
|
||||
"""示例查询参数"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
name: Optional[str] = Query(None, description="名称"),
|
||||
status: Optional[bool] = Query(None, description="是否启用"),
|
||||
created_id: Optional[int] = Query(None, description="创建人"),
|
||||
start_time: Optional[DateTimeStr] = Query(None, description="开始时间", example="2025-01-01 00:00:00"),
|
||||
end_time: Optional[DateTimeStr] = Query(None, description="结束时间", example="2025-12-31 23:59:59"),
|
||||
) -> None:
|
||||
|
||||
# 模糊查询字段
|
||||
self.name = ("like", name)
|
||||
|
||||
# 精确查询字段
|
||||
self.created_id = created_id
|
||||
self.status = status
|
||||
|
||||
# 时间范围查询
|
||||
if start_time and end_time:
|
||||
self.created_time = ("between", (start_time, end_time))
|
||||
|
||||
|
||||
|
||||
@@ -11,8 +11,7 @@ from app.utils.excel_util import ExcelUtil
|
||||
from app.core.logger import log
|
||||
|
||||
from app.api.v1.module_system.auth.schema import AuthSchema
|
||||
from .schema import DemoCreateSchema, DemoUpdateSchema, DemoOutSchema
|
||||
from .param import DemoQueryParam
|
||||
from .schema import DemoCreateSchema, DemoUpdateSchema, DemoOutSchema, DemoQueryParam
|
||||
from .crud import DemoCRUD
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user