Files
health-service/service/report_service.py
2026-09-04 21:28:19 +08:00

27 lines
489 B
Python

import json
from sqlalchemy import select
from sqlalchemy.orm import Session
from models.health import Report
def upload_report(report: str, db: Session):
report = Report(
content=json.loads(report),
)
db.add(report)
db.commit()
db.refresh(report)
return report.id
def query_report(id: int, db: Session):
result = db.execute(
select(Report).where(Report.id == id)
)
report = result.scalar_one_or_none()
return report.content