| | |
| | | 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()); |
| | |
| | | }); |
| | | return PageData.from(result); |
| | | } |
| | | |
| | | private String getMemberOpenId(Integer memberId) { |
| | | Member member = memberMapper.selectById(memberId); |
| | | return member != null ? member.getOpenId() : null; |
| | | } |
| | | } |