UserController.java 1.2 KB
Newer Older
Q
qinyingjie 已提交
1 2 3 4
package com.kwan.springbootkwan.controller;

import com.kwan.springbootkwan.entity.User;
import com.kwan.springbootkwan.service.IUserService;
Q
qinyingjie 已提交
5 6
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
Q
qinyingjie 已提交
7
import lombok.extern.slf4j.Slf4j;
Q
qinyingjie 已提交
8 9 10 11 12
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

Q
qinyingjie 已提交
13 14 15 16 17 18 19
/**
 * 用户相关
 *
 * @author : qinyingjie
 * @version : 2.2.0
 * @date : 2022/12/19 16:08
 */
Q
qinyingjie 已提交
20
@Slf4j
Q
qinyingjie 已提交
21
@Api(description = "用户信息", tags = "UserController")
Q
qinyingjie 已提交
22 23 24 25 26 27 28
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

Q
qinyingjie 已提交
29
    @ApiOperation(value = "获取所有用户", notes = "获取所有用户")
Q
qinyingjie 已提交
30 31
    @RequestMapping(value = "/all", method = RequestMethod.GET)
    public List<User> addAdvertise() {
Q
qinyingjie 已提交
32
        log.info("测试日志={}", "success");
Q
qinyingjie 已提交
33 34 35
        return userService.getUsers();
    }

Q
qinyingjie 已提交
36
    @ApiOperation(value = "根据id获取用户信息", notes = "根据id获取用户信息")
Q
qinyingjie 已提交
37 38 39 40 41
    @RequestMapping(value = "/getUserById/{id}", method = RequestMethod.GET)
    public User getUserById(@PathVariable Integer id) {
        return userService.getUserById(id);
    }
}