You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
981 B

package com.example.controller;
import com.example.pojo.Result;
import com.example.pojo.User;
import com.example.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
@Slf4j
public class UserController {
@Autowired
private UserService userService;
@GetMapping("/list/user")
public Result list(){
log.info("查询所有用户");
List<User> list = userService.list();
return Result.success(list);
}
@PostMapping("/list/add")
public Result add(@RequestBody User user){
log.info("新增用户");
userService.addUser(user);
return Result.success();
}
}