Files
konjacpotato 2c8426d543 import arlo
2025-11-05 21:00:19 +08:00

33 lines
1.9 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from datetime import datetime
from sqlalchemy import Column, Integer, String, Text, Boolean, TIMESTAMP, func
from sqlalchemy.dialects.postgresql import BIGINT
from dataclasses import dataclass
from database.database import Base
@dataclass
class TContentDispatch(Base):
__tablename__ = 't_content_dispatch'
id: int = Column(BIGINT, primary_key=True, autoincrement=True, comment='自动递增的唯一任务ID')
creation_date: datetime = Column(TIMESTAMP(timezone=True), server_default=func.now(), nullable=False, comment='记录数据条目的创建时间')
is_sent: bool = Column(Boolean, default=False, nullable=False, comment='表示数据条目是否已被发送')
category: str = Column(String(255), nullable=False, comment='类别')
title: str = Column(String(255), nullable=False, comment='标题')
cover_image: str = Column(Text, nullable=True, comment='封面')
poster_image: str = Column(Text, nullable=True, comment='海报')
opening_text: str = Column(Text, nullable=True, comment='开头语')
content: str = Column(Text, nullable=False, comment='内容')
ai_content: str = Column(Text, nullable=True, comment='AI编辑的内容')
closing_text: str = Column(Text, nullable=True, comment='结束语')
is_scheduled: bool = Column(Boolean, default=False, nullable=False, comment='是否设置为定时发送')
schedule_time: str = Column(TIMESTAMP, nullable=True, comment='定时发送的具体时间')
format: str = Column(String(50), nullable=True, comment='数据条目的格式')
ai_generate: int = Column(Integer, default=0, nullable=False, comment='是否AI生成。0否1部分参与2是。')
def __repr__(self):
return f"<TContentDispatch(id={self.id}, title={self.title}, category={self.category})>"
def get_creation_date_in_localtime(self) -> datetime:
# 将 UTC 时间转换为localtime
return self.creation_date.astimezone()