feat:[FL-139][ATP模型管理要分页]

- 在atp_model_service.py的list_models函数添加limit和offset参数
- 在atp_models.py的get_atp_model_list端点添加limit和offset查询参数
- 默认limit=100,offset=0,limit最大值500
- 保持向后兼容,不传参数时使用默认值

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: multica-agent <github@multica.ai>
This commit is contained in:
chengkai3
2026-06-15 22:27:27 +08:00
parent 598c281e8a
commit 60d5d8e305
2 changed files with 10 additions and 2 deletions
+3 -1
View File
@@ -52,10 +52,12 @@ def get_atp_engine_status_endpoint(
def get_atp_model_list(
keyword: str | None = Query(default=None),
status_filter: str | None = Query(default=None, alias="status"),
limit: int = Query(default=100, ge=1, le=500),
offset: int = Query(default=0, ge=0),
_: CurrentUser = Depends(require_any_permission("atp.read", "atp.run", "atp.manage")),
db: Session = Depends(get_db),
) -> AtpModelListResponse:
return list_models(db, keyword=keyword, status_filter=status_filter)
return list_models(db, keyword=keyword, status_filter=status_filter, limit=limit, offset=offset)
@router.post("", response_model=AtpModelSummary)
+7 -1
View File
@@ -318,6 +318,8 @@ def list_models(
*,
keyword: str | None,
status_filter: str | None,
limit: int = 100,
offset: int = 0,
) -> AtpModelListResponse:
stmt = select(AtpModel)
total_stmt = select(func.count()).select_from(AtpModel)
@@ -337,7 +339,11 @@ def list_models(
total_stmt = total_stmt.where(AtpModel.status == normalized_status)
total = int(db.scalar(total_stmt) or 0)
items = db.execute(stmt.order_by(AtpModel.update_date.desc(), AtpModel.code.asc())).scalars().all()
items = db.execute(
stmt.order_by(AtpModel.update_date.desc(), AtpModel.code.asc())
.offset(offset)
.limit(limit)
).scalars().all()
model_ids = [item.id for item in items]
version_count_map = _load_model_version_count_map(db, model_ids)