refactor: 重构查询参数处理逻辑,统一搜索参数处理

- 移除各模块查询schema中的自定义model_validator,统一通过search_to_dict处理搜索参数
- 为需要的字段添加json_schema_extra标记查询操作类型
- 重构base_crud的条件解析逻辑,支持直接处理普通字符串、数字类型参数
- 重构base_schema中的公共查询参数校验逻辑,简化时间范围和创建更新人参数处理
- 修复菜单查询的异步懒加载问题,添加多级预加载
- 调整日志打印配置,关闭uvicorn.access重复日志
- 修复前端路由跳转路径错误
- 调整弹窗宽度适配内容
- 修复测试环境限流器未注册问题
- 清理无用的导入和废弃函数
This commit is contained in:
zhangtao
2026-07-16 01:19:03 +08:00
parent 3f7d5aa4b9
commit f74b5f277e
63 changed files with 217 additions and 490 deletions
@@ -32,7 +32,7 @@ async def get_param_list_controller(
auth: Annotated[AuthSchema, Security(AuthPermission(["module_system:param:query"]))],
db: Annotated[AsyncSession, Depends(db_getter)],
page: Annotated[PaginationQueryParam, Depends()],
search: Annotated[ParamsQueryParam, Query(description="参数查询参数")],
search: Annotated[ParamsQueryParam, Query()],
) -> JSONResponse:
result_dict = await ParamsService(auth, db).page(
page_no=page.page_no,
@@ -92,7 +92,7 @@ async def batch_set_status_controller(
async def export_param_list_controller(
auth: Annotated[AuthSchema, Security(AuthPermission(["module_system:param:export"]))],
db: Annotated[AsyncSession, Depends(db_getter)],
search: Annotated[ParamsQueryParam, Query(description="参数查询参数")],
search: Annotated[ParamsQueryParam, Query()],
) -> StreamingResponse:
result_dict_list = await ParamsService(auth, db).get_list(search=search)
export_data = [item.model_dump() for item in result_dict_list]
@@ -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
@@ -51,19 +50,7 @@ class ParamsQueryParam(BaseQueryParam, UserByQueryParam, TenantByQueryParam):
"""参数管理查询参数
"""
config_name: str | tuple[str, str] | None = Field(None, description="参数名称")
config_key: str | tuple[str, str] | None = Field(None, description="参数键名")
config_type: bool | tuple[str, bool] | None = Field(None, description="是否系统内置(True:是 False:否)")
status: int | tuple[str, int] | None = Field(None, ge=0, le=1, description="状态(0:启动 1:停用)")
@model_validator(mode="after")
def validate_query_params(self) -> "ParamsQueryParam":
if isinstance(self.config_name, str):
self.config_name = (QueueEnum.like.value, self.config_name)
if isinstance(self.config_key, str):
self.config_key = (QueueEnum.like.value, self.config_key)
if isinstance(self.config_type, bool):
self.config_type = (QueueEnum.eq.value, self.config_type)
if isinstance(self.status, int):
self.status = (QueueEnum.eq.value, self.status)
return self
config_name: str | None = Field(None, description="参数名称")
config_key: str | None = Field(None, description="参数键名", json_schema_extra={"q": "eq"})
config_type: bool | None = Field(None, description="是否系统内置(True:是 False:否)")
status: int | None = Field(None, ge=0, le=1, description="状态(0:启动 1:停用)")