70%
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user