Developer 역할 Spring 골격 smoke (role-developer-live-v3-001)
This commit is contained in:
parent
7dc1a29dfa
commit
0180987ea1
1 changed files with 37 additions and 0 deletions
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue