初始提交:极码 GeekCode 全栈项目(FastAPI + Vue3)
This commit is contained in:
23
backend/models/post.py
Normal file
23
backend/models/post.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""经验帖模型"""
|
||||
from sqlalchemy import Column, Integer, String, Text, DateTime, Boolean, ForeignKey
|
||||
from sqlalchemy.sql import func
|
||||
from database import Base
|
||||
|
||||
|
||||
class Post(Base):
|
||||
__tablename__ = "posts"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True)
|
||||
user_id = Column(Integer, ForeignKey("users.id"), nullable=False, index=True)
|
||||
title = Column(String(200), nullable=False)
|
||||
content = Column(Text, nullable=False)
|
||||
category = Column(String(50), default="") # 分类:前端/后端/部署/踩坑/最佳实践
|
||||
tags = Column(Text, default="") # JSON数组存储标签
|
||||
is_public = Column(Boolean, default=True)
|
||||
is_draft = Column(Boolean, default=False, index=True) # 草稿状态
|
||||
view_count = Column(Integer, default=0)
|
||||
like_count = Column(Integer, default=0)
|
||||
collect_count = Column(Integer, default=0)
|
||||
comment_count = Column(Integer, default=0)
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
||||
Reference in New Issue
Block a user