feat: 自动拼图失败三次后改为手动拖动

This commit is contained in:
2026-10-27 04:28:25 +08:00
parent 858d777588
commit afda5a883f
6 changed files with 446 additions and 62 deletions
+15 -3
View File
@@ -11,7 +11,7 @@ from pydantic import BaseModel, Field
from sqlalchemy.orm import Session
from euniv.db import get_db, init_db
from euniv.service import fetch_home, login_and_store
from euniv.service import fetch_home, login_and_store, submit_jigsaw
@asynccontextmanager
@@ -28,6 +28,11 @@ class LoginBody(BaseModel):
password: str = Field(min_length=1, max_length=128)
class JigsawBody(BaseModel):
attempt_id: str = Field(min_length=8, max_length=64)
offset: int = Field(ge=0, le=2000)
@app.get("/api/health")
def health() -> dict:
return {"ok": True}
@@ -37,10 +42,17 @@ def health() -> dict:
def login(body: LoginBody, db: Session = Depends(get_db)) -> dict:
employee_id = body.employee_id.strip()
try:
login_and_store(db, employee_id, body.password)
return login_and_store(db, employee_id, body.password)
except RuntimeError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
@app.post("/api/login/jigsaw")
def login_jigsaw(body: JigsawBody, db: Session = Depends(get_db)) -> dict:
try:
return submit_jigsaw(db, body.attempt_id, body.offset)
except RuntimeError as exc:
raise HTTPException(status_code=400, detail=str(exc)) from exc
return {"employee_id": employee_id}
@app.get("/api/home")