赞
踩
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<User> 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);
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。