57 lines
1.3 KiB
Python
57 lines
1.3 KiB
Python
from fastapi import APIRouter, Path, Query
|
|
|
|
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,
|
|
include_deleted: bool = Query(alias="includeDeleted", default=False),
|
|
):
|
|
return await ClientService(session).get_all(include_deleted)
|
|
|
|
|
|
@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)
|