feat: 增加公告栏并让用户自选学时判断
This commit is contained in:
@@ -84,6 +84,7 @@ class StudyBundleBody(BaseModel):
|
||||
heartbeat_video_seconds: int | None = Field(default=None, strict=True, ge=0, le=300)
|
||||
heartbeat_document_seconds: int | None = Field(default=None, strict=True, ge=0, le=600)
|
||||
heartbeat_scorm_seconds: int | None = Field(default=None, strict=True, ge=0, le=600)
|
||||
hours_source: str | None = None
|
||||
|
||||
|
||||
class StudyControlBody(BaseModel):
|
||||
@@ -327,6 +328,14 @@ def _signed_in(request: Request, db: Session) -> str:
|
||||
return employee_id
|
||||
|
||||
|
||||
@app.get("/api/announcements")
|
||||
def announcements(request: Request, db: Session = Depends(get_db)) -> list[dict]:
|
||||
from admin.notices import list_notices
|
||||
|
||||
_signed_in(request, db)
|
||||
return list_notices(db)
|
||||
|
||||
|
||||
@app.get("/api/home/summary")
|
||||
def home_summary(request: Request, db: Session = Depends(get_db)) -> dict:
|
||||
try:
|
||||
@@ -446,6 +455,11 @@ def _apply_study_bundle(account: Account, body: StudyBundleBody) -> None:
|
||||
body.heartbeat_document_seconds,
|
||||
body.heartbeat_scorm_seconds,
|
||||
)
|
||||
if body.hours_source is not None:
|
||||
chosen = str(body.hours_source).strip().lower()
|
||||
if chosen not in {"api", "history"}:
|
||||
raise HTTPException(status_code=400, detail="学时判断须为官方统计或历史统计")
|
||||
account.hours_source = chosen
|
||||
except (StudyWindowError, CourseWorkersError, HeartbeatError) as exc:
|
||||
raise HTTPException(status_code=400, detail=str(exc)) from exc
|
||||
|
||||
|
||||
Reference in New Issue
Block a user