package com.pmu.betengine.controller; import com.pmu.betengine.model.Role; import com.pmu.betengine.service.RoleService; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import java.util.List; @RestController @RequestMapping("/api/v1/roles") @CrossOrigin public class RoleController { private final RoleService roleService; public RoleController(RoleService roleService) { this.roleService = roleService; } @PostMapping public ResponseEntity create(@RequestBody Role role) { return ResponseEntity.ok(roleService.create(role)); } @PutMapping("/{id}") public ResponseEntity update(@PathVariable Long id, @RequestBody Role role) { return ResponseEntity.ok(roleService.update(id, role)); } @GetMapping("/{id}") public ResponseEntity getById(@PathVariable Long id) { return ResponseEntity.ok(roleService.getById(id)); } @GetMapping public ResponseEntity> getAll() { return ResponseEntity.ok(roleService.getAll()); } @DeleteMapping("/{id}") public ResponseEntity delete(@PathVariable Long id) { roleService.delete(id); return ResponseEntity.noContent().build(); } }