feat: add new file

This commit is contained in:
Daniel
2026-03-24 10:35:58 +08:00
commit 2788fc468f
9058 changed files with 896924 additions and 0 deletions

45
backend/app/models.py Normal file
View File

@@ -0,0 +1,45 @@
from datetime import datetime
from sqlalchemy import Date, DateTime, Float, Integer, String, Text
from sqlalchemy.orm import Mapped, mapped_column
from .database import Base
class Resource(Base):
__tablename__ = "resources"
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
title: Mapped[str] = mapped_column(String(255), nullable=False)
resource_type: Mapped[str] = mapped_column(String(20), nullable=False) # link/file
url: Mapped[str | None] = mapped_column(String(1024), nullable=True)
file_name: Mapped[str | None] = mapped_column(String(255), nullable=True)
category: Mapped[str] = mapped_column(String(50), nullable=False)
tags: Mapped[str | None] = mapped_column(String(255), nullable=True)
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
class Mistake(Base):
__tablename__ = "mistakes"
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
title: Mapped[str] = mapped_column(String(255), nullable=False)
image_url: Mapped[str | None] = mapped_column(String(1024), nullable=True)
category: Mapped[str] = mapped_column(String(50), nullable=False)
difficulty: Mapped[str | None] = mapped_column(String(20), nullable=True) # easy/medium/hard
note: Mapped[str | None] = mapped_column(Text, nullable=True)
wrong_count: Mapped[int] = mapped_column(Integer, default=1)
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)
class ScoreRecord(Base):
__tablename__ = "score_records"
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
exam_name: Mapped[str] = mapped_column(String(255), nullable=False)
exam_date: Mapped[Date] = mapped_column(Date, nullable=False)
total_score: Mapped[float] = mapped_column(Float, nullable=False)
module_scores: Mapped[str | None] = mapped_column(
String(255), nullable=True
) # JSON string for simplicity
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow)