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