整理代码
This commit is contained in:
@@ -17,10 +17,7 @@ class AttachmentApiHandler(BaseApiHandler):
|
||||
"""附件 API Handler"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "attachment"
|
||||
self._node_class = AttachmentSyncNode
|
||||
self._schema = AttachmentSchema
|
||||
super().__init__(node_class=AttachmentSyncNode, schema=AttachmentSchema)
|
||||
|
||||
async def load(self) -> List[SyncNode]:
|
||||
"""加载附件列表(依赖 Project)"""
|
||||
|
||||
@@ -9,4 +9,4 @@ from .sync_node import AttachmentSyncNode
|
||||
class AttachmentJsonlHandler(BaseJsonlHandler):
|
||||
"""附件 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "attachment", AttachmentSyncNode, Dict[str, Any])
|
||||
super().__init__(datasource, AttachmentSyncNode, schema=Dict[str, Any])
|
||||
|
||||
@@ -6,7 +6,7 @@ Company API Handler (只读)
|
||||
- 不支持创建/更新/删除
|
||||
"""
|
||||
|
||||
from typing import List, Dict, Any
|
||||
from typing import List
|
||||
from ...datasource.api.handler import BaseApiHandler
|
||||
from ...datasource.task_result import TaskResult
|
||||
from ...common.sync_node import SyncNode
|
||||
@@ -18,10 +18,7 @@ class CompanyApiHandler(BaseApiHandler):
|
||||
"""公司 API Handler (只读)"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "company"
|
||||
self._node_class = CompanySyncNode
|
||||
self._schema = CompanyResponse
|
||||
super().__init__(node_class=CompanySyncNode, schema=CompanyResponse)
|
||||
|
||||
async def load(self) -> List[SyncNode]:
|
||||
"""加载公司列表(支持分页)"""
|
||||
@@ -85,10 +82,6 @@ class CompanyApiHandler(BaseApiHandler):
|
||||
"""轮询异步任务状态(占位)"""
|
||||
return await super().poll_tasks(task_ids)
|
||||
|
||||
def _create_node(self, data: Dict[str, Any]) -> SyncNode:
|
||||
return self._create_basic_node(data, depend_ids=[])
|
||||
|
||||
|
||||
# ========== 静态 API 函数 ==========
|
||||
|
||||
async def api_get_company_list(client, page: int = 1, page_size: int = 100) -> tuple[List[CompanyResponse], int]:
|
||||
|
||||
@@ -7,5 +7,5 @@ from schemas.company.company import CompanyResponse
|
||||
class CompanyJsonlHandler(BaseJsonlHandler):
|
||||
"""公司 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "company", CompanySyncNode, CompanyResponse)
|
||||
super().__init__(datasource, CompanySyncNode, schema=CompanyResponse)
|
||||
|
||||
|
||||
@@ -28,10 +28,7 @@ class ConstructionTaskApiHandler(BaseApiHandler):
|
||||
"""施工任务 API Handler"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "construction_task"
|
||||
self._node_class = ConstructionTaskSyncNode
|
||||
self._schema = ConstructionResponse
|
||||
super().__init__(node_class=ConstructionTaskSyncNode, schema=ConstructionResponse)
|
||||
self.update_schemas = [ConstructionCreate, ConstructionUpdate, ConstructionPlanUpdate]
|
||||
|
||||
async def load(self) -> List[SyncNode]:
|
||||
|
||||
@@ -7,4 +7,4 @@ from schemas.construction.construction import ConstructionResponse
|
||||
class ConstructionTaskJsonlHandler(BaseJsonlHandler):
|
||||
"""施工任务 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "construction_task", ConstructionTaskSyncNode, ConstructionResponse)
|
||||
super().__init__(datasource, ConstructionTaskSyncNode, schema=ConstructionResponse)
|
||||
|
||||
@@ -24,10 +24,7 @@ class ConstructionTaskDetailApiHandler(BaseApiHandler):
|
||||
"""施工明细 API Handler"""
|
||||
|
||||
def __init__(self, **handler_config: Any):
|
||||
super().__init__(**handler_config)
|
||||
self._node_type = "construction_task_detail"
|
||||
self._node_class = ConstructionTaskDetailSyncNode
|
||||
self._schema = ConstructionDetailResponse
|
||||
super().__init__(node_class=ConstructionTaskDetailSyncNode, schema=ConstructionDetailResponse, **handler_config)
|
||||
self.update_schemas = [ConstructionDetailCreate, ConstructionDetailUpdate]
|
||||
|
||||
def _use_aggregate_load(self) -> bool:
|
||||
|
||||
@@ -9,4 +9,4 @@ from schemas.construction.construction_detail import ConstructionDetailResponse
|
||||
class ConstructionTaskDetailJsonlHandler(BaseJsonlHandler):
|
||||
"""施工任务明细 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "construction_task_detail", ConstructionTaskDetailSyncNode, ConstructionDetailResponse)
|
||||
super().__init__(datasource, ConstructionTaskDetailSyncNode, schema=ConstructionDetailResponse)
|
||||
|
||||
@@ -101,10 +101,7 @@ class ContractApiHandler(BaseApiHandler):
|
||||
"""合同 API Handler"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "contract"
|
||||
self._node_class = ContractSyncNode
|
||||
self._schema = ContractResponse
|
||||
super().__init__(node_class=ContractSyncNode, schema=ContractResponse)
|
||||
self.update_schemas = [ContractCreate, ContractUpdate]
|
||||
|
||||
# ========== Handler 接口实现 ==========
|
||||
|
||||
@@ -9,6 +9,6 @@ from schemas.contract.contract import ContractResponse
|
||||
class ContractJsonlHandler(BaseJsonlHandler):
|
||||
"""合同 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "contract", ContractSyncNode, ContractResponse)
|
||||
super().__init__(datasource, ContractSyncNode, schema=ContractResponse)
|
||||
|
||||
|
||||
|
||||
@@ -24,11 +24,7 @@ class ContractChangeApiHandler(BaseApiHandler):
|
||||
"""合同变更 API Handler"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "contract_change"
|
||||
self._node_class = ContractChangeSyncNode
|
||||
# TODO: ContractChangeResponse schema in schemas/project_extensions/contract_change.py is missing 'project_id'
|
||||
self._schema = ContractChangeResponse
|
||||
super().__init__(node_class=ContractChangeSyncNode, schema=ContractChangeResponse)
|
||||
|
||||
async def load(self) -> List[SyncNode]:
|
||||
"""加载合同变更数据"""
|
||||
|
||||
@@ -7,4 +7,4 @@ from schemas.project_extensions.contract_change import ContractChangeResponse
|
||||
class ContractChangeJsonlHandler(BaseJsonlHandler):
|
||||
"""合同变更 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "contract_change", ContractChangeSyncNode, ContractChangeResponse)
|
||||
super().__init__(datasource, ContractChangeSyncNode, schema=ContractChangeResponse)
|
||||
|
||||
@@ -28,10 +28,7 @@ class ContractSettlementApiHandler(BaseApiHandler):
|
||||
"""合同结算 API Handler"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "contract_settlement"
|
||||
self._node_class = ContractSettlementSyncNode
|
||||
self._schema = ContractSettlementResponse
|
||||
super().__init__(node_class=ContractSettlementSyncNode, schema=ContractSettlementResponse)
|
||||
self.update_schemas = [ContractSettlementCreate, ContractSettlementUpdate, ContractSettlementPlanUpdate]
|
||||
|
||||
async def load(self) -> List[SyncNode]:
|
||||
|
||||
@@ -7,4 +7,4 @@ from schemas.contract_settlement.contract_settlement import ContractSettlementRe
|
||||
class ContractSettlementJsonlHandler(BaseJsonlHandler):
|
||||
"""合同结算 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "contract_settlement", ContractSettlementSyncNode, ContractSettlementResponse)
|
||||
super().__init__(datasource, ContractSettlementSyncNode, schema=ContractSettlementResponse)
|
||||
|
||||
@@ -24,10 +24,7 @@ class ContractSettlementDetailApiHandler(BaseApiHandler):
|
||||
"""合同结算明细 API Handler"""
|
||||
|
||||
def __init__(self, **handler_config: Any):
|
||||
super().__init__(**handler_config)
|
||||
self._node_type = "contract_settlement_detail"
|
||||
self._node_class = ContractSettlementDetailSyncNode
|
||||
self._schema = ContractSettlementDetailResponse
|
||||
super().__init__(node_class=ContractSettlementDetailSyncNode, schema=ContractSettlementDetailResponse, **handler_config)
|
||||
self.update_schemas = [ContractSettlementDetailCreate, ContractSettlementDetailUpdate]
|
||||
|
||||
def _use_aggregate_load(self) -> bool:
|
||||
|
||||
@@ -9,4 +9,4 @@ from schemas.contract_settlement.contract_settlement_detail import ContractSettl
|
||||
class ContractSettlementDetailJsonlHandler(BaseJsonlHandler):
|
||||
"""合同结算明细 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "contract_settlement_detail", ContractSettlementDetailSyncNode, ContractSettlementDetailResponse)
|
||||
super().__init__(datasource, ContractSettlementDetailSyncNode, schema=ContractSettlementDetailResponse)
|
||||
|
||||
@@ -31,10 +31,7 @@ class LarApiHandler(BaseApiHandler):
|
||||
"""移民征地 API Handler"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "lar"
|
||||
self._node_class = LarSyncNode
|
||||
self._schema = LarDetailSchema
|
||||
super().__init__(node_class=LarSyncNode, schema=LarDetailSchema)
|
||||
|
||||
async def load(self) -> List[SyncNode]:
|
||||
"""
|
||||
|
||||
@@ -7,4 +7,4 @@ from schemas.project_extensions.lar import LarDetailSchema
|
||||
class LarJsonlHandler(BaseJsonlHandler):
|
||||
"""移民征地 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "lar", LarSyncNode, LarDetailSchema)
|
||||
super().__init__(datasource, LarSyncNode, schema=LarDetailSchema)
|
||||
|
||||
@@ -28,10 +28,7 @@ class LarChangeApiHandler(BaseApiHandler):
|
||||
"""移民变更 API Handler"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "lar_change"
|
||||
self._node_class = LarChangeSyncNode
|
||||
self._schema = LarChangeDetailSchema
|
||||
super().__init__(node_class=LarChangeSyncNode, schema=LarChangeDetailSchema)
|
||||
|
||||
async def load(self) -> List[SyncNode]:
|
||||
"""
|
||||
|
||||
@@ -9,4 +9,4 @@ class LarChangeJsonlHandler(BaseJsonlHandler):
|
||||
"""LAR Change (移民变更) JSONL 数据处理器"""
|
||||
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "lar_change", LarChangeSyncNode, LarChangeDetailSchema)
|
||||
super().__init__(datasource, LarChangeSyncNode, schema=LarChangeDetailSchema)
|
||||
|
||||
@@ -23,10 +23,7 @@ class MaterialApiHandler(BaseApiHandler):
|
||||
"""物资 API Handler"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "material"
|
||||
self._node_class = MaterialSyncNode
|
||||
self._schema = MaterialResponse
|
||||
super().__init__(node_class=MaterialSyncNode, schema=MaterialResponse)
|
||||
self.update_schemas = [MaterialCreate, MaterialUpdate, MaterialPlanUpdate]
|
||||
|
||||
async def load(self) -> List[SyncNode]:
|
||||
|
||||
@@ -7,4 +7,4 @@ from schemas.material.material import MaterialResponse
|
||||
class MaterialJsonlHandler(BaseJsonlHandler):
|
||||
"""物资 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "material", MaterialSyncNode, MaterialResponse)
|
||||
super().__init__(datasource, MaterialSyncNode, schema=MaterialResponse)
|
||||
|
||||
@@ -39,10 +39,7 @@ class MaterialDetailApiHandler(BaseApiHandler):
|
||||
"""物资明细 API Handler"""
|
||||
|
||||
def __init__(self, **handler_config: Any):
|
||||
super().__init__(**handler_config)
|
||||
self._node_type = "material_detail"
|
||||
self._node_class = MaterialDetailSyncNode
|
||||
self._schema = MaterialDetailResponse
|
||||
super().__init__(node_class=MaterialDetailSyncNode, schema=MaterialDetailResponse, **handler_config)
|
||||
self.update_schemas = [MaterialDetailCreate, MaterialDetailUpdate]
|
||||
|
||||
def _use_aggregate_load(self) -> bool:
|
||||
|
||||
@@ -9,4 +9,4 @@ from schemas.material.material_detail import MaterialDetailResponse
|
||||
class MaterialDetailJsonlHandler(BaseJsonlHandler):
|
||||
"""物资明细 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "material_detail", MaterialDetailSyncNode, MaterialDetailResponse)
|
||||
super().__init__(datasource, MaterialDetailSyncNode, schema=MaterialDetailResponse)
|
||||
|
||||
@@ -19,10 +19,7 @@ class PersonnelApiHandler(BaseApiHandler):
|
||||
"""人员 API Handler"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "personnel"
|
||||
self._node_class = PersonnelSyncNode
|
||||
self._schema = PowerResponse
|
||||
super().__init__(node_class=PersonnelSyncNode, schema=PowerResponse)
|
||||
self.update_schemas = [PowerCreate, PowerUpdate, PowerPlanUpdate]
|
||||
|
||||
async def load(self) -> List[SyncNode]:
|
||||
|
||||
@@ -7,4 +7,4 @@ from schemas.power.power import PowerResponse
|
||||
class PersonnelJsonlHandler(BaseJsonlHandler):
|
||||
"""人员 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "personnel", PersonnelSyncNode, PowerResponse)
|
||||
super().__init__(datasource, PersonnelSyncNode, schema=PowerResponse)
|
||||
|
||||
@@ -20,10 +20,7 @@ class PersonnelDetailApiHandler(BaseApiHandler):
|
||||
"""人员明细 API Handler"""
|
||||
|
||||
def __init__(self, **handler_config: Any):
|
||||
super().__init__(**handler_config)
|
||||
self._node_type = "personnel_detail"
|
||||
self._node_class = PersonnelDetailSyncNode
|
||||
self._schema = PowerDetail
|
||||
super().__init__(node_class=PersonnelDetailSyncNode, schema=PowerDetail, **handler_config)
|
||||
self.update_schemas = [PowerDetailCreate, PowerDetailUpdate]
|
||||
|
||||
def _use_aggregate_load(self) -> bool:
|
||||
|
||||
@@ -9,4 +9,4 @@ from schemas.power.power_detail import PowerDetail
|
||||
class PersonnelDetailJsonlHandler(BaseJsonlHandler):
|
||||
"""人员明细 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "personnel_detail", PersonnelDetailSyncNode, PowerDetail)
|
||||
super().__init__(datasource, PersonnelDetailSyncNode, schema=PowerDetail)
|
||||
|
||||
@@ -10,7 +10,7 @@ PUT:
|
||||
- /preparation - 更新里程碑数据
|
||||
"""
|
||||
|
||||
from typing import List, Dict, Any
|
||||
from typing import List, Dict
|
||||
from ...datasource.api.handler import BaseApiHandler
|
||||
from ...datasource.task_result import TaskResult
|
||||
from ...common.sync_node import SyncNode
|
||||
@@ -23,10 +23,7 @@ class PreparationApiHandler(BaseApiHandler):
|
||||
"""里程碑 API Handler"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "preparation"
|
||||
self._node_class = PreparationSyncNode
|
||||
self._schema = PreparationDetail
|
||||
super().__init__(node_class=PreparationSyncNode, schema=PreparationDetail)
|
||||
self.update_schemas = [PostPreparation]
|
||||
|
||||
async def load(self) -> List[SyncNode]:
|
||||
@@ -141,10 +138,6 @@ class PreparationApiHandler(BaseApiHandler):
|
||||
for node in nodes
|
||||
]
|
||||
|
||||
def _create_node(self, data: Dict[str, Any]) -> SyncNode:
|
||||
return self._create_basic_node(data, depend_ids=[])
|
||||
|
||||
|
||||
# ========== 静态 API 函数 ==========
|
||||
|
||||
async def api_update_preparation(
|
||||
|
||||
@@ -8,4 +8,4 @@ from schemas.project_extensions.preparation import PreparationDetail
|
||||
class PreparationJsonlHandler(BaseJsonlHandler):
|
||||
"""里程碑 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "preparation", PreparationSyncNode, PreparationDetail)
|
||||
super().__init__(datasource, PreparationSyncNode, schema=PreparationDetail)
|
||||
|
||||
@@ -23,10 +23,7 @@ class ProductionApiHandler(BaseApiHandler):
|
||||
"""投产节点 API Handler"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "production"
|
||||
self._node_class = ProductionSyncNode
|
||||
self._schema = ProductionDetail
|
||||
super().__init__(node_class=ProductionSyncNode, schema=ProductionDetail)
|
||||
self.update_schemas = [PostProduction]
|
||||
|
||||
async def load(self) -> List[SyncNode]:
|
||||
|
||||
@@ -7,4 +7,4 @@ from schemas.project_extensions.production import ProductionDetail
|
||||
class ProductionJsonlHandler(BaseJsonlHandler):
|
||||
"""投产节点 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "production", ProductionSyncNode, ProductionDetail)
|
||||
super().__init__(datasource, ProductionSyncNode, schema=ProductionDetail)
|
||||
|
||||
@@ -73,10 +73,7 @@ class ProjectApiHandler(BaseApiHandler):
|
||||
_all_info_cache: Dict[str, Dict[str, Any]] = {}
|
||||
|
||||
def __init__(self, **handler_config: Any):
|
||||
super().__init__(**handler_config)
|
||||
self._node_type = "project"
|
||||
self._node_class = ProjectSyncNode
|
||||
self._schema = ProjectResponseBase
|
||||
super().__init__(node_class=ProjectSyncNode, schema=ProjectResponseBase, **handler_config)
|
||||
|
||||
@classmethod
|
||||
async def get_all_info(cls, client, project_id: str) -> Dict[str, Any]:
|
||||
|
||||
@@ -9,4 +9,4 @@ from schemas.project.project_base import ProjectResponseBase
|
||||
class ProjectJsonlHandler(BaseJsonlHandler):
|
||||
"""项目 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "project", ProjectSyncNode, ProjectResponseBase)
|
||||
super().__init__(datasource, ProjectSyncNode, schema=ProjectResponseBase)
|
||||
|
||||
@@ -49,10 +49,7 @@ class ProjectDetailApiHandler(BaseApiHandler):
|
||||
"""项目容量信息 API Handler"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "project_detail_data"
|
||||
self._node_class = ProjectDetailSyncNode
|
||||
self._schema = ProjectDetailProject
|
||||
super().__init__(node_class=ProjectDetailSyncNode, schema=ProjectDetailProject)
|
||||
self._pending_push_context: Dict[str, Dict[str, str]] = {}
|
||||
|
||||
async def load(self) -> List[SyncNode]:
|
||||
|
||||
@@ -7,4 +7,4 @@ from schemas.project_extensions.project_detail import ProjectDetailProject
|
||||
class ProjectDetailJsonlHandler(BaseJsonlHandler):
|
||||
"""项目容量信息 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "project_detail_data", ProjectDetailSyncNode, ProjectDetailProject)
|
||||
super().__init__(datasource, ProjectDetailSyncNode, schema=ProjectDetailProject)
|
||||
|
||||
@@ -6,7 +6,7 @@ Supplier API Handler (只读)
|
||||
- 不支持创建/更新/删除
|
||||
"""
|
||||
|
||||
from typing import List, Dict, Any
|
||||
from typing import List, Dict
|
||||
from ...datasource.api.handler import BaseApiHandler
|
||||
from ...datasource.task_result import TaskResult
|
||||
from ...common.sync_node import SyncNode
|
||||
@@ -18,10 +18,7 @@ class SupplierApiHandler(BaseApiHandler):
|
||||
"""供应商 API Handler (只读)"""
|
||||
|
||||
def __init__(self, load_mode: str = "api", max_total: int | None = None):
|
||||
super().__init__()
|
||||
self._node_type = "supplier"
|
||||
self._node_class = SupplierSyncNode
|
||||
self._schema = SupplierDetailResponse
|
||||
super().__init__(node_class=SupplierSyncNode, schema=SupplierDetailResponse)
|
||||
self._load_mode = load_mode
|
||||
self._max_total = max_total
|
||||
|
||||
@@ -99,10 +96,6 @@ class SupplierApiHandler(BaseApiHandler):
|
||||
"""轮询异步任务状态(占位)"""
|
||||
return await super().poll_tasks(task_ids)
|
||||
|
||||
def _create_node(self, data: Dict[str, Any]) -> SyncNode:
|
||||
return self._create_basic_node(data, depend_ids=[])
|
||||
|
||||
|
||||
# ========== 静态 API 函数 ==========
|
||||
|
||||
async def api_get_supplier_list(client, page: int = 1, page_size: int = 100) -> tuple[List[SupplierDetailResponse], int]:
|
||||
|
||||
@@ -9,4 +9,4 @@ from schemas.supplier.supplier import SupplierDetailResponse
|
||||
class SupplierJsonlHandler(BaseJsonlHandler):
|
||||
"""供应商 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "supplier", SupplierSyncNode, SupplierDetailResponse)
|
||||
super().__init__(datasource, SupplierSyncNode, schema=SupplierDetailResponse)
|
||||
|
||||
@@ -23,10 +23,7 @@ class UnitsApiHandler(BaseApiHandler):
|
||||
"""机组 API Handler"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "units"
|
||||
self._node_class = UnitsSyncNode
|
||||
self._schema = GeneratorUnitProject
|
||||
super().__init__(node_class=UnitsSyncNode, schema=GeneratorUnitProject)
|
||||
|
||||
async def load(self) -> List[SyncNode]:
|
||||
"""加载机组数据(从 project all_info 中提取)"""
|
||||
|
||||
@@ -11,7 +11,7 @@ from schemas.project_extensions.generator_unit import GeneratorUnitProject
|
||||
class UnitsJsonlHandler(BaseJsonlHandler):
|
||||
"""机组 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "units", UnitsSyncNode, GeneratorUnitProject)
|
||||
super().__init__(datasource, UnitsSyncNode, schema=GeneratorUnitProject)
|
||||
|
||||
async def load(self) -> List['SyncNode']:
|
||||
"""加载机组数据(支持 generator_unit_N.jsonl 与 units_N.jsonl)"""
|
||||
|
||||
@@ -10,7 +10,7 @@ GET:
|
||||
- /user/list - 获取用户列表
|
||||
"""
|
||||
|
||||
from typing import List, Dict, Any
|
||||
from typing import List, Dict
|
||||
from ...datasource.api.handler import BaseApiHandler
|
||||
from ...datasource.task_result import TaskResult
|
||||
from ...common.sync_node import SyncNode
|
||||
@@ -22,10 +22,7 @@ class UserApiHandler(BaseApiHandler):
|
||||
"""用户 API Handler (只读)"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._node_type = "user"
|
||||
self._node_class = UserSyncNode
|
||||
self._schema = UserListDetailItem
|
||||
super().__init__(node_class=UserSyncNode, schema=UserListDetailItem)
|
||||
|
||||
async def load(self) -> List[SyncNode]:
|
||||
"""加载用户列表(支持分页)"""
|
||||
@@ -87,10 +84,6 @@ class UserApiHandler(BaseApiHandler):
|
||||
"""轮询异步任务状态(占位)"""
|
||||
return await super().poll_tasks(task_ids)
|
||||
|
||||
def _create_node(self, data: Dict[str, Any]) -> SyncNode:
|
||||
return self._create_basic_node(data, depend_ids=[])
|
||||
|
||||
|
||||
# ========== 静态 API 函数 ==========
|
||||
|
||||
async def api_get_user_list(client, page: int = 1, page_size: int = 100) -> tuple[List[UserListDetailItem], int]:
|
||||
|
||||
@@ -7,4 +7,4 @@ from schemas.user.user import UserListDetailItem
|
||||
class UserJsonlHandler(BaseJsonlHandler):
|
||||
"""用户 JSONL Handler"""
|
||||
def __init__(self, datasource: JsonlDataSource):
|
||||
super().__init__(datasource, "user", UserSyncNode, UserListDetailItem)
|
||||
super().__init__(datasource, UserSyncNode, schema=UserListDetailItem)
|
||||
|
||||
Reference in New Issue
Block a user