增加account_id条件获取沉降数据

This commit is contained in:
2025-11-12 21:26:11 +08:00
parent ae58d19616
commit 411072ef6b
5 changed files with 177 additions and 14 deletions

View File

@@ -20,10 +20,16 @@ class SectionDataService(BaseService[SectionData]):
"""根据断面ID获取断面数据"""
sections = self.get_by_field(db, "section_id", section_id)
return sections[0] if sections else None
def get_by_account_id(self, db: Session, account_id: str) -> Optional[SectionData]:
def get_by_account_id(self, db: Session, account_id: str) -> List[SectionData]:
"""根据账号ID获取断面数据"""
accounts = self.get_by_field(db, "account_id", account_id)
return accounts if accounts else None
return accounts if accounts else []
def get_by_account_id_batch(self, db: Session, account_ids: List[str]) -> List[SectionData]:
"""批量根据账号ID列表获取断面数据使用IN查询优化性能"""
if not account_ids:
return []
return db.query(SectionData).filter(SectionData.account_id.in_(account_ids)).all()
def get_by_number(self, db: Session, number: str) -> List[SectionData]:
"""根据桥梁墩(台)编号获取断面数据"""
return self.get_by_field(db, "number", number)