feat: 管理端定时日扩到1至28号,学时顺带写回列表
This commit is contained in:
@@ -61,7 +61,7 @@ class ProxyBody(BaseModel):
|
||||
|
||||
|
||||
class StudyStartBody(BaseModel):
|
||||
day: int = Field(strict=True, ge=5, le=25)
|
||||
day: int = Field(strict=True, ge=1, le=28)
|
||||
hour: int = Field(strict=True, ge=0, le=23)
|
||||
minute: int = Field(strict=True, ge=0, le=59)
|
||||
second: int = Field(strict=True, ge=0, le=59)
|
||||
@@ -74,7 +74,7 @@ class CourseWorkersBody(BaseModel):
|
||||
|
||||
class StudyBundleBody(BaseModel):
|
||||
monthly_target: int = Field(strict=True, ge=0, le=9999)
|
||||
day: int = Field(strict=True, ge=5, le=25)
|
||||
day: int = Field(strict=True, ge=1, le=28)
|
||||
hour: int = Field(strict=True, ge=0, le=23)
|
||||
minute: int = Field(strict=True, ge=0, le=59)
|
||||
second: int = Field(strict=True, ge=0, le=59)
|
||||
@@ -394,13 +394,13 @@ def get_study_start(request: Request, db: Session = Depends(get_db)) -> dict:
|
||||
|
||||
@app.put("/api/settings/study-start")
|
||||
def put_study_start(body: StudyStartBody, request: Request, db: Session = Depends(get_db)) -> dict:
|
||||
from euniv.study_window import StudyWindowError, apply, view_of
|
||||
from euniv.study_window import StudyWindowError, apply_user, view_of
|
||||
|
||||
account = db.get(Account, _signed_in(request, db))
|
||||
if account is None:
|
||||
raise HTTPException(status_code=401, detail="未登录")
|
||||
try:
|
||||
apply(account, body.day, body.hour, body.minute, body.second)
|
||||
apply_user(account, body.day, body.hour, body.minute, body.second)
|
||||
except StudyWindowError as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
if body.enabled is not None:
|
||||
@@ -426,7 +426,7 @@ def _apply_study_bundle(account: Account, body: StudyBundleBody) -> None:
|
||||
"""把首页这一组学习配置写到账号上。不符合要求时抛 400,由调用方回滚。"""
|
||||
from euniv.course_workers import CourseWorkersError, apply as apply_workers
|
||||
from euniv.heartbeat import HeartbeatError, apply as apply_heartbeat
|
||||
from euniv.study_window import StudyWindowError, apply as apply_start
|
||||
from euniv.study_window import StudyWindowError, apply_user as apply_start
|
||||
|
||||
try:
|
||||
account.monthly_target = body.monthly_target
|
||||
|
||||
Reference in New Issue
Block a user