Class ProdottoController

java.lang.Object
it.unicam.cs.ids2425.FilieraAgricola.controller.ProdottoController

@RestController @RequestMapping("/api/prodotti") public class ProdottoController extends Object
Controller REST per la gestione dei Prodotti. Espone gli endpoint per la creazione, consultazione e sottomissione dei prodotti.
  • Constructor Details

    • ProdottoController

      public ProdottoController()
  • Method Details

    • creaProdotto

      @PostMapping @PreAuthorize("hasAnyRole(\'PRODUTTORE\', \'TRASFORMATORE\')") public org.springframework.http.ResponseEntity<ProdottoResponse> creaProdotto(@RequestBody ProdottoRequest request)
      Endpoint per la creazione di un nuovo prodotto. All'inizio il prodotto sarĂ  nello stato BOZZA.
    • sottomettiProdotto

      @PostMapping("/{id}/sottometti") @PreAuthorize("hasAnyRole(\'PRODUTTORE\', \'TRASFORMATORE\')") public org.springframework.http.ResponseEntity<Void> sottomettiProdotto(@PathVariable Long id)
      Endpoint usato dal proprietario per sottomettere il proprio prodotto (da BOZZA a IN_REVISIONE).
    • getAllProdotti

      @GetMapping public org.springframework.http.ResponseEntity<List<ProdottoResponse>> getAllProdotti()
      Ritorna tutti i prodotti APPROVATI (visibili pubblicamente).
    • getProdottoById

      @GetMapping("/{id}") public org.springframework.http.ResponseEntity<ProdottoResponse> getProdottoById(@PathVariable Long id)
      Ritorna i dettagli di un singolo prodotto tramite ID.
    • getProdottiByUtente

      @GetMapping("/utente/{utenteId}") @PreAuthorize("hasAnyRole(\'PRODUTTORE\', \'TRASFORMATORE\', \'GESTORE\', \'CURATORE\')") public org.springframework.http.ResponseEntity<List<ProdottoResponse>> getProdottiByUtente(@PathVariable Long utenteId)
      Ritorna i prodotti associati a un utente specifico.
    • aggiornaProdotto

      @PutMapping("/{id}") @PreAuthorize("hasAnyRole(\'PRODUTTORE\', \'TRASFORMATORE\')") public org.springframework.http.ResponseEntity<ProdottoResponse> aggiornaProdotto(@PathVariable Long id, @RequestBody ProdottoRequest request)
      Aggiorna le informazioni di un prodotto.
    • eliminaProdotto

      @DeleteMapping("/{id}") @PreAuthorize("hasAnyRole(\'PRODUTTORE\', \'TRASFORMATORE\', \'GESTORE\', \'CURATORE\')") public org.springframework.http.ResponseEntity<Void> eliminaProdotto(@PathVariable Long id)
      Elimina un prodotto.