feat:增加知识库数据接口
This commit is contained in:
33
models/library.py
Normal file
33
models/library.py
Normal file
@@ -0,0 +1,33 @@
|
||||
from sqlalchemy import Column, BigInteger, String, Text, TIMESTAMP, Integer, ForeignKey
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from models.base import AuditBase
|
||||
|
||||
|
||||
class LibraryFile(AuditBase):
|
||||
subject = Column(String(45), nullable=False)
|
||||
module = Column(String(45), nullable=False)
|
||||
name = Column(String(45), nullable=False)
|
||||
type = Column(String(45), nullable=False)
|
||||
size = Column(Integer, nullable=False)
|
||||
|
||||
questions = relationship(
|
||||
"LibraryFileQuestion",
|
||||
back_populates="library_file",
|
||||
cascade="all, delete-orphan"
|
||||
)
|
||||
|
||||
|
||||
class LibraryFileQuestion(AuditBase):
|
||||
library_file_id = Column(BigInteger, ForeignKey("library_file.id"), nullable=False)
|
||||
|
||||
type = Column(String(45), nullable=False)
|
||||
question = Column(Text, nullable=False)
|
||||
options = Column(JSONB, nullable=False)
|
||||
answer = Column(JSONB, nullable=False)
|
||||
|
||||
library_file = relationship(
|
||||
"LibraryFile",
|
||||
back_populates="questions"
|
||||
)
|
||||
Reference in New Issue
Block a user