Files
huihuiSquare/backend/app/models/news_cache.py
yuqianqian10204095yu cebc0a288f 1.0.0初始化源代码
2026-03-23 15:40:36 +08:00

46 lines
1.7 KiB
Python
Raw 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 sqlalchemy import Column, Integer, String, DateTime, Text, Boolean, Date
from sqlalchemy.sql import func
from .base import Base
class NewsCache(Base):
"""新闻缓存表"""
__tablename__ = "news_cache"
id = Column(Integer, primary_key=True, autoincrement=True, comment="缓存 ID")
# 新闻基本信息
news_id = Column(String(100), unique=True, nullable=False, index=True, comment="新闻 ID来自会会接口")
title = Column(String(500), nullable=False, comment="新闻标题")
summary = Column(Text, comment="新闻摘要")
content = Column(Text, comment="新闻内容")
# 来源信息
source = Column(String(200), comment="来源")
author = Column(String(100), comment="作者")
publish_time = Column(DateTime, comment="发布时间")
# 分类标签
category = Column(String(100), comment="分类")
tags = Column(String(500), comment="标签(逗号分隔)")
# 互动统计
view_count = Column(Integer, default=0, comment="阅读数")
comment_count = Column(Integer, default=0, comment="评论数")
like_count = Column(Integer, default=0, comment="点赞数")
# 缓存状态
is_cached = Column(Boolean, default=True, comment="是否已缓存")
cache_date = Column(Date, server_default=func.now(), index=True, comment="缓存日期")
# 时间戳
created_at = Column(DateTime, server_default=func.now(), comment="创建时间")
updated_at = Column(DateTime, server_default=func.now(), onupdate=func.now(), comment="更新时间")
def __repr__(self):
return f"<NewsCache(id={self.id}, news_id='{self.news_id}', title='{self.title[:30]}...')>"