anotherAPI
This commit is contained in:
parent
d79235ed55
commit
1e3a6a3d43
@ -37,4 +37,20 @@ public class UserController {
|
||||
userRepo.save(user);
|
||||
return "Saved...";
|
||||
}
|
||||
@PutMapping("/update/{id}")
|
||||
public String updateUser(@PathVariable long id, @RequestBody User user){
|
||||
User updapteUser = userRepo.findById(id).get();
|
||||
updapteUser.setName(user.getName());
|
||||
updapteUser.setAge(user.getAge());
|
||||
updapteUser.setEmail(user.getEmail());
|
||||
userRepo.save(updapteUser);
|
||||
return "Recored Updated...";
|
||||
}
|
||||
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public String deleteUser(@PathVariable long id){
|
||||
User deleteUser = userRepo.findById(id).get();
|
||||
userRepo.delete(deleteUser);
|
||||
return "Record with id " + id + " has been deleted...";
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,7 @@ public class User {
|
||||
private String email;
|
||||
|
||||
public User(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
public User(int id, String name, int age, String email) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user