package com.example.fercoganbackend.controller; import com.example.fercoganbackend.entity.Puja; import com.example.fercoganbackend.service.PujaService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("/api/pujas") public class PujaController { @Autowired private PujaService pujaService; @GetMapping public List getAll() { return pujaService.findAll(); } @GetMapping("/id/{id}") public ResponseEntity getById(@PathVariable Long id) { return pujaService.findById(id) .map(ResponseEntity::ok) .orElse(ResponseEntity.notFound().build()); } @GetMapping("/informe/{remateId}") public List getForInforme(@PathVariable Long remateId){ return pujaService.fingForReporte(remateId); } @GetMapping("/remate/{id}") public List getForRemate(@PathVariable Long id){ return pujaService.findForRemtae(id); } //get coincidir con lote y remate @GetMapping("/loteyremate/{loteId}/{remateId}") public List getForLoteAndRemate(@PathVariable Long loteId,@PathVariable Long remateId){ return pujaService.findForLoteAndRemate(loteId,remateId); } @PostMapping public Puja create(@RequestBody Puja puja) { return pujaService.save(puja); } @PutMapping("/{id}") public ResponseEntity update(@PathVariable Long id, @RequestBody Puja remate) { return pujaService.findById(id) .map(r -> { remate.setId(id); return ResponseEntity.ok(pujaService.save(remate)); }) .orElse(ResponseEntity.notFound().build()); } @DeleteMapping("/{id}") public ResponseEntity delete(@PathVariable Long id) { pujaService.delete(id); return ResponseEntity.noContent().build(); } }