Developer 역할 Spring 골격 smoke #4

Open
forge-bot wants to merge 9 commits from forge/role-developer-live-v3-001-attempt-1-run-2d01a4fe6309 into main
Showing only changes of commit 0180987ea1 - Show all commits

View file

@ -0,0 +1,37 @@
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<List<String>> getAllRoles() {
return ResponseEntity.ok(developerService.getAllRoles());
}
@GetMapping("/{role}")
public ResponseEntity<Map<String, String>> getRolePermission(@PathVariable String role) {
String permission = developerService.getRolePermission(role);
return ResponseEntity.ok(Map.of("role", role, "permission", permission));
}
@GetMapping("/{role}/check")
public ResponseEntity<Map<String, Boolean>> checkPermission(
@PathVariable String role,
@RequestParam String action) {
boolean allowed = developerService.hasPermission(role, action);
return ResponseEntity.ok(Map.of("action", action, "allowed", allowed));
}
}