Files
CRM-OLD-API/app/api/v1/residues.py
2025-07-24 20:13:47 +03:00

77 lines
1.9 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from time import time
from fastapi import APIRouter
from app import mongo
from app.utils.response_util import response
router = APIRouter()
@router.post("/pallet", tags=[""])
async def pallet(params: dict):
start_time = time()
client_id = params["clientId"]
await mongo.client_pallets_collection.insert_one({
"id": await mongo.get_next_id(mongo.client_pallets_collection),
"createdAt": mongo.created_at(),
"clientId": client_id,
"boxes": list(),
"residualProducts": list()
})
return response({
"message": "Паллет успешно добавлен",
"ok": True
}, start_time=start_time)
@router.delete("/pallet/{pallet_id}", tags=[""])
async def delete_pallet(pallet_id: int):
start_time = time()
await mongo.client_pallets_collection.delete_one({
"id": pallet_id
})
return response({
"message": "Паллет успешно удален",
"ok": True
}, start_time=start_time)
@router.post("/box", tags=[""])
async def box(params: dict):
start_time = time()
client_id = params["clientId"]
pallet_id = params["palletId"]
await mongo.client_boxes_collection.insert_one({
"id": await mongo.get_next_id(mongo.client_boxes_collection),
"createdAt": mongo.created_at(),
"clientId": client_id,
"palletId": pallet_id,
"boxes": list(),
"residualProducts": list()
})
return response({
"message": "Короб успешно создан",
"ok": True
}, start_time=start_time)
@router.delete("/box/{box_id}", tags=[""])
async def delete_box(box_id: int):
start_time = time()
await mongo.client_boxes_collection.delete_one({
"id": box_id
})
return response({
"message": "Короб успешно удален",
"ok": True
}, start_time=start_time)