backend con panel admin funcional
Some checks failed
Deploy Spring Boot App / build-and-deploy (push) Has been cancelled
Some checks failed
Deploy Spring Boot App / build-and-deploy (push) Has been cancelled
This commit is contained in:
@@ -6,6 +6,8 @@ import com.example.fercoganbackend.entity.Usuario;
|
||||
import com.example.fercoganbackend.otros.ConfirmadoTF;
|
||||
import com.example.fercoganbackend.service.ContadorService;
|
||||
import com.example.fercoganbackend.service.UsuarioService;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
@@ -25,13 +27,18 @@ public class AppController {
|
||||
|
||||
// Registro
|
||||
@PostMapping("/auth/registrar")
|
||||
public String registrar(@RequestParam String username,
|
||||
@RequestParam String password) {
|
||||
public ResponseEntity<String> registrar(@RequestParam String username,
|
||||
@RequestParam String password) {
|
||||
if (usuarioService.estaRegistrado(username)) {
|
||||
return ResponseEntity.status(HttpStatus.CONFLICT).body("Usuario ya existe ❌");
|
||||
}
|
||||
|
||||
usuarioService.registrarUsuario(username, password, Set.of(Rol.CLIENTE));
|
||||
return "Usuario registrado, pendiente de aprobación";
|
||||
return ResponseEntity.ok("Usuario registrado, pendiente de aprobación ✅");
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Verificar si aprobado
|
||||
@GetMapping("/auth/verificar/{username}")
|
||||
public ConfirmadoTF verificar(@PathVariable String username) {
|
||||
@@ -39,6 +46,22 @@ public class AppController {
|
||||
return aprobado;
|
||||
}
|
||||
|
||||
@GetMapping("/auth/existe/{username}")
|
||||
public ResponseEntity<ConfirmadoTF> existe(@PathVariable String username) {
|
||||
ConfirmadoTF aprobado = usuarioService.registradoYAprobado(username);
|
||||
|
||||
if (aprobado == null) {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).build();
|
||||
}
|
||||
|
||||
if (!aprobado.isConfirmed()) { // supongamos que ConfirmadoTF tiene isAprobado()
|
||||
return ResponseEntity.status(HttpStatus.UNAUTHORIZED).build();
|
||||
}
|
||||
|
||||
return ResponseEntity.ok(aprobado);
|
||||
}
|
||||
|
||||
|
||||
// Listar pendientes (solo admin/super)
|
||||
@GetMapping("/admin/pendientes")
|
||||
public List<Usuario> pendientes() {
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.example.fercoganbackend.controller;
|
||||
|
||||
import com.example.fercoganbackend.entity.Cabana;
|
||||
import com.example.fercoganbackend.service.CabanaService;
|
||||
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/cabanas")
|
||||
public class CabanaController {
|
||||
|
||||
@Autowired
|
||||
private CabanaService cabanaService;
|
||||
|
||||
@GetMapping
|
||||
public List<Cabana> getAll() {
|
||||
return cabanaService.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Cabana> getById(@PathVariable Long id) {
|
||||
return cabanaService.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Cabana create(@RequestBody Cabana remate) {
|
||||
return cabanaService.save(remate);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<Cabana> update(@PathVariable Long id, @RequestBody Cabana remate) {
|
||||
return cabanaService.findById(id)
|
||||
.map(r -> {
|
||||
remate.setId(id);
|
||||
return ResponseEntity.ok(cabanaService.save(remate));
|
||||
})
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> delete(@PathVariable Long id) {
|
||||
cabanaService.delete(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.example.fercoganbackend.controller;
|
||||
|
||||
import com.example.fercoganbackend.entity.Lote;
|
||||
import com.example.fercoganbackend.service.LoteService;
|
||||
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/lotes")
|
||||
public class LoteController {
|
||||
|
||||
@Autowired
|
||||
private LoteService loteService;
|
||||
|
||||
@GetMapping
|
||||
public List<Lote> getAll() {
|
||||
return loteService.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Lote> getById(@PathVariable Long id) {
|
||||
return loteService.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Lote create(@RequestBody Lote remate) {
|
||||
return loteService.save(remate);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<Lote> update(@PathVariable Long id, @RequestBody Lote remate) {
|
||||
return loteService.findById(id)
|
||||
.map(r -> {
|
||||
remate.setId(id);
|
||||
return ResponseEntity.ok(loteService.save(remate));
|
||||
})
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> delete(@PathVariable Long id) {
|
||||
loteService.delete(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.example.fercoganbackend.controller;
|
||||
|
||||
import com.example.fercoganbackend.entity.Remate;
|
||||
import com.example.fercoganbackend.service.RemateService;
|
||||
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/remates")
|
||||
public class RemateController {
|
||||
|
||||
@Autowired
|
||||
private RemateService remateService;
|
||||
|
||||
@GetMapping
|
||||
public List<Remate> getAll() {
|
||||
return remateService.findAll();
|
||||
}
|
||||
|
||||
@GetMapping("/{id}")
|
||||
public ResponseEntity<Remate> getById(@PathVariable Long id) {
|
||||
return remateService.findById(id)
|
||||
.map(ResponseEntity::ok)
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public Remate create(@RequestBody Remate remate) {
|
||||
return remateService.save(remate);
|
||||
}
|
||||
|
||||
@PutMapping("/{id}")
|
||||
public ResponseEntity<Remate> update(@PathVariable Long id, @RequestBody Remate remate) {
|
||||
return remateService.findById(id)
|
||||
.map(r -> {
|
||||
remate.setId(id);
|
||||
return ResponseEntity.ok(remateService.save(remate));
|
||||
})
|
||||
.orElse(ResponseEntity.notFound().build());
|
||||
}
|
||||
|
||||
@DeleteMapping("/{id}")
|
||||
public ResponseEntity<Void> delete(@PathVariable Long id) {
|
||||
remateService.delete(id);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.example.fercoganbackend.controller;
|
||||
|
||||
import com.example.fercoganbackend.service.UsuarioService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/user")
|
||||
public class UserController {
|
||||
@Autowired
|
||||
UsuarioService usuarioService;
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user