nex_docus/backend/app/models/notification.py

27 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""
通知模型
"""
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}')>"