new features
This commit is contained in:
@@ -2,7 +2,7 @@ from __future__ import annotations
|
||||
|
||||
import uuid
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Response, status
|
||||
from fastapi import APIRouter, Depends, HTTPException, Query, Response, status
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from cpv3.infrastructure.auth import get_current_user
|
||||
@@ -16,11 +16,17 @@ router = APIRouter(prefix="/api/projects", tags=["Projects"])
|
||||
|
||||
@router.get("/", response_model=list[ProjectRead])
|
||||
async def list_all_projects(
|
||||
search: str | None = Query(None, description="Поиск по названию или описанию"),
|
||||
status_filter: str | None = Query(
|
||||
None, alias="status", description="Фильтр по статусу проекта"
|
||||
),
|
||||
current_user: User = Depends(get_current_user),
|
||||
db: AsyncSession = Depends(get_db),
|
||||
) -> list[ProjectRead]:
|
||||
service = ProjectService(db)
|
||||
projects = await service.list_projects(requester=current_user)
|
||||
projects = await service.list_projects(
|
||||
requester=current_user, search=search, status=status_filter,
|
||||
)
|
||||
return [ProjectRead.model_validate(p) for p in projects]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user