luojunhui 1 месяц назад
Родитель
Сommit
56d616c6fc

+ 6 - 2
app/api/v1/routers/__init__.py → app/api/v1/endpoints/__init__.py

@@ -3,5 +3,9 @@ from .health import create_health_bp
 from .tasks import create_tasks_bp
 from .tokens import create_tokens_bp
 
-__all__ = ["create_abtest_bp", "create_health_bp", "create_tasks_bp", "create_tokens_bp"]
-
+__all__ = [
+    "create_abtest_bp",
+    "create_health_bp",
+    "create_tasks_bp",
+    "create_tokens_bp",
+]

+ 2 - 3
app/api/v1/routers/abtest.py → app/api/v1/endpoints/abtest.py

@@ -4,9 +4,9 @@ from pydantic import ValidationError
 from quart import Blueprint, jsonify
 
 from app.ab_test import GetCoverService
-from app.api.v1.deps import ApiDependencies
-from app.api.v1.utils import parse_json, validation_error_response
+from app.api.v1.utils import ApiDependencies
 from app.api.v1.utils import GetCoverRequest
+from app.api.v1.utils import parse_json, validation_error_response
 
 
 def create_abtest_bp(deps: ApiDependencies) -> Blueprint:
@@ -25,4 +25,3 @@ def create_abtest_bp(deps: ApiDependencies) -> Blueprint:
         return jsonify(result)
 
     return bp
-

+ 0 - 1
app/api/v1/routers/health.py → app/api/v1/endpoints/health.py

@@ -13,4 +13,3 @@ def create_health_bp() -> Blueprint:
         )
 
     return bp
-

+ 3 - 4
app/api/v1/routers/tasks.py → app/api/v1/endpoints/tasks.py

@@ -4,9 +4,9 @@ from pydantic import ValidationError
 from quart import Blueprint, jsonify
 
 from app.api.service import TaskManager, TaskScheduler
-from app.api.v1.deps import ApiDependencies
-from app.api.v1.utils import parse_json, validation_error_response
+from app.api.v1.utils import ApiDependencies
 from app.api.v1.utils import RunTaskRequest, TaskListRequest
+from app.api.v1.utils import parse_json, validation_error_response
 from app.infra.shared.tools import generate_task_trace_id
 
 
@@ -37,7 +37,6 @@ def create_tasks_bp(deps: ApiDependencies) -> Blueprint:
 
         manager = TaskManager(pool=deps.db, data=body, config=deps.config)
         result = await manager.list_tasks()
-        return jsonify({"code": 0, "message": "success", "data": result})
+        return jsonify(result)
 
     return bp
-

+ 2 - 3
app/api/v1/routers/tokens.py → app/api/v1/endpoints/tokens.py

@@ -4,9 +4,9 @@ from pydantic import ValidationError
 from quart import Blueprint, jsonify
 
 from app.api.service import GzhCookieManager
-from app.api.v1.deps import ApiDependencies
-from app.api.v1.utils import parse_json, validation_error_response
+from app.api.v1.utils import ApiDependencies
 from app.api.v1.utils import SaveTokenRequest
+from app.api.v1.utils import parse_json, validation_error_response
 
 
 def create_tokens_bp(deps: ApiDependencies) -> Blueprint:
@@ -25,4 +25,3 @@ def create_tokens_bp(deps: ApiDependencies) -> Blueprint:
         return jsonify(result)
 
     return bp
-

+ 1 - 3
app/api/v1/__init__.py → app/api/v1/routes/__init__.py

@@ -1,5 +1,3 @@
 from .routes import server_routes
 
-__all__ = [
-    "server_routes"
-]
+__all__ = ["server_routes"]

+ 2 - 2
app/api/v1/routes.py → app/api/v1/routes/routes.py

@@ -2,8 +2,8 @@ from __future__ import annotations
 
 from quart import Blueprint
 
-from app.api.v1.deps import ApiDependencies
-from app.api.v1.routers import (
+from app.api.v1.utils import ApiDependencies
+from app.api.v1.endpoints import (
     create_abtest_bp,
     create_health_bp,
     create_tasks_bp,

+ 2 - 1
app/api/v1/utils/__init__.py

@@ -1,5 +1,5 @@
 from ._utils import parse_json, validation_error_response
-
+from .deps import ApiDependencies
 from .schemas import RunTaskRequest, TaskListRequest, SaveTokenRequest, GetCoverRequest
 
 
@@ -10,4 +10,5 @@ __all__ = [
     "TaskListRequest",
     "SaveTokenRequest",
     "GetCoverRequest",
+    "ApiDependencies",
 ]

+ 0 - 1
app/api/v1/utils/_utils.py

@@ -23,4 +23,3 @@ async def parse_json(model: Type[T]) -> Tuple[T, Dict[str, Any]]:
 
 def validation_error_response(e: ValidationError) -> Tuple[Dict[str, Any], int]:
     return {"code": 400, "message": "invalid request body", "errors": e.errors()}, 400
-

+ 0 - 1
app/api/v1/deps.py → app/api/v1/utils/deps.py

@@ -14,4 +14,3 @@ class ApiDependencies:
     db: DatabaseManager
     log: LogService
     config: GlobalConfigSettings
-

+ 0 - 1
app/api/v1/utils/schemas.py

@@ -39,4 +39,3 @@ class SaveTokenRequest(BaseRequest):
     """GzhCookieManager 的请求体字段不固定,先保持兼容。"""
 
     token: Optional[str] = None
-

+ 1 - 1
app/core/config/settings/cold_start.py

@@ -7,7 +7,7 @@ class ColdStartConfig(BaseSettings):
     """冷启动配置"""
 
     # 分类映射
-    category_map: Dict[str, str] = Field(
+    cold_start_category_map: Dict[str, str] = Field(
         default_factory=lambda: {
             "知识科普": "20250813032110801233225",
             "国家大事": "20250813032845706844854",

+ 1 - 1
task_app.py

@@ -4,7 +4,7 @@ from quart import Quart
 
 from app.core.bootstrap import AppContext
 from app.core.dependency import ServerContainer
-from app.api.v1 import server_routes
+from app.api.v1.routes import server_routes
 
 logging.basicConfig(level=logging.INFO)