27 lines
1.2 KiB
Python
27 lines
1.2 KiB
Python
|
|
"""
|
|||
|
|
通知模型
|
|||
|
|
"""
|
|||
|
|
from sqlalchemy import Column, BigInteger, String, DateTime, SmallInteger, Text, ForeignKey
|
|||
|
|
from sqlalchemy.sql import func
|
|||
|
|
from app.core.database import Base
|
|||
|
|
|
|||
|
|
|
|||
|
|
class Notification(Base):
|
|||
|
|
"""用户通知表模型"""
|
|||
|
|
|
|||
|
|
__tablename__ = "notifications"
|
|||
|
|
|
|||
|
|
id = Column(BigInteger, primary_key=True, autoincrement=True, comment="通知ID")
|
|||
|
|
user_id = Column(BigInteger, ForeignKey("users.id", ondelete="CASCADE"), nullable=False, index=True, comment="接收用户ID")
|
|||
|
|
type = Column(String(20), default="info", comment="类型:info, success, warning, error")
|
|||
|
|
category = Column(String(50), default="system", comment="分类:system, project, collaboration")
|
|||
|
|
title = Column(String(200), nullable=False, comment="标题")
|
|||
|
|
content = Column(Text, comment="内容")
|
|||
|
|
link = Column(String(255), comment="跳转链接")
|
|||
|
|
is_read = Column(SmallInteger, default=0, comment="是否已读:0-未读 1-已读")
|
|||
|
|
created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
|
|||
|
|
read_at = Column(DateTime, comment="阅读时间")
|
|||
|
|
|
|||
|
|
def __repr__(self):
|
|||
|
|
return f"<Notification(id={self.id}, user_id={self.user_id}, title='{self.title}')>"
|