| | |
| | | package com.panzhihua.applets.api; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import javax.validation.constraints.NotEmpty; |
| | | |
| | | import com.panzhihua.common.model.dtos.community.ComActDiscussVoteOptionDTO; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.PutMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.panzhihua.applets.weixin.CheckService; |
| | | import com.panzhihua.common.constants.Constants; |
| | | import com.panzhihua.common.controller.BaseController; |
| | | import com.panzhihua.common.model.dtos.community.ComActDiscussCommentDTO; |
| | | import com.panzhihua.common.model.dtos.community.ComActDiscussCommentUserDTO; |
| | | import com.panzhihua.common.model.dtos.community.ComActDiscussDTO; |
| | | import com.panzhihua.common.model.dtos.community.ComActDiscussOptionDTO; |
| | | import com.panzhihua.common.model.dtos.community.ComActDiscussOptionUserDTO; |
| | | import com.panzhihua.common.model.dtos.community.ComActDiscussUserDTO; |
| | | import com.panzhihua.common.model.dtos.community.DiscussVoteOptionDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageComActDiscussCommentDTO; |
| | | import com.panzhihua.common.model.dtos.community.PageComActDiscussDTO; |
| | | import com.panzhihua.common.model.dtos.community.*; |
| | | import com.panzhihua.common.model.dtos.community.integral.admin.AddComActIntegralUserDTO; |
| | | import com.panzhihua.common.model.vos.LoginUserInfoVO; |
| | | import com.panzhihua.common.model.vos.R; |
| | |
| | | import com.panzhihua.common.utlis.DateUtils; |
| | | import com.panzhihua.common.validated.AddGroup; |
| | | import com.panzhihua.common.validated.PutGroup; |
| | | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.util.ObjectUtils; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.validation.Valid; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * @program: springcloud_k8s_panzhihuazhihuishequ |
| | |
| | | @ApiOperation(value = "一起议-新增") |
| | | @PostMapping("discuss") |
| | | public R addDiscuss(@RequestBody @Validated(AddGroup.class) ComActDiscussDTO comActDiscussDTO) { |
| | | String openid = this.getLoginUserInfo().getOpenid(); |
| | | String appId = this.getAppId(); |
| | | // 微信内容审核 |
| | | String discussSubject = comActDiscussDTO.getDiscussSubject(); |
| | | if (!checkService.checkMessage(discussSubject)) { |
| | | return R.fail("内容违规"); |
| | | if (StrUtil.isNotBlank(discussSubject)) { |
| | | String result = checkService.checkMessageBy(discussSubject, openid, appId); |
| | | if (StrUtil.isNotBlank(result)) { |
| | | return R.fail(501, "填写内容存在 " + result + " 违规信息"); |
| | | } |
| | | } |
| | | |
| | | //微信图片审核 |
| | | String photoPah = comActDiscussDTO.getPhotoPah(); |
| | | if (StrUtil.isNotBlank(photoPah)) { |
| | | if (!checkService.checkImageBy(photoPah, appId)) { |
| | | return R.fail(501, "上传图片存在违规信息"); |
| | | } |
| | | } |
| | | |
| | | Integer type = comActDiscussDTO.getType(); |
| | | String voteTitle = comActDiscussDTO.getVoteTitle(); |
| | | List<ComActDiscussOptionDTO> discussOptions = comActDiscussDTO.getDiscussOptions(); |
| | |
| | | return communityService.pageDiscussApplets(pageComActDiscussDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "一起议-分页查询-脱敏", response = ComActDiscussVO.class) |
| | | @PostMapping("pageDiscussDesensitize") |
| | | public R pageDiscussDesensitize(@RequestBody PageComActDiscussDTO pageComActDiscussDTO) { |
| | | if (Objects.isNull(pageComActDiscussDTO.getType())) { |
| | | return R.fail("查询类型不能为空"); |
| | | } |
| | | LoginUserInfoVO loginUserInfo = this.getLoginUserInfoSureNoLogin(); |
| | | if (loginUserInfo != null) { |
| | | pageComActDiscussDTO.setCommunityId(loginUserInfo.getCommunityId()); |
| | | pageComActDiscussDTO.setLoginUserId(loginUserInfo.getUserId()); |
| | | |
| | | Integer isMy = pageComActDiscussDTO.getIsMy(); |
| | | if (null != isMy && isMy.intValue() == 1) { |
| | | pageComActDiscussDTO.setUserId(loginUserInfo.getUserId()); |
| | | } |
| | | } |
| | | return communityService.pageDiscussAppletsDesensitize(pageComActDiscussDTO); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "一起议-回复") |
| | | @PostMapping("discusscomment") |
| | | public R addDiscussComment(@RequestBody ComActDiscussCommentDTO comActDiscussCommentDTO) { |
| | |
| | | if (null == discussId || 0 == discussId) { |
| | | return R.fail("一起议主键不能为空"); |
| | | } |
| | | String result = checkService.checkMessageBy(comment, this.getLoginUserInfo().getOpenid(), this.getAppId()); |
| | | if (StrUtil.isNotBlank(result)) { |
| | | return R.fail(501, "填写内容存在 " + result + " 违规信息"); |
| | | } |
| | | comActDiscussCommentDTO.setUserId(this.getUserId()); |
| | | // 议事投票计算积分 |
| | | AddComActIntegralUserDTO integralUserDTO = new AddComActIntegralUserDTO(discussId, |
| | | AddComActIntegralUserDTO.integralType.cyystp, this.getCommunityId(), this.getUserId()); |
| | | AddComActIntegralUserDTO.integralType.cyystp, this.getCommunityId(), this.getUserId()); |
| | | integralUserDTO.setIsComment(1); |
| | | communityService.addIntegralTradeAdmin(integralUserDTO); |
| | | return communityService.addDiscussComment(comActDiscussCommentDTO); |
| | |
| | | return communityService.detailDiscussApplets(id, userId); |
| | | } |
| | | |
| | | @ApiOperation(value = "一起议-详情-脱敏", response = ComActDiscussVO.class) |
| | | @GetMapping("discussDesensitize") |
| | | @ApiImplicitParam(name = "id", value = "一起议主键", required = true) |
| | | public R detailDiscussDesensitize(@RequestParam("id") Long id) { |
| | | Long userId = 0L; |
| | | LoginUserInfoVO loginUserInfo = this.getLoginUserInfoSureNoLogin(); |
| | | if (loginUserInfo != null) { |
| | | userId = loginUserInfo.getUserId(); |
| | | } |
| | | return communityService.detailDiscussAppletsDesensitize(id, userId); |
| | | } |
| | | |
| | | @ApiOperation(value = "一起议-评论-分页查询", response = ComActDiscussCommentVO.class) |
| | | @PostMapping("pagediscusscomment") |
| | | public R pageDiscussComment(@RequestBody PageComActDiscussCommentDTO pageComActDiscussCommentDTO) { |
| | |
| | | return communityService.pageDiscussCommentApplets(pageComActDiscussCommentDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "一起议-评论-分页查询-脱敏", response = ComActDiscussCommentVO.class) |
| | | @PostMapping("pageDiscussCommentDesensitize") |
| | | public R pageDiscussCommentDesensitize(@RequestBody PageComActDiscussCommentDTO pageComActDiscussCommentDTO) { |
| | | Long id = pageComActDiscussCommentDTO.getId(); |
| | | if (null == id || 0 == id) { |
| | | return R.fail("一起议主键不能为空"); |
| | | } |
| | | Long userId = 0L; |
| | | LoginUserInfoVO loginUserInfo = this.getLoginUserInfoSureNoLogin(); |
| | | if (loginUserInfo != null) { |
| | | userId = loginUserInfo.getUserId(); |
| | | } |
| | | pageComActDiscussCommentDTO.setLoginUserId(userId); |
| | | return communityService.pageDiscussCommentAppletsDesensitize(pageComActDiscussCommentDTO); |
| | | } |
| | | |
| | | @ApiOperation(value = "一起议-评论-回复") |
| | | @PostMapping("discusscommentback") |
| | | public R addDiscussCommentBack(@RequestBody ComActDiscussCommentDTO comActDiscussCommentDTO) { |
| | |
| | | Long id = comActDiscussCommentDTO.getId(); |
| | | if (null == id || 0 == id) { |
| | | return R.fail("评论主键不能为空"); |
| | | } |
| | | String result = checkService.checkMessageBy(comment, this.getLoginUserInfo().getOpenid(), this.getAppId()); |
| | | if (StrUtil.isNotBlank(result)) { |
| | | return R.fail(501, "填写内容存在 " + result + " 违规信息"); |
| | | } |
| | | comActDiscussCommentDTO.setUserId(this.getUserId()); |
| | | return communityService.addDiscussCommentBack(comActDiscussCommentDTO); |
| | |
| | | @ApiOperation(value = "一起议-增加浏览量") |
| | | @PostMapping("discuss/increase-view-num") |
| | | public void increaseViewNum(@RequestParam("discussId") |
| | | @ApiParam(value = "一起议主键id", required = true) |
| | | Long discussId) { |
| | | @ApiParam(value = "一起议主键id", required = true) |
| | | Long discussId) { |
| | | communityService.increaseViewNum(discussId); |
| | | } |
| | | |