| | |
| | | package com.doumee.service.business.impl; |
| | | |
| | | import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckRequest; |
| | | import cn.binarywang.wx.miniapp.bean.security.WxMaMsgSecCheckCheckResponse; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import com.doumee.core.model.PageWrap; |
| | | import com.doumee.core.utils.Constants; |
| | | import com.doumee.core.utils.Utils; |
| | | import com.doumee.core.wx.WxMiniConfig; |
| | | import com.doumee.dao.business.*; |
| | | import com.doumee.dao.business.model.*; |
| | | import com.doumee.dao.web.dto.CommentDTO; |
| | |
| | | import com.doumee.service.business.CommentService; |
| | | import com.doumee.service.business.ZanService; |
| | | import com.github.yulichang.wrapper.MPJLambdaWrapper; |
| | | import me.chanjar.weixin.common.error.WxErrorException; |
| | | import org.apache.commons.collections4.MapUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | |
| | | |
| | | @Override |
| | | public Comment apply(CommentApplyRequest comment, Integer memberId) { |
| | | if (StringUtils.isNotBlank(comment.getContent())) { |
| | | try { |
| | | WxMaMsgSecCheckCheckRequest checkRequest = WxMaMsgSecCheckCheckRequest.builder() |
| | | .version("2") |
| | | .scene(3) |
| | | .openid(getMemberOpenId(memberId)) |
| | | .content(comment.getContent()) |
| | | .build(); |
| | | WxMaMsgSecCheckCheckResponse checkResponse = WxMiniConfig.wxMaService.getSecurityService().checkMessage(checkRequest); |
| | | if (checkResponse.getResult() != null && checkResponse.getResult().getSuggest() != null) { |
| | | String suggest = checkResponse.getResult().getSuggest(); |
| | | if ("risky".equalsIgnoreCase(suggest)) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "评论内容包含违规信息,请修改后重新发布"); |
| | | } |
| | | } |
| | | } catch (WxErrorException e) { |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "内容安全检测失败,请稍后重试"); |
| | | } |
| | | } |
| | | |
| | | Comment target = new Comment(); |
| | | target.setCreateDate(new Date()); |
| | | target.setEditDate(new Date()); |
| | |
| | | Utils.MP.blankToNull(pageWrap.getModel()); |
| | | replyWrapper.selectAs(Comment::getId,ActivityReplyCommentDTO::getId); |
| | | replyWrapper.selectAs(Comment::getReplyId,ActivityReplyCommentDTO::getReplyId); |
| | | replyWrapper.selectAs(Comment::getIsdeleted,ActivityReplyCommentDTO::getIsdeleted); |
| | | if(Objects.isNull(pageWrap.getModel().getMemberId())){ |
| | | replyWrapper.select(" 0 ",ActivityReplyCommentDTO::getZanStatus); |
| | | }else{ |
| | |
| | | if(Objects.nonNull(replyCommentDTO)){ |
| | | ZanDTO replyZan = MapUtils.getObject(count, replyCommentDTO.getId()); |
| | | replyCommentDTO.setZanCount(replyZan != null ? replyZan.getCount() : 0); |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | replyCommentDTO.setMultifileList(multifileList.stream().filter(t -> t.getObjId().equals(replyCommentDTO.getId())).collect(Collectors.toList())); |
| | | if(Constants.equalsInteger(replyCommentDTO.getIsdeleted(),Constants.ONE)){ |
| | | replyCommentDTO.setContent("该评论已被原作者删除"); |
| | | }else{ |
| | | if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){ |
| | | replyCommentDTO.setMultifileList(multifileList.stream().filter(t -> t.getObjId().equals(replyCommentDTO.getId())).collect(Collectors.toList())); |
| | | } |
| | | } |
| | | replyCommentDTO.setMemberImgUrl(StringUtils.isNotBlank(replyCommentDTO.getMemberImgUrl())?memberFile+replyCommentDTO.getMemberImgUrl():null); |
| | | s.setActivityReplyCommentDTO(replyCommentDTO); |
| | |
| | | }); |
| | | return PageData.from(result); |
| | | } |
| | | |
| | | private String getMemberOpenId(Integer memberId) { |
| | | Member member = memberMapper.selectById(memberId); |
| | | return member != null ? member.getOpenId() : null; |
| | | } |
| | | } |