announcement.py 1.1 KB

12345678910111213141516171819202122232425
  1. """
  2. 公告模型
  3. """
  4. from datetime import datetime
  5. from app.utils.timezone import beijing_now_naive
  6. from sqlalchemy import Column, Integer, String, DateTime, Boolean, Text
  7. from app.database import Base
  8. class Announcement(Base):
  9. """公告表"""
  10. __tablename__ = "announcements"
  11. id = Column(Integer, primary_key=True, autoincrement=True, comment="主键ID")
  12. title = Column(String(200), nullable=False, comment="公告标题")
  13. content = Column(Text, nullable=False, comment="公告内容")
  14. priority = Column(Integer, default=0, comment="优先级: 0-普通, 1-重要, 2-紧急")
  15. is_active = Column(Boolean, default=True, comment="是否启用: 1-启用, 0-禁用")
  16. publish_time = Column(DateTime, nullable=True, comment="发布时间")
  17. is_deleted = Column(Boolean, default=False, comment="是否删除: 0-否, 1-是")
  18. created_at = Column(DateTime, default=beijing_now_naive, comment="创建时间")
  19. updated_at = Column(DateTime, default=beijing_now_naive, onupdate=beijing_now_naive, comment="更新时间")
  20. def __repr__(self):
  21. return f"<Announcement(id={self.id}, title='{self.title}')>"