Squashed 'core/' content from commit 92ec910
git-subtree-dir: core git-subtree-split: 92ec910a132e379a3a6e442a75bcb07cac0f0010
This commit is contained in:
38
backend/app/models/report.py
Normal file
38
backend/app/models/report.py
Normal file
@@ -0,0 +1,38 @@
|
||||
from sqlalchemy import Column, Integer, String, Boolean, DateTime, ForeignKey, Text, JSON
|
||||
from sqlalchemy.sql import func
|
||||
from app.core.database import Base
|
||||
|
||||
|
||||
class ReportTemplate(Base):
|
||||
__tablename__ = "report_templates"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
name = Column(String(100), nullable=False)
|
||||
report_type = Column(String(50), nullable=False) # daily, weekly, monthly, yearly, custom
|
||||
description = Column(Text)
|
||||
fields = Column(JSON, nullable=False) # 报表字段配置
|
||||
filters = Column(JSON) # 默认筛选条件
|
||||
aggregation = Column(String(20), default="sum") # sum, avg, max, min
|
||||
time_granularity = Column(String(20), default="hour") # hour, day, month
|
||||
format_config = Column(JSON) # 展示格式配置
|
||||
is_system = Column(Boolean, default=False) # 系统预置
|
||||
created_by = Column(Integer, ForeignKey("users.id"))
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
|
||||
|
||||
class ReportTask(Base):
|
||||
__tablename__ = "report_tasks"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
template_id = Column(Integer, ForeignKey("report_templates.id"), nullable=False)
|
||||
name = Column(String(200))
|
||||
schedule = Column(String(50)) # cron expression or null for manual
|
||||
next_run = Column(DateTime(timezone=True))
|
||||
last_run = Column(DateTime(timezone=True))
|
||||
recipients = Column(JSON) # 接收人
|
||||
export_format = Column(String(20), default="xlsx") # xlsx, csv, pdf
|
||||
file_path = Column(String(500)) # 最新生成的文件路径
|
||||
status = Column(String(20), default="pending") # pending, running, completed, failed
|
||||
is_active = Column(Boolean, default=True)
|
||||
created_by = Column(Integer, ForeignKey("users.id"))
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
Reference in New Issue
Block a user