import uuid

from fastapi import HTTPException, status
from sqlalchemy.orm import Session

from app.models.user import Student


def get_student_for_user(db: Session, student_id: uuid.UUID, user_id: uuid.UUID) -> Student:
    student = db.get(Student, student_id)
    if student is None or student.user_id != user_id:
        raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="学生不存在")
    return student
