e76fa586f1
Ship dual-track learning (daily accumulation vs textbook),沪教/商务词书 APIs and UI, native iOS wrapper with bundled H5, and production book import on deploy. Co-authored-by: Cursor <cursoragent@cursor.com>
39 lines
1.1 KiB
Python
39 lines
1.1 KiB
Python
from typing import Literal
|
|
|
|
from fastapi import APIRouter, Depends, Query
|
|
from sqlalchemy.orm import Session
|
|
|
|
from auth import get_current_user
|
|
from database import get_db
|
|
from models import User
|
|
from schemas import CoachSessionResponse, CoachTurnRequest, CoachTurnResponse
|
|
from services.memory_coach_service import memory_coach_service
|
|
|
|
router = APIRouter(prefix="/api/coach", tags=["coach"])
|
|
|
|
|
|
@router.get("/session", response_model=CoachSessionResponse)
|
|
def coach_session(
|
|
track: Literal["accumulation", "book"] = Query("accumulation"),
|
|
db: Session = Depends(get_db),
|
|
current_user: User = Depends(get_current_user),
|
|
):
|
|
return memory_coach_service.start_session(db, current_user, track=track)
|
|
|
|
|
|
@router.post("/turn", response_model=CoachTurnResponse)
|
|
def coach_turn(
|
|
data: CoachTurnRequest,
|
|
db: Session = Depends(get_db),
|
|
current_user: User = Depends(get_current_user),
|
|
):
|
|
return memory_coach_service.handle_turn(
|
|
db,
|
|
current_user,
|
|
data.word_id,
|
|
data.stage,
|
|
data.user_message,
|
|
data.hints_used,
|
|
data.duration_seconds or 0,
|
|
)
|