feat:增加知识库数据接口

This commit is contained in:
2026-07-28 19:54:50 +08:00
parent 2e6e571973
commit 0e9bde9a14
19 changed files with 703 additions and 31 deletions

33
models/library.py Normal file
View 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"
)