package com.example.demo.controller;

import com.example.demo.model.User;
import com.example.demo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping(“/user”)
public class UserController {

@Autowired
private UserService userService;

@GetMapping(“/all”)
public List getAllUsers(){
return userService.getAllUsers();
}

@PostMapping(“/add”)
public void addUser(@RequestBody User user){
userService.addUser(user);
}

@PutMapping(“/update”)
public void updateUser(@RequestBody User user){
userService.updateUser(user);
}

@DeleteMapping(“/delete/{id}”)
public void deleteUser(@PathVariable int id){
userService.deleteUser(id);
}
}

Pin It on Pinterest