feat: client endpoints for clients page

This commit is contained in:
2025-10-04 18:12:13 +04:00
parent 66b50fb951
commit 986712d5b7
12 changed files with 268 additions and 0 deletions

View File

@ -0,0 +1,55 @@
from fastapi import APIRouter, Path
from backend.dependecies import SessionDependency
from modules.clients.schemas.client import *
from modules.clients.services import ClientService
router = APIRouter(tags=["client"])
@router.get(
"/",
response_model=GetClientsResponse,
operation_id="get_clients",
)
async def get_clients(
session: SessionDependency,
):
return await ClientService(session).get_all()
@router.post(
"/",
response_model=CreateClientResponse,
operation_id="create_client",
)
async def create_client(
session: SessionDependency,
request: CreateClientRequest,
):
return await ClientService(session).create(request)
@router.patch(
"/{pk}",
response_model=UpdateClientResponse,
operation_id="update_client",
)
async def update_client(
session: SessionDependency,
request: UpdateClientRequest,
pk: int = Path(),
):
return await ClientService(session).update(pk, request)
@router.delete(
"/{pk}",
response_model=DeleteClientResponse,
operation_id="delete_client",
)
async def delete_product(
session: SessionDependency,
pk: int = Path(),
):
return await ClientService(session).delete(pk)