crappy
This commit is contained in:
100
routers/deal.py
100
routers/deal.py
@@ -52,6 +52,44 @@ async def get_summary(
|
||||
return await DealService(session).get_summary()
|
||||
|
||||
|
||||
@deal_router.get(
|
||||
'/get-all',
|
||||
response_model=DealGetAllResponse,
|
||||
operation_id='getAllDeals'
|
||||
)
|
||||
async def get_all(
|
||||
session: Annotated[AsyncSession, Depends(get_session)]
|
||||
):
|
||||
return await DealService(session).get_all()
|
||||
|
||||
|
||||
# endpoint to get deal by id
|
||||
@deal_router.get(
|
||||
'/get/{deal_id}',
|
||||
response_model=DealSchema,
|
||||
operation_id='getDealById'
|
||||
)
|
||||
async def get_deal_by_id(
|
||||
deal_id: int,
|
||||
session: Annotated[AsyncSession, Depends(get_session)]
|
||||
):
|
||||
return await DealService(session).get_by_id(deal_id)
|
||||
|
||||
|
||||
@deal_router.post(
|
||||
'/update-general-info',
|
||||
response_model=DealUpdateGeneralInfoResponse,
|
||||
operation_id='updateDealGeneralInfo'
|
||||
)
|
||||
async def update_general_info(
|
||||
request: DealUpdateGeneralInfoRequest,
|
||||
session: Annotated[AsyncSession, Depends(get_session)]
|
||||
):
|
||||
return await DealService(session).update_general_info(request)
|
||||
|
||||
|
||||
# region Deal services
|
||||
|
||||
@deal_router.post(
|
||||
'/services/add/multiple',
|
||||
response_model=DealAddServicesResponse,
|
||||
@@ -87,6 +125,7 @@ async def services_update(
|
||||
):
|
||||
return await DealService(session).update_service_quantity(request)
|
||||
|
||||
|
||||
@deal_router.post(
|
||||
'/services/delete',
|
||||
response_model=DealDeleteServiceResponse,
|
||||
@@ -98,6 +137,7 @@ async def services_delete(
|
||||
):
|
||||
return await DealService(session).delete_service(request)
|
||||
|
||||
|
||||
@deal_router.post(
|
||||
'/services/delete/multiple',
|
||||
response_model=DealDeleteServicesResponse,
|
||||
@@ -110,26 +150,46 @@ async def services_delete(
|
||||
return await DealService(session).delete_services(request)
|
||||
|
||||
|
||||
@deal_router.get(
|
||||
'/get-all',
|
||||
response_model=DealGetAllResponse,
|
||||
operation_id='getAllDeals'
|
||||
)
|
||||
async def get_all(
|
||||
session: Annotated[AsyncSession, Depends(get_session)]
|
||||
):
|
||||
return await DealService(session).get_all()
|
||||
# endregion
|
||||
|
||||
# region Deal products
|
||||
@deal_router.post(
|
||||
'/products/update-quantity',
|
||||
response_model=DealUpdateProductQuantityResponse,
|
||||
operation_id='updateDealProductQuantity')
|
||||
async def products_update(
|
||||
request: DealUpdateProductQuantityRequest,
|
||||
session: Annotated[AsyncSession, Depends(get_session)]):
|
||||
return await DealService(session).update_product_quantity(request)
|
||||
|
||||
|
||||
# endpoint to get deal by id
|
||||
@deal_router.get(
|
||||
'/get/{deal_id}',
|
||||
response_model=DealSchema,
|
||||
operation_id='getDealById'
|
||||
)
|
||||
async def get_deal_by_id(
|
||||
deal_id: int,
|
||||
session: Annotated[AsyncSession, Depends(get_session)]
|
||||
):
|
||||
return await DealService(session).get_by_id(deal_id)
|
||||
@deal_router.post(
|
||||
'/products/add',
|
||||
response_model=DealAddProductResponse,
|
||||
operation_id='addDealProduct')
|
||||
async def products_add(
|
||||
request: DealAddProductRequest,
|
||||
session: Annotated[AsyncSession, Depends(get_session)]):
|
||||
return await DealService(session).add_product(request)
|
||||
|
||||
|
||||
@deal_router.post(
|
||||
'/products/delete',
|
||||
response_model=DealDeleteProductResponse,
|
||||
operation_id='deleteDealProduct')
|
||||
async def products_delete(
|
||||
request: DealDeleteProductRequest,
|
||||
session: Annotated[AsyncSession, Depends(get_session)]):
|
||||
return await DealService(session).delete_product(request)
|
||||
|
||||
|
||||
@deal_router.post(
|
||||
'/products/delete/multiple',
|
||||
response_model=DealDeleteProductsResponse,
|
||||
operation_id='deleteMultipleDealProducts')
|
||||
async def products_delete(
|
||||
request: DealDeleteProductsRequest,
|
||||
session: Annotated[AsyncSession, Depends(get_session)]):
|
||||
return await DealService(session).delete_products(request)
|
||||
|
||||
# endregion
|
||||
|
||||
@@ -62,3 +62,49 @@ async def get_product(
|
||||
session: Annotated[AsyncSession, Depends(get_session)]
|
||||
):
|
||||
return await ProductService(session).get_by_client_id(client_id, pagination)
|
||||
|
||||
|
||||
@product_router.get('/get-by-id',
|
||||
response_model=ProductSchema,
|
||||
operation_id='get_product_by_id')
|
||||
async def get_product_by_id(
|
||||
product_id: int,
|
||||
session: Annotated[AsyncSession, Depends(get_session)]
|
||||
):
|
||||
return await ProductService(session).get_by_id(product_id)
|
||||
|
||||
|
||||
@product_router.post(
|
||||
'/barcode/add',
|
||||
response_model=ProductAddBarcodeResponse,
|
||||
operation_id='add_product_barcode'
|
||||
)
|
||||
async def add_product_barcode(
|
||||
request: ProductAddBarcodeRequest,
|
||||
session: Annotated[AsyncSession, Depends(get_session)]
|
||||
):
|
||||
return await ProductService(session).add_barcode(request)
|
||||
|
||||
|
||||
@product_router.get(
|
||||
'/barcode/exists',
|
||||
response_model=ProductExistsBarcodeResponse,
|
||||
operation_id='exists_product_barcode'
|
||||
)
|
||||
async def exists_product_barcode(
|
||||
product_id: int,
|
||||
barcode: str,
|
||||
session: Annotated[AsyncSession, Depends(get_session)]
|
||||
):
|
||||
return await ProductService(session).exists_barcode(product_id, barcode)
|
||||
|
||||
@product_router.post(
|
||||
'/barcode/generate',
|
||||
response_model=ProductGenerateBarcodeResponse,
|
||||
operation_id='generate_product_barcode'
|
||||
)
|
||||
async def generate_product_barcode(
|
||||
request: ProductGenerateBarcodeRequest,
|
||||
session: Annotated[AsyncSession, Depends(get_session)]
|
||||
):
|
||||
return await ProductService(session).generate_barcode(request)
|
||||
|
||||
Reference in New Issue
Block a user