huanghongfa
2020-12-10 f76377ffd111434d90c5aaf5507cd33a982d4aa6
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package com.panzhihua.applets.api;
 
import com.panzhihua.common.model.vos.community.ComActActivityVO;
import com.panzhihua.common.service.community.CommunityService;
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.RequestBody;
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;
    @Resource
    private CommunityService communityService;
 
    @ApiOperation(value = "当前登录用户信息",response = LoginUserInfoVO.class)
    @GetMapping("info")
    public R getUserInfo(){
        Long userId = this.getUserId();
        boolean empty = ObjectUtils.isEmpty(userId);
        if (empty) {
           throw new UnAuthenticationException();
        }
        R<LoginUserInfoVO> r = userService.getUserInfoByUserId(userId + "");
        return r;
    }
 
    @ApiOperation(value = "分页展示我的活动",response = ComActActivityVO.class)
    @GetMapping("pagemyactivity")
    public R pageMyActivity(@RequestBody ComActActivityVO comActActivityVO){
        Long userId = this.getUserId();
//        todo 我的活动包括普通社区活动、志愿者活动、党建活动
        comActActivityVO.setSponsorId(userId);//登录人id 暂时存入负责人字段
        R r = communityService.pageMyActivity(comActActivityVO);
        return r;
    }
}