feat: add new file
This commit is contained in:
45
backend/app/models.py
Normal file
45
backend/app/models.py
Normal 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)
|
||||
Reference in New Issue
Block a user