feat: 每月定时开始学习并改为本地计算心跳摘要

This commit is contained in:
2026-11-15 01:30:24 +08:00
parent e9a1e9b315
commit caa79d79b7
14 changed files with 510 additions and 35 deletions
+22
View File
@@ -17,8 +17,10 @@ from admin.users import (
list_users,
read_credentials,
read_proxy,
read_study_start,
set_paused,
set_proxy,
set_study_start,
)
from euniv.courses import course_page, request_course_sync_now
from euniv.db import get_db
@@ -57,6 +59,14 @@ class AdminProxyClearBody(BaseModel):
employee_ids: list[str]
class AdminStudyStartBody(BaseModel):
employee_ids: list[str]
day: int
hour: int
minute: int
second: int
def require_admin(request: Request) -> str:
if not admin_session_active(request.cookies):
raise HTTPException(status_code=401, detail="未登录")
@@ -164,6 +174,18 @@ def get_user_proxy(employee_id: str, db: Session = Depends(get_db), _: str = Dep
return read_proxy(db, employee_id)
@admin_router.put("/users/study-start")
def put_users_study_start(
body: AdminStudyStartBody, db: Session = Depends(get_db), _: str = Depends(require_admin)
) -> dict:
return set_study_start(db, body.employee_ids, body.day, body.hour, body.minute, body.second)
@admin_router.get("/users/{employee_id}/study-start")
def get_user_study_start(employee_id: str, db: Session = Depends(get_db), _: str = Depends(require_admin)) -> dict:
return read_study_start(db, employee_id)
@admin_router.get("/users/{employee_id}/credentials")
def get_credentials(employee_id: str, db: Session = Depends(get_db), _: str = Depends(require_admin)) -> dict:
return read_credentials(db, employee_id)