mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-14 05:00:10 +00:00
refactor: 重构查询参数处理逻辑,统一搜索参数处理
- 移除各模块查询schema中的自定义model_validator,统一通过search_to_dict处理搜索参数 - 为需要的字段添加json_schema_extra标记查询操作类型 - 重构base_crud的条件解析逻辑,支持直接处理普通字符串、数字类型参数 - 重构base_schema中的公共查询参数校验逻辑,简化时间范围和创建更新人参数处理 - 修复菜单查询的异步懒加载问题,添加多级预加载 - 调整日志打印配置,关闭uvicorn.access重复日志 - 修复前端路由跳转路径错误 - 调整弹窗宽度适配内容 - 修复测试环境限流器未注册问题 - 清理无用的导入和废弃函数
This commit is contained in:
@@ -21,7 +21,7 @@ GenRouter = APIRouter(route_class=OperationLogRoute, prefix="/gencode", tags=["
|
||||
async def gen_table_list_controller(
|
||||
auth: Annotated[AuthSchema, Security(AuthPermission(["module_generator:gencode:query"]))],
|
||||
page: Annotated[PaginationQueryParam, Depends()],
|
||||
search: Annotated[GenTableQueryParam, Query(description="查询参数")],
|
||||
search: Annotated[GenTableQueryParam, Query()],
|
||||
db: Annotated[AsyncSession, Depends(db_getter)],
|
||||
) -> JSONResponse:
|
||||
order_by = [{"created_time": "desc"}]
|
||||
@@ -40,7 +40,7 @@ async def gen_table_list_controller(
|
||||
async def get_gen_db_table_list_controller(
|
||||
auth: Annotated[AuthSchema, Security(AuthPermission(["module_generator:dblist:query"]))],
|
||||
page: Annotated[PaginationQueryParam, Depends()],
|
||||
search: Annotated[GenTableQueryParam, Query(description="查询参数")],
|
||||
search: Annotated[GenTableQueryParam, Query()],
|
||||
db: Annotated[AsyncSession, Depends(db_getter)],
|
||||
) -> JSONResponse:
|
||||
result_dict = await GenTableService(auth, db).get_gen_db_table_page(
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import re
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator
|
||||
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
||||
|
||||
from app.common.enums import QueueEnum
|
||||
from app.core.base_schema import BaseQueryParam, BaseSchema, TenantByQueryParam, TenantBySchema, UserByQueryParam, UserBySchema
|
||||
|
||||
|
||||
@@ -286,16 +285,8 @@ class GenTableQueryParam(BaseQueryParam, UserByQueryParam, TenantByQueryParam):
|
||||
- 空值将被忽略,不参与过滤。
|
||||
"""
|
||||
|
||||
table_name: str | tuple[str, str] | None = Field(None, description="表名称")
|
||||
table_comment: str | tuple[str, str] | None = Field(None, description="表注释")
|
||||
status: int | tuple[str, int] | None = Field(None, ge=0, le=1, description="状态(0:启动 1:停用)")
|
||||
table_name: str | None = Field(None, description="表名称")
|
||||
table_comment: str | None = Field(None, description="表注释")
|
||||
status: int | None = Field(None, ge=0, le=1, description="状态(0:启动 1:停用)")
|
||||
|
||||
|
||||
@model_validator(mode="after")
|
||||
def validate_query_params(self) -> "GenTableQueryParam":
|
||||
if isinstance(self.table_name, str):
|
||||
self.table_name = (QueueEnum.like.value, self.table_name)
|
||||
if isinstance(self.table_comment, str):
|
||||
self.table_comment = (QueueEnum.like.value, self.table_comment)
|
||||
if isinstance(self.status, int):
|
||||
self.status = (QueueEnum.eq.value, self.status)
|
||||
return self
|
||||
|
||||
Reference in New Issue
Block a user