package com.example.demo.controller; import com.example.demo.service.DeveloperService; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.List; import java.util.Map; @RestController @RequestMapping("/api/roles") public class DeveloperController { private final DeveloperService developerService; public DeveloperController(DeveloperService developerService) { this.developerService = developerService; } @GetMapping public ResponseEntity> getAllRoles() { return ResponseEntity.ok(developerService.getAllRoles()); } @GetMapping("/{role}") public ResponseEntity> getRolePermission(@PathVariable String role) { String permission = developerService.getRolePermission(role); return ResponseEntity.ok(Map.of("role", role, "permission", permission)); } @GetMapping("/{role}/check") public ResponseEntity> checkPermission( @PathVariable String role, @RequestParam String action) { boolean allowed = developerService.hasPermission(role, action); return ResponseEntity.ok(Map.of("action", action, "allowed", allowed)); } }