nex_docus/backend/app/models/document.py

29 lines
1.3 KiB
Python
Raw Normal View History

2025-12-20 11:18:59 +00:00
"""
文档元数据模型
"""
from sqlalchemy import Column, BigInteger, String, Integer, DateTime
from sqlalchemy.sql import func
from app.core.database import Base
class DocumentMeta(Base):
"""文档元数据表模型"""
__tablename__ = "document_meta"
id = Column(BigInteger, primary_key=True, autoincrement=True, comment="元数据ID")
project_id = Column(BigInteger, nullable=False, index=True, comment="项目ID")
file_path = Column(String(500), nullable=False, comment="文件相对路径")
title = Column(String(200), comment="文档标题")
tags = Column(String(500), comment="标签JSON数组")
author_id = Column(BigInteger, index=True, comment="作者ID")
word_count = Column(Integer, default=0, comment="字数统计")
view_count = Column(Integer, default=0, comment="浏览次数")
last_editor_id = Column(BigInteger, comment="最后编辑者ID")
last_edited_at = Column(DateTime, 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"<DocumentMeta(id={self.id}, project_id={self.project_id}, file_path='{self.file_path}')>"