4
from fastapi import APIRouter, Query, Request, Depends
5
from fastapi_filter import FilterDepends
7
from app.inventory.order.schemas.move_schemas import (
12
MoveFilter, MoveConfirmScheme, GetMovesByBarcode,
14
from app.inventory.order.services.move_service import MoveService
16
move_router = APIRouter(
21
@move_router.get("", response_model=MoveListSchema)
23
model_filter: MoveFilter = FilterDepends(MoveFilter),
24
size: int = Query(ge=1, le=100, default=20),
25
service: MoveService = 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
@move_router.post("", response_model=MoveScheme)
33
async def move_create(schema: MoveCreateScheme, service: MoveService = Depends()):
34
return await service.create(obj=schema)
37
@move_router.get("/{move_id}", response_model=MoveScheme)
38
async def move_get(move_id: uuid.UUID, service: MoveService = Depends()) -> typing.Union[None, MoveScheme]:
39
return await service.get(id=move_id)
42
@move_router.put("/{move_id}", response_model=MoveScheme)
43
async def move_update(move_id: uuid.UUID, schema: MoveUpdateScheme, service: MoveService = Depends()):
44
return await service.update(id=move_id, obj=schema)
47
@move_router.delete("/{move_id}")
48
async def move_delete(move_id: uuid.UUID, service: MoveService = Depends()):
49
await service.delete(id=move_id)
52
@move_router.post("/confirm")
53
async def action_move_confirm(schema: MoveConfirmScheme, service: MoveService = Depends()):
54
return await service.confirm(moves=schema.ids)
56
@move_router.post("/get_moves_by_barcode", response_model=list[MoveScheme])
57
async def get_moves_by_barcode(schema: GetMovesByBarcode, service: MoveService = Depends()):
58
return await service.get_moves_by_barcode(barcode=schema.barcode, order_id=schema.order_id)