feature: 数据配比增加通过更新时间来配置 (#95)

* feature: 数据配比增加通过更新时间来配置

* fix: 修复配比时间参数传递的问题
This commit is contained in:
hefanli
2025-11-20 18:50:51 +08:00
committed by GitHub
parent 955ffff6cd
commit cddfe9b149
10 changed files with 458 additions and 595 deletions

View File

@@ -1,11 +1,13 @@
from .common import (
BaseResponseModel,
StandardResponse,
PaginatedData
PaginatedData,
TaskStatus
)
__all__ = [
"BaseResponseModel",
"StandardResponse",
"PaginatedData"
]
"PaginatedData",
"TaskStatus"
]

View File

@@ -1,8 +1,9 @@
"""
通用响应模型
"""
from typing import Generic, TypeVar, Optional, List, Type
from typing import Generic, TypeVar, List
from pydantic import BaseModel, Field
from enum import Enum
# 定义泛型类型变量
T = TypeVar('T')
@@ -16,7 +17,7 @@ def to_camel(string: str) -> str:
class BaseResponseModel(BaseModel):
"""基础响应模型,启用别名生成器"""
class Config:
populate_by_name = True
alias_generator = to_camel
@@ -24,7 +25,7 @@ class BaseResponseModel(BaseModel):
class StandardResponse(BaseResponseModel, Generic[T]):
"""
标准API响应格式
所有API端点应返回此格式,确保响应的一致性
"""
code: int = Field(..., description="HTTP状态码")
@@ -42,3 +43,9 @@ class PaginatedData(BaseResponseModel, Generic[T]):
total_elements: int = Field(..., description="总条数")
total_pages: int = Field(..., description="总页数")
content: List[T] = Field(..., description="当前页数据")
class TaskStatus(Enum):
PENDING = "PENDING"
RUNNING = "RUNNING"
COMPLETED = "COMPLETED"
FAILED = "FAILED"