This commit is contained in:
2024-04-10 03:45:52 +03:00
parent 5de5b9b3e4
commit 93eb6ae6b7
5 changed files with 107 additions and 16 deletions

View File

@@ -5,8 +5,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
from backend.session import get_session
from models import User
from schemas.client import ClientSearchRequest, ClientUpdateDetailsRequest, ClientUpdateDetailsResponse, \
ClientGetAllResponse
from schemas.client import *
from services.auth import get_current_user
from services.client import ClientService
@@ -48,3 +47,41 @@ async def get_all_clients(
session: Annotated[AsyncSession, Depends(get_session)],
):
return await ClientService(session).get_all()
@client_router.post(
'/create',
operation_id='create_client',
response_model=ClientCreateResponse
)
async def create_client(
request: ClientCreateRequest,
user: Annotated[User, Depends(get_current_user)],
session: Annotated[AsyncSession, Depends(get_session)]
):
return await ClientService(session).create(request, user)
@client_router.post(
'/update',
operation_id='update_client',
response_model=ClientUpdateResponse
)
async def update_client(
request: ClientUpdateRequest,
user: Annotated[User, Depends(get_current_user)],
session: Annotated[AsyncSession, Depends(get_session)]
):
return await ClientService(session).update(request, user)
@client_router.post(
'/delete',
operation_id='delete_client',
response_model=ClientDeleteResponse
)
async def delete_client(
request: ClientDeleteRequest,
session: Annotated[AsyncSession, Depends(get_session)]
):
return await ClientService(session).delete(request)