25 lines
790 B
Python
25 lines
790 B
Python
# scheme/scores.py
|
|
from typing import Optional
|
|
from pydantic import BaseModel, Field
|
|
|
|
#录入成绩的请求体模型
|
|
class ScoreCreate(BaseModel):
|
|
sid: int = Field(..., description="学号")
|
|
exam_num: int = Field(..., description="考核次数(第几次考试)")
|
|
score: float = Field(..., description="分数")
|
|
|
|
|
|
# sid、exam_num 作为路径参数在路由中单独传入,更新请求体参数中只放需要更新的字段
|
|
class ScoreUpdate(BaseModel):
|
|
score: Optional[float] = Field(None, description="分数")
|
|
|
|
# 响应体模型返回学号,考试次数,以及考核分数
|
|
class ScoreResponse(BaseModel):
|
|
# score_id: int
|
|
sid: int
|
|
exam_num: int
|
|
score: float
|
|
flag: int
|
|
class Config:
|
|
from_attributes = True # 支持 ORM 对象转换
|