UserController.java
898 字节
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.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@Controller
@RequestMapping(value = "/user")
public class UserController {
@Autowired
private UserService userService;
@ResponseBody
@PostMapping("/add")
public int addUser(User user){
return userService.insert(user);
}
@ResponseBody
@GetMapping("all")
public Object findAllUser(
@RequestParam(name="pageNum",required = false,defaultValue = "1")
int pageNum,
@RequestParam(name = "pageSize",required = false,defaultValue = "10")
int pageSize){
return userService.findAllUser(pageNum,pageSize);
}
}