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
@@ -100,7 +100,7 @@ async def remove_job_controller(
async def get_job_log_list_controller(
auth: Annotated[AuthSchema, Security(AuthPermission(["module_task:cronjob:job:query"]))],
page: Annotated[PaginationQueryParam, Depends()],
search: Annotated[JobQueryParam, Query(description="查询参数")],
search: Annotated[JobQueryParam, Query()],
db: Annotated[AsyncSession, Depends(db_getter)],
) -> JSONResponse:
result_dict = await JobService(auth, db).get_job_log_page(
@@ -3,10 +3,8 @@ from pydantic import (
ConfigDict,
Field,
field_validator,
model_validator,
)
from app.common.enums import QueueEnum
from app.core.base_schema import BaseQueryParam, BaseSchema, TenantByQueryParam, TenantBySchema, UserByQueryParam, UserBySchema
@@ -61,19 +59,9 @@ class JobOutSchema(JobCreateSchema, BaseSchema, UserBySchema, TenantBySchema):
class JobQueryParam(BaseQueryParam, UserByQueryParam, TenantByQueryParam):
"""执行日志查询参数"""
job_id: str | tuple[str, str] | None = Field(None, description="任务ID")
job_name: str | tuple[str, str] | None = Field(None, description="任务名称")
trigger_type: str | tuple[str, str] | None = Field(None, description="触发方式")
status: int | tuple[str, int] | None = Field(None, ge=0, le=5, description="执行状态(0:待执行 1:执行中 2:成功 3:失败 4:超时 5:已取消)")
job_id: str | None = Field(None, description="任务ID")
job_name: str | None = Field(None, description="任务名称")
trigger_type: str | None = Field(None, description="触发方式", json_schema_extra={"q": "eq"})
status: int | None = Field(None, ge=0, le=5, description="执行状态(0:待执行 1:执行中 2:成功 3:失败 4:超时 5:已取消)")
@model_validator(mode="after")
def validate_query_params(self) -> "JobQueryParam":
if self.job_id is not None:
self.job_id = (QueueEnum.eq.value, str(self.job_id))
if isinstance(self.job_name, str):
self.job_name = (QueueEnum.like.value, self.job_name)
if isinstance(self.trigger_type, str):
self.trigger_type = (QueueEnum.eq.value, self.trigger_type)
if isinstance(self.status, int):
self.status = (QueueEnum.eq.value, self.status)
return self
@@ -40,7 +40,7 @@ async def get_obj_detail_controller(
async def get_obj_list_controller(
auth: Annotated[AuthSchema, Security(AuthPermission(["module_task:cronjob:node:query"]))],
page: Annotated[PaginationQueryParam, Depends()],
search: Annotated[NodeQueryParam, Query(description="查询参数")],
search: Annotated[NodeQueryParam, Query()],
db: Annotated[AsyncSession, Depends(db_getter)],
) -> JSONResponse:
service = NodeService(auth, db)
@@ -8,7 +8,6 @@ from pydantic import (
model_validator,
)
from app.common.enums import QueueEnum
from app.core.base_schema import BaseQueryParam, BaseSchema, TenantByQueryParam, TenantBySchema, UserByQueryParam, UserBySchema
from app.core.validator import datetime_validator
@@ -72,16 +71,8 @@ class NodeOutSchema(NodeCreateSchema, BaseSchema, UserBySchema, TenantBySchema):
class NodeQueryParam(BaseQueryParam, UserByQueryParam, TenantByQueryParam):
"""节点查询参数"""
name: str | tuple[str, str] | None = Field(None, description="节点名称")
status: int | tuple[str, int] | None = Field(None, ge=0, le=1, description="状态(0:启动 1:停用)")
@model_validator(mode="after")
def validate_query_params(self) -> "NodeQueryParam":
if isinstance(self.name, str):
self.name = (QueueEnum.like.value, self.name)
if isinstance(self.status, int):
self.status = (QueueEnum.eq.value, self.status)
return self
name: str | None = Field(None, description="节点名称")
status: int | None = Field(None, ge=0, le=1, description="状态(0:启动 1:停用)")
class NodeExecuteSchema(BaseModel):