| | |
| | | package com.panzhihua.applets.api; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.panzhihua.applets.weixin.CheckService; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.model.dtos.partybuilding.ActivitySignUpDTO; |
| | | import com.panzhihua.common.model.dtos.partybuilding.ComPbActivityDTO; |
| | | import com.panzhihua.common.model.dtos.partybuilding.PageComPbServiceTeamDTO; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | | import com.panzhihua.common.model.vos.partybuilding.*; |
| | | import com.panzhihua.common.model.vos.user.SysUserNoticeVO; |
| | | import com.panzhihua.common.service.partybuilding.PartyBuildingService; |
| | | import com.panzhihua.common.service.user.UserService; |
| | | import com.panzhihua.common.validated.AddGroup; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | private PartyBuildingService partyBuildingService; |
| | | @Resource |
| | | private UserService userService; |
| | | @Resource |
| | | private CheckService checkService; |
| | | |
| | | @ApiOperation(value = "分页党建动态/政策文件",response =PartyCommitteeVO.class ) |
| | | @ApiOperation(value = "分页党建动态/政策文件",response =PartyBuildingComPbDynVO.class ) |
| | | @PostMapping("pagedynamic") |
| | | public R pageYnamic(@RequestBody PartyBuildingComPbDynVO partyBuildingComPbDynVO){ |
| | | Long communityId = this.getCommunityId(); |
| | |
| | | public R pageActivity(@RequestBody PartyBuildingActivityVO partyBuildingActivityVO) { |
| | | Long communityId = this.getCommunityId(); |
| | | partyBuildingActivityVO.setCommunityId(communityId); |
| | | Integer status = partyBuildingActivityVO.getStatus(); |
| | | if (null!=status&&status.intValue()==4) { |
| | | partyBuildingActivityVO.setIsAppliets(1); |
| | | } |
| | | return partyBuildingService.pageActivity(partyBuildingActivityVO); |
| | | } |
| | | |
| | | @ApiOperation(value = "动态/政策文件详情",response =PartyBuildingComPbDynVO.class ) |
| | | @GetMapping("infodynamic") |
| | | public R infoYnamic(@RequestParam("id") Long id) { |
| | | return partyBuildingService.infoYnamic(id); |
| | | R r = partyBuildingService.infoYnamic(id); |
| | | if (R.isOk(r)) { |
| | | if (ObjectUtils.isEmpty(id)||0==id) { |
| | | return R.fail("主键id不能为空"); |
| | | } |
| | | Long userId = this.getUserId(); |
| | | ComPbDynUserVO comPbDynUserVO=new ComPbDynUserVO(); |
| | | comPbDynUserVO.setCreateAt(new Date()); |
| | | comPbDynUserVO.setDynId(id); |
| | | comPbDynUserVO.setUserId(userId); |
| | | R r1 = partyBuildingService.addDynUser(comPbDynUserVO); |
| | | PartyBuildingComPbDynVO partyBuildingComPbDynVO=JSONObject.parseObject(JSONObject.toJSONString(r.getData()),PartyBuildingComPbDynVO.class); |
| | | if (R.isOk(r1)) { |
| | | partyBuildingComPbDynVO.setIsAdd(1); |
| | | }else{ |
| | | partyBuildingComPbDynVO.setIsAdd(0); |
| | | } |
| | | return R.ok(partyBuildingComPbDynVO); |
| | | } |
| | | return r; |
| | | } |
| | | |
| | | @ApiOperation(value = "增加阅读记录") |
| | | @PostMapping("adddynuser") |
| | | public R addDynUser(@RequestBody PartyBuildingComPbDynVO partyBuildingComPbDynVO) { |
| | | Long id = partyBuildingComPbDynVO.getId(); |
| | | if (ObjectUtils.isEmpty(id)||0==id) { |
| | | return R.fail("主键id不能为空"); |
| | | } |
| | | Long userId = this.getUserId(); |
| | | ComPbDynUserVO comPbDynUserVO=new ComPbDynUserVO(); |
| | | comPbDynUserVO.setCreateAt(new Date()); |
| | | comPbDynUserVO.setDynId(id); |
| | | comPbDynUserVO.setUserId(userId); |
| | | return partyBuildingService.addDynUser(comPbDynUserVO); |
| | | } |
| | | // @ApiOperation(value = "增加阅读记录") |
| | | // @PostMapping("adddynuser") |
| | | // public R addDynUser(@RequestBody PartyBuildingComPbDynVO partyBuildingComPbDynVO) { |
| | | // Long id = partyBuildingComPbDynVO.getId(); |
| | | // if (ObjectUtils.isEmpty(id)||0==id) { |
| | | // return R.fail("主键id不能为空"); |
| | | // } |
| | | // Long userId = this.getUserId(); |
| | | // ComPbDynUserVO comPbDynUserVO=new ComPbDynUserVO(); |
| | | // comPbDynUserVO.setCreateAt(new Date()); |
| | | // comPbDynUserVO.setDynId(id); |
| | | // comPbDynUserVO.setUserId(userId); |
| | | // return partyBuildingService.addDynUser(comPbDynUserVO); |
| | | // } |
| | | |
| | | @ApiOperation(value = "分页党委查询",response =PartyCommitteeVO.class ) |
| | | @PostMapping("pagepartycommittee") |
| | |
| | | sysUserNoticeVO.setTitle("报名成功"); |
| | | sysUserNoticeVO.setBusinessType(2); |
| | | sysUserNoticeVO.setBusinessTitle(partyBuildingActivityVO.getName()); |
| | | sysUserNoticeVO.setBusinessContent(String.format("活动将于%s开始,请按时参加",partyBuildingActivityVO.getActivityTimeBegin())); |
| | | Date activityTimeBegin = partyBuildingActivityVO.getActivityTimeBegin(); |
| | | sysUserNoticeVO.setBusinessContent(String.format("活动将于 %tF %tT 开始,请按时参加", activityTimeBegin,activityTimeBegin)); |
| | | sysUserNoticeVO.setBusinessId(id); |
| | | sysUserNoticeVO.setStatus(0); |
| | | sysUserNoticeVO.setBusinessStatus(2); |
| | |
| | | return r; |
| | | } |
| | | |
| | | @ApiOperation(value = "创建党员活动") |
| | | @PostMapping("activityinfo") |
| | | public R addActivityinfo(@RequestBody @Validated(AddGroup.class) ComPbActivityDTO comPbActivityDTO) { |
| | | // 微信内容审核 |
| | | String msg = comPbActivityDTO.getRichText(); |
| | | if (!checkService.checkMessage(msg)) { |
| | | return R.fail("内容违规"); |
| | | } |
| | | LoginUserInfoVO loginUserInfo = this.getLoginUserInfo(); |
| | | Long userId = loginUserInfo.getUserId(); |
| | | Long communityId = loginUserInfo.getCommunityId(); |
| | | comPbActivityDTO.setCreateBy(userId); |
| | | comPbActivityDTO.setCommunityId(communityId); |
| | | Date date=new Date(); |
| | | comPbActivityDTO.setReleaseTime(date); |
| | | Date activityTimeBegin = comPbActivityDTO.getActivityTimeBegin(); |
| | | Date activityTimeEnd = comPbActivityDTO.getActivityTimeEnd(); |
| | | boolean before = activityTimeEnd.before(activityTimeBegin); |
| | | if (before) { |
| | | return R.fail("活动结束时间不能早于开始时间"); |
| | | } |
| | | // 1 待发布 2 未开始 3 报名中 4 进行中 5 已结束 6 已取消 |
| | | int status=2; |
| | | Date enrollTimeBegin = comPbActivityDTO.getEnrollTimeBegin(); |
| | | Date enrollTimeEnd = comPbActivityDTO.getEnrollTimeEnd(); |
| | | if (enrollTimeEnd.before(enrollTimeBegin)) { |
| | | return R.fail("报名结束时间不能早于报名开始时间"); |
| | | } |
| | | if (enrollTimeBegin.before(date)) { |
| | | status=3; |
| | | } |
| | | comPbActivityDTO.setStatus(status); |
| | | return partyBuildingService.addActivityApplets(comPbActivityDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "分页查询服务团队成员",response = ComPbServiceTeamVO.class) |
| | | @PostMapping("pageserviceteam") |
| | | public R pageServiceTeam(@RequestBody PageComPbServiceTeamDTO pageComPbServiceTeamDTO) { |
| | | pageComPbServiceTeamDTO.setCommunityId(this.getCommunityId()); |
| | | return partyBuildingService.pageServiceTeam(pageComPbServiceTeamDTO); |
| | | } |
| | | |
| | | |
| | | public static void main(String[] args) { |
| | | Date date = new Date(); |
| | | String dateFormat = String.format("%tF %tT ", date, date); |
| | | System.out.println(dateFormat); |
| | | } |
| | | } |