3
from fastapi import APIRouter, Query, Request, Depends
4
from fastapi_filter import FilterDepends
6
from app.inventory.quant.schemas import (
10
ExceptionResponseSchema,
14
from app.inventory.quant.services import LotService
16
lot_router = APIRouter(
17
responses={"400": {"model": ExceptionResponseSchema}},
21
@lot_router.get("", response_model=LotListSchema)
23
model_filter: LotFilter = FilterDepends(LotFilter),
24
size: int = Query(ge=1, le=100, default=100),
25
service: LotService = Depends()
27
data = await service.list(model_filter, size)
28
cursor = model_filter.lsn__gt
29
return {'size': len(data), 'cursor': cursor, 'data': data}
32
@lot_router.post("", response_model=LotScheme)
33
async def lot_create(schema: LotCreateScheme, service: LotService = Depends()):
34
return await service.create(obj=schema)
37
@lot_router.get("/{lot_id}", response_model=LotScheme)
38
async def lot_get(lot_id: uuid.UUID, service: LotService = Depends()):
39
return await service.get(id=lot_id)
42
@lot_router.put("/{lot_id}", response_model=LotScheme)
43
async def lot_update(lot_id: uuid.UUID, schema: LotUpdateScheme, service: LotService = Depends()):
44
return await service.update(id=lot_id, obj=schema)
47
@lot_router.delete("/{lot_id}")
48
async def lot_delete(lot_id: uuid.UUID, service: LotService = Depends()):
49
await service.delete(id=lot_id)