This commit is contained in:
Dede
2025-11-25 17:07:27 +00:00
parent c13e5b1dfc
commit 7d2cc98d2c
39 changed files with 881 additions and 390 deletions

View File

@@ -0,0 +1,46 @@
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<Role> create(@RequestBody Role role) {
return ResponseEntity.ok(roleService.create(role));
}
@PutMapping("/{id}")
public ResponseEntity<Role> update(@PathVariable Long id, @RequestBody Role role) {
return ResponseEntity.ok(roleService.update(id, role));
}
@GetMapping("/{id}")
public ResponseEntity<Role> getById(@PathVariable Long id) {
return ResponseEntity.ok(roleService.getById(id));
}
@GetMapping
public ResponseEntity<List<Role>> getAll() {
return ResponseEntity.ok(roleService.getAll());
}
@DeleteMapping("/{id}")
public ResponseEntity<Void> delete(@PathVariable Long id) {
roleService.delete(id);
return ResponseEntity.noContent().build();
}
}