from typing import List, Optional
from fastapi import APIRouter, Depends, Query
from sqlmodel import Session, select
from app.database import get_session
from app.models.dicton import Dicton

router = APIRouter(tags=["dictons"])


@router.get("/dictons", response_model=List[Dicton])
def list_dictons(
    mois: Optional[int] = Query(None),
    session: Session = Depends(get_session),
):
    q = select(Dicton)
    if mois:
        q = q.where(Dicton.mois == mois)
    return session.exec(q).all()
