add: saber el rol del usuario, poder crear roles
Some checks failed
Deploy Spring Boot App / build-and-deploy (push) Has been cancelled

This commit is contained in:
2026-02-20 12:17:19 -04:00
parent aa9b7d2056
commit 95c2e57ab1
2 changed files with 13 additions and 1 deletions

View File

@@ -8,7 +8,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/roles")
@RequestMapping("/api/roles")
public class RolesController {
final RolesRepository rolesRepository;

View File

@@ -12,7 +12,9 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@RestController
@@ -85,6 +87,16 @@ public class UserController {
return ResponseEntity.ok(id);
}
@GetMapping("/rol/{username}")
public ResponseEntity<Map<String, Long>> obtenerRolUsuario(@PathVariable String username) {
Long rolId = service.obtenerIdRolPorUsername(username);
Map<String, Long> response = new HashMap<>();
response.put("rolId", rolId);
return ResponseEntity.ok(response);
}
// ✅ DTO interno para registro