Files
video-gen/video-gen-api/app/models/scheduled_task.py
T
root 7dcedf974d 1、后台菜单增加定时任务和银行交易
2、增加后台配置银行账户和请求网址
2026-08-13 15:12:16 +08:00

24 lines
1.4 KiB
Python

"""定时任务配置模型。"""
from sqlalchemy import Boolean, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from app.models.base import Base, TimestampMixin
class ScheduledTask(Base, TimestampMixin):
__tablename__ = "scheduled_tasks"
id: Mapped[str] = mapped_column(String(32), primary_key=True)
name: Mapped[str] = mapped_column(String(128), nullable=False, comment="任务名称")
task_type: Mapped[str] = mapped_column(String(32), nullable=False, comment="类型: external_api / internal_method")
schedule: Mapped[str] = mapped_column(String(128), nullable=False, comment="Cron 表达式或间隔秒数")
config: Mapped[str | None] = mapped_column(Text, nullable=True, comment="任务配置 JSON")
# external_api config: {url, method, headers, payload}
# internal_method config: {module, function, args}
is_active: Mapped[bool] = mapped_column(Boolean, default=True, comment="是否启用")
last_run_at: Mapped[str | None] = mapped_column(String(64), nullable=True, comment="最后执行时间 ISO")
last_status: Mapped[str | None] = mapped_column(String(16), nullable=True, comment="最后执行状态: success / error")
last_error: Mapped[str | None] = mapped_column(Text, nullable=True, comment="最后执行错误信息")
created_by: Mapped[str | None] = mapped_column(String(32), nullable=True, comment="创建者管理员 ID")