feat:增加训练场和错题集接口
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from sqlalchemy import Column, BigInteger, String, Text, TIMESTAMP, Integer, ForeignKey
|
||||
from sqlalchemy import Column, BigInteger, String, Text, Integer, ForeignKey
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
@@ -19,6 +19,18 @@ class LibraryFile(AuditBase):
|
||||
cascade="all, delete-orphan"
|
||||
)
|
||||
|
||||
practice_record = relationship(
|
||||
"PracticeRecord",
|
||||
back_populates="library_file",
|
||||
cascade="all, delete-orphan"
|
||||
)
|
||||
|
||||
mistake = relationship(
|
||||
"Mistake",
|
||||
back_populates="library_file",
|
||||
cascade="all, delete-orphan"
|
||||
)
|
||||
|
||||
|
||||
class LibraryFileQuestion(AuditBase):
|
||||
library_file_id = Column(BigInteger, ForeignKey("library_file.id"), nullable=False)
|
||||
@@ -32,3 +44,38 @@ class LibraryFileQuestion(AuditBase):
|
||||
"LibraryFile",
|
||||
back_populates="questions"
|
||||
)
|
||||
|
||||
mistake = relationship(
|
||||
"Mistake",
|
||||
back_populates="library_file_question",
|
||||
cascade="all, delete-orphan"
|
||||
)
|
||||
|
||||
|
||||
class PracticeRecord(AuditBase):
|
||||
library_file_id = Column(BigInteger, ForeignKey("library_file.id"), nullable=False)
|
||||
|
||||
total_count = Column(Integer, nullable=False)
|
||||
correct_count = Column(Integer, nullable=False)
|
||||
wrong_count = Column(Integer, nullable=False)
|
||||
|
||||
library_file = relationship(
|
||||
"LibraryFile",
|
||||
back_populates="practice_record",
|
||||
)
|
||||
|
||||
class Mistake(AuditBase):
|
||||
library_file_id = Column(BigInteger, ForeignKey("library_file.id"), nullable=False)
|
||||
question_id = Column(BigInteger, ForeignKey("library_file_question.id"), nullable=False)
|
||||
|
||||
wrong_count = Column(Integer, nullable=False)
|
||||
|
||||
library_file = relationship(
|
||||
"LibraryFile",
|
||||
back_populates="mistake",
|
||||
)
|
||||
|
||||
library_file_question = relationship(
|
||||
"LibraryFileQuestion",
|
||||
back_populates="mistake",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user