Implement PATCH
This commit is contained in:
parent
5eb33db38e
commit
2f2be651b3
@ -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)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user