Refactor DatasetController and DatasetService, update upvote and downvote endpoints

This commit refactors the `DatasetController` and `DatasetService` classes to update the endpoints for upvoting and downvoting datasets. The `@PostMapping` annotations are replaced with `@PutMapping` annotations to better align with RESTful conventions. This change improves the clarity and consistency of the API endpoints.
This commit is contained in:
Erik Foris 2024-06-25 09:19:24 +02:00
parent 5df6a65f1b
commit 6b588cba8c

View File

@ -51,19 +51,19 @@ public class DatasetController {
datasetService.deleteDataset(id);
}
@PostMapping("/id/{id}/upvote")
@PutMapping("/id/{id}/upvote")
public Dataset upvote(@PathVariable("id") UUID id) {
datasetService.upvoteDataset(id);
return null;
}
@PostMapping("/id/{id}/downvote")
@PutMapping("/id/{id}/downvote")
public Dataset downvote(@PathVariable("id") UUID id) {
datasetService.downvoteDataset(id);
return null; // new ResponseEntity<>(null, HttpStatus.OK);
}
@PostMapping("/id/{id}/vote")
@PutMapping("/id/{id}/vote")
public String postMethodName(@PathVariable("id") UUID id,
@RequestParam("stars") int stars) {
if (stars > 0 && stars < 6) {