huanghongfa
2021-01-07 ae33fef700e5d2558dffb03c8f66358da2545791
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package com.panzhihua.applets.api;
 
import com.alibaba.fastjson.JSONObject;
import com.panzhihua.common.controller.BaseController;
import com.panzhihua.common.model.dtos.community.PageVolunteerDTO;
import com.panzhihua.common.model.vos.R;
import com.panzhihua.common.model.vos.community.*;
import com.panzhihua.common.model.vos.partybuilding.PartyBuildingActivityVO;
import com.panzhihua.common.model.vos.user.SysUserNoticeVO;
import com.panzhihua.common.service.community.CommunityService;
import com.panzhihua.common.service.user.UserService;
import com.panzhihua.common.validated.AddGroup;
import com.panzhihua.common.validated.PageGroup;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
 
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
 * @description: 社区服务
 * @author: huang.hongfa weixin hhf9596 qq 959656820
 * @create: 2020-12-10 10:04
 **/
@Slf4j
@RestController
@RequestMapping("/community/")
@Api(tags = {"社区服务"})
public class CommunityApi extends BaseController {
    @Resource
    private CommunityService communityService;
    @Resource
    private UserService userService;
 
    @ApiOperation(value = "分页获取社区动态",response = ComActDynVO.class)
    @PostMapping("pagedynamic")
    public R pageDynamic(@RequestBody ComActDynVO comActDynVO){
        Long communityId = this.getCommunityId();
        comActDynVO.setCommunityId(communityId);
        comActDynVO.setIsTopping(null);
        comActDynVO.setStatus(null);
        return communityService.pageDynamic(comActDynVO);
    }
 
    @ApiOperation(value = "社区动态详情",response = ComActDynVO.class)
    @GetMapping("detaildynamic")
    @ApiImplicitParam(name ="id",value = "社区动态主键",required = true)
    public R detailDynamic(@RequestParam("id") Long id){//todo 增加微信分享接口
        return communityService.detailDynamic(id);
    }
 
    @ApiOperation(value = "分页查询社区活动",response = ComActActivityVO.class)
    @PostMapping("pageactivity")
    public R pageActivity(@RequestBody ComActActivityVO comActActivityVO){
        Long communityId = this.getCommunityId();
        comActActivityVO.setCommunityId(communityId);
        return communityService.pageActivity(comActActivityVO);
    }
 
    @ApiOperation(value = "社区活动/志愿者活动详情",response = ComActActivityVO.class)
    @GetMapping("detailactivity")
    @ApiImplicitParam(name ="id",value = "社区活动主键",required = true)
    public R detailActivity(@RequestParam("id") Long id){
        Long userId = this.getUserId();
        return communityService.detailActivity(id,userId);
    }
 
    @ApiOperation(value = "报名/取消报名社区活动")
    @PutMapping("signactivity")
    public R signActivity(@RequestBody @Validated(AddGroup.class) SignactivityVO signactivityVO){
        Long userId = this.getUserId();
        Long activityId = signactivityVO.getActivityId();
        signactivityVO.setUserId(userId);
        R r = communityService.signActivity(signactivityVO);
        if (R.isOk(r)&&signactivityVO.getType().intValue()==1) {
            R r2 = communityService.detailActivity(activityId, userId);
            ComActActivityVO comActActivityVO= JSONObject.parseObject(JSONObject.toJSONString(r2.getData()),ComActActivityVO.class);
            SysUserNoticeVO sysUserNoticeVO=new SysUserNoticeVO();
            sysUserNoticeVO.setUserId(userId);
            sysUserNoticeVO.setType(1);
            sysUserNoticeVO.setTitle("报名成功");
            sysUserNoticeVO.setBusinessType(1);
            sysUserNoticeVO.setBusinessTitle(comActActivityVO.getActivityName());
            sysUserNoticeVO.setBusinessContent(String.format("活动将于%s开始,请按时参加",comActActivityVO.getBeginAt()));
            sysUserNoticeVO.setBusinessId(activityId);
            sysUserNoticeVO.setStatus(0);
            sysUserNoticeVO.setBusinessStatus(2);
            R r1 = userService.addNotice(sysUserNoticeVO);
            if (R.isOk(r1)) {
                log.info("新增用户报名社区活动通知成功【{}】", JSONObject.toJSONString(sysUserNoticeVO));
            }
        }
        return r;
    }
 
    @ApiOperation(value = "活动人员列表",response = ActivitySignVO.class)
    @ApiImplicitParam(name ="id",value = "社区活动主键",required = true)
    @GetMapping("listactivitysign")
    public R listActivitySign(@RequestParam("id") Long id){
        ActivitySignVO activitySignVO=new ActivitySignVO();
        activitySignVO.setActivityId(id);
        return communityService.listActivitySign(activitySignVO);
    }
 
    @ApiOperation(value = "新增社区动态浏览记录")
    @PostMapping("dynamicuser")
    public R addDynamicUser(@RequestBody ComActDynVO comActDynVO){
        Long id = comActDynVO.getId();
        if (null==id||id==0) {
            return R.fail("社区动态不存在");
        }
        Long userId = this.getUserId();
        return communityService.addDynamicUser(id,userId);
    }
 
    @ApiOperation(value = "志愿者申请")
    @PostMapping("volunteer")
    public R addVolunteer(@RequestBody @Validated(AddGroup.class) ComMngVolunteerMngVO comMngVolunteerMngVO){
        comMngVolunteerMngVO.setState(1);
        return communityService.addVolunteer(comMngVolunteerMngVO);
    }
 
    @ApiOperation(value = "分页查询志愿者团队")
    @PostMapping("pagevolunteer")
    public R pageVolunteer(@RequestBody @Validated(PageGroup.class) PageVolunteerDTO pageVolunteerDTO){
        Long communityId = this.getCommunityId();
        ComMngVolunteerMngVO comMngVolunteerMngVO=new ComMngVolunteerMngVO();
        comMngVolunteerMngVO.setCommunityId(communityId);
        comMngVolunteerMngVO.setPageNum(pageVolunteerDTO.getPageNum());
        comMngVolunteerMngVO.setPageSize(pageVolunteerDTO.getPageSize());
        return communityService.pageVolunteer(comMngVolunteerMngVO);
    }
 
    @ApiOperation(value = "志愿者详情",response = ComMngVolunteerMngAppletsVO.class)
    @GetMapping("volunteer")
    public R detailVolunteer(@RequestParam("id") Long id){
        return communityService.detailVolunteer(id);
    }
 
 
}