feat(api): add database models
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
from sqlalchemy import Column, Integer, String, DateTime
|
||||
from sqlalchemy.orm import relationship
|
||||
from sqlalchemy.sql import func
|
||||
|
||||
from app.database import Base
|
||||
|
||||
|
||||
class JokeType(Base):
|
||||
"""笑话类型表模型"""
|
||||
__tablename__ = "joke_types"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
name = Column(String(50), nullable=False)
|
||||
icon = Column(String(50), nullable=True)
|
||||
sort_order = Column(Integer, default=0)
|
||||
created_at = Column(DateTime, default=func.now())
|
||||
|
||||
# Relationships
|
||||
jokes = relationship("Joke", back_populates="type")
|
||||
|
||||
|
||||
class JokeCrowd(Base):
|
||||
"""笑话人群表模型"""
|
||||
__tablename__ = "joke_crowds"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
name = Column(String(50), nullable=False)
|
||||
icon = Column(String(50), nullable=True)
|
||||
sort_order = Column(Integer, default=0)
|
||||
created_at = Column(DateTime, default=func.now())
|
||||
|
||||
# Relationships
|
||||
jokes = relationship("Joke", back_populates="crowd")
|
||||
Reference in New Issue
Block a user