from fastapi import APIRouter, Depends
from sqlalchemy.ext.asyncio import AsyncSession

from app.database.session import get_db
from app.domain.entities.role import RoleEntity
from app.infrastructure.dependencies import get_current_user
from app.infrastructure.roles_service import RolesService

router = APIRouter()


@router.get(
    '/',
    response_model=list[RoleEntity],
    summary='Return all roles',
    description='Return all roles',
)
async def get_all_roles(
        db: AsyncSession = Depends(get_db),
        user=Depends(get_current_user),
):
    roles_service = RolesService(db)
    return await roles_service.get_all_roles()
