buscar usuario por id
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:
@@ -78,6 +78,12 @@ public class UserController {
|
|||||||
return ResponseEntity.ok("Usuario eliminado correctamente");
|
return ResponseEntity.ok("Usuario eliminado correctamente");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/id/{username}")
|
||||||
|
public ResponseEntity<Long> getIdPorUsername(@PathVariable String username) {
|
||||||
|
Long id = service.findId(username);
|
||||||
|
return ResponseEntity.ok(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ✅ DTO interno para registro
|
// ✅ DTO interno para registro
|
||||||
public static class UsuarioRequest {
|
public static class UsuarioRequest {
|
||||||
|
|||||||
@@ -74,5 +74,14 @@ public class UsuarioService {
|
|||||||
repo.deleteById(id);
|
repo.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//encontrar el usuario por gmail
|
||||||
|
public Long findId(String username){
|
||||||
|
Usuario usuario = repo.findByUsername(username)
|
||||||
|
.orElseThrow(() -> new RuntimeException("Usuario no encontrado: " + username));
|
||||||
|
|
||||||
|
return usuario.getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
spring.application.name=fercoganbackend
|
spring.application.name=fercoganbackend
|
||||||
spring.profiles.active=prod
|
spring.profiles.active=dev
|
||||||
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
|
||||||
|
|
||||||
spring.jpa.hibernate.ddl-auto=update
|
spring.jpa.hibernate.ddl-auto=update
|
||||||
|
|||||||
Reference in New Issue
Block a user