Implement PATCH

This commit is contained in:
Joshua Sigona 2020-07-23 04:33:28 +09:00
parent 5eb33db38e
commit 2f2be651b3

View File

@ -2,6 +2,7 @@ package com.example.demo;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PatchMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
@ -54,6 +55,14 @@ public class Controller {
return "ID "+id+" does not exist!";
}
}
@PatchMapping("/data/{id}")
public Object _6(@PathVariable Long id,@RequestBody Data data) {
if (database.existsById(id)) {
return database.save(data);
} else {
return "ID "+id+" does not exist!";
}
}
@DeleteMapping("/data/{id}")
public String _4(@PathVariable Long id) {
if (database.existsById(id)) {