backend con panel admin funcional
Some checks failed
Deploy Spring Boot App / build-and-deploy (push) Has been cancelled

This commit is contained in:
2025-10-01 16:45:24 -04:00
parent ef2b6c1870
commit 2f9142e1b5
21 changed files with 719 additions and 3 deletions

View File

@@ -0,0 +1,50 @@
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<Puja> getAll() {
return pujaService.findAll();
}
@GetMapping("/{id}")
public ResponseEntity<Puja> getById(@PathVariable Long id) {
return pujaService.findById(id)
.map(ResponseEntity::ok)
.orElse(ResponseEntity.notFound().build());
}
@PostMapping
public Puja create(@RequestBody Puja remate) {
return pujaService.save(remate);
}
@PutMapping("/{id}")
public ResponseEntity<Puja> 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<Void> delete(@PathVariable Long id) {
pujaService.delete(id);
return ResponseEntity.noContent().build();
}
}