feat(P5): 学科配置表(学科=配置非插件)——Course model+repo+service(7 学科种子,提示词自由化基座)+routes(公开列表/管理员 CRUD)+main 挂载 seed
这个提交包含在:
@@ -1,4 +1,5 @@
|
||||
"""ORM 模型:题目、提交记录、学习进度、用户、对话消息、班级。"""
|
||||
"""ORM 模型:题目、提交记录、学习进度、用户、对话消息、班级、学科配置。"""
|
||||
from app.models.course import Course
|
||||
from app.models.klass import Class, ClassMember
|
||||
from app.models.message import Message
|
||||
from app.models.problem import Problem
|
||||
@@ -6,4 +7,4 @@ from app.models.progress import Progress
|
||||
from app.models.submission import Submission
|
||||
from app.models.user import User
|
||||
|
||||
__all__ = ["Class", "ClassMember", "Message", "Problem", "Progress", "Submission", "User"]
|
||||
__all__ = ["Class", "ClassMember", "Course", "Message", "Problem", "Progress", "Submission", "User"]
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
"""学科配置表:学科=配置而非插件(微核心+插件架构的配置层)。
|
||||
|
||||
每个学科挂:提示词(对话机制基座)、LaTeX 速查表键、题库路由、启用状态。
|
||||
注册页/工作台/教师端共用;管理员可 CRUD。
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import DateTime, Integer, String, Text, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.core.db import Base
|
||||
|
||||
|
||||
class Course(Base):
|
||||
__tablename__ = "courses"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
code: Mapped[str] = mapped_column(String(32), unique=True, index=True) # ap-csa / usaco / ap-calc ...
|
||||
name: Mapped[str] = mapped_column(String(64)) # AP CSA / USACO ...
|
||||
# 学科对话机制提示词(基座;学生发散问题仍自由回应,不强拉题目)
|
||||
prompt: Mapped[str] = mapped_column(Text, default="")
|
||||
# LaTeX 速查表键(对应 data/latex_sheet.json courses[].id,如 ap-calc)
|
||||
latex_key: Mapped[str] = mapped_column(String(32), default="common")
|
||||
# 题库路由:HydroOJ domain 或题目单前缀(留空=全局题单)
|
||||
problem_route: Mapped[str] = mapped_column(String(64), default="")
|
||||
enabled: Mapped[bool] = mapped_column(Integer, default=1)
|
||||
sort: Mapped[int] = mapped_column(Integer, default=100)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, server_default=func.now())
|
||||
|
||||
def to_dict(self) -> dict:
|
||||
return {
|
||||
"id": self.id,
|
||||
"code": self.code,
|
||||
"name": self.name,
|
||||
"prompt": self.prompt,
|
||||
"latex_key": self.latex_key,
|
||||
"problem_route": self.problem_route,
|
||||
"enabled": bool(self.enabled),
|
||||
"sort": self.sort,
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户