Class StockController

java.lang.Object
com.deusto.coffeestack.controller.StockController

@RestController @RequestMapping("/api/stock") public class StockController extends Object
REST controller for stock consultation.

Endpoints:

  • GET /api/stock/insumos – stock summary for all insumos
  • GET /api/stock/insumos/{id} – stock detail (with lote breakdown) for one insumo
  • Constructor Details

    • StockController

      public StockController(StockService stockService)
  • Method Details

    • getAllStock

      @GetMapping("/insumos") public List<StockInsumoResponse> getAllStock()
      Returns stock summary (total quantity + shortage flag + lote detail) for every insumo.
    • getStockByInsumo

      @GetMapping("/insumos/{id}") public StockInsumoResponse getStockByInsumo(@PathVariable Long id)
      Returns stock detail for a single insumo. Returns 404 if the insumo does not exist.
    • getCobertura

      @GetMapping("/cobertura") @PreAuthorize("hasAnyRole(\'PROPIETARIO\',\'ROOT\')") public List<CoberturaInsumoResponse> getCobertura(@RequestParam(defaultValue="30") int ventana)
      Returns estimated coverage days per insumo, sorted from most critical to safest.

      Coverage days = total stock / average daily consumption over the given window. Restricted to PROPIETARIO and ROOT roles.