huanghongfa
2020-12-03 00036b47f300ac0221075aab1e2d366003195289
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.panzhihua.applets.api;
 
import com.panzhihua.common.service.user.UserService;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.exceptions.UnAuthenticationException;
import com.panzhihua.common.model.vos.LoginUserInfoVO;
import com.panzhihua.common.model.vos.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.annotation.Resource;
 
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
 * @description: 用户
 * @author: huang.hongfa weixin hhf9596 qq 959656820
 * @create: 2020-11-24 12:03
 **/
@RestController
@RequestMapping("/user/")
@Api(tags = {"用户模块"})
public class UserApi extends BaseController {
    @Resource
    private UserService userService;
 
    @ApiOperation(value = "当前登录用户信息",response = LoginUserInfoVO.class)
    @GetMapping("info")
    public R getUserInfo(){
        Integer userId = this.getUserId();
        boolean empty = ObjectUtils.isEmpty(userId);
        if (empty) {
           throw new UnAuthenticationException();
        }
        R<LoginUserInfoVO> r = userService.getUserInfoByUserId(userId + "");
        return r;
    }
}