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 QuantService
16
quant_router = APIRouter(
17
responses={"400": {"model": ExceptionResponseSchema}},
21
@quant_router.get("", response_model=QuantListSchema)
23
model_filter: QuantFilter = FilterDepends(QuantFilter),
24
size: int = Query(ge=1, le=100, default=100),
25
service: QuantService = 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
@quant_router.post("", response_model=QuantScheme)
33
async def quant_create(schema: QuantCreateScheme, service: QuantService = Depends()):
34
return await service.create(obj=schema)
37
@quant_router.get("/{quant_id}", response_model=QuantScheme)
38
async def quant_get(quant_id: uuid.UUID, service: QuantService = Depends()):
39
return await service.get(id=quant_id)
42
@quant_router.put("/{quant_id}", response_model=QuantScheme)
43
async def quant_update(quant_id: uuid.UUID, schema: QuantUpdateScheme, service: QuantService = Depends()):
44
return await service.update(id=quant_id, obj=schema)
47
@quant_router.delete("/{quant_id}")
48
async def quant_delete(quant_id: uuid.UUID, service: QuantService = Depends()):
49
await service.delete(id=quant_id)