|
@@ -4,7 +4,9 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
|
|
|
import com.tzld.piaoquan.growth.common.common.constant.MessageConstant;
|
|
|
+import com.tzld.piaoquan.growth.common.common.enums.ExceptionCodeEnum;
|
|
|
import com.tzld.piaoquan.growth.common.common.enums.MessageAttachmentTypeEnum;
|
|
|
+import com.tzld.piaoquan.growth.common.common.exception.CustomizeException;
|
|
|
import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
|
|
|
import com.tzld.piaoquan.growth.common.component.ProxyHttpPoolClient;
|
|
|
import com.tzld.piaoquan.growth.common.dao.mapper.GuaranteesVideoMapper;
|
|
@@ -17,10 +19,7 @@ import com.tzld.piaoquan.growth.common.model.vo.GuaranteedParam;
|
|
|
import com.tzld.piaoquan.growth.common.service.WeComAccessTokenService;
|
|
|
import com.tzld.piaoquan.growth.common.service.MessageAttachmentService;
|
|
|
import com.tzld.piaoquan.growth.common.service.WeComSendService;
|
|
|
-import com.tzld.piaoquan.growth.common.utils.DateUtil;
|
|
|
-import com.tzld.piaoquan.growth.common.utils.FileUtils;
|
|
|
-import com.tzld.piaoquan.growth.common.utils.LarkRobotUtil;
|
|
|
-import com.tzld.piaoquan.growth.common.utils.ToolUtils;
|
|
|
+import com.tzld.piaoquan.growth.common.utils.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import lombok.val;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -152,10 +151,13 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
|
return voidCommonResponse;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- Map<Long, VideoDetail> coverMap = getVideoDetail(videoIds);
|
|
|
- Map<Long, MessageAttachment> messageAttachmentMap = createMessageAttachmentMap(videoIds, coverMap);
|
|
|
-
|
|
|
+ Map<Long, MessageAttachment> messageAttachmentMap;
|
|
|
+ try {
|
|
|
+ Map<Long, VideoDetail> coverMap = getVideoDetail(videoIds);
|
|
|
+ messageAttachmentMap = createMessageAttachmentMap(videoIds, coverMap);
|
|
|
+ } catch (CustomizeException e) {
|
|
|
+ return CommonResponse.create(500, e.getMessage());
|
|
|
+ }
|
|
|
List<MessageAttachment> messageAttachmentList = new ArrayList<>();
|
|
|
for (VideoParam videoParam : guaranteedParam.getVideoParamList()) {
|
|
|
addMessageAttachments(videoParam, messageAttachmentMap, guaranteedParam.getDate(), messageAttachmentList);
|
|
@@ -215,8 +217,10 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
|
for (Long videoId : videoIds) {
|
|
|
VideoDetail videoDetail = coverMap.get(videoId);
|
|
|
if (videoDetail == null || StringUtils.isEmpty(videoDetail.getCover()) || StringUtils.isEmpty(videoDetail.getTitle())) {
|
|
|
- LarkRobotUtil.sendMessage("获取视频详情异常,请查看" + videoId);
|
|
|
- throw new RuntimeException("获取视频详情异常");
|
|
|
+ throw new CustomizeException(ExceptionCodeEnum.PARAMS_ERROR, "获取视频详情异常,请查看:" + videoId);
|
|
|
+ }
|
|
|
+ if (!ImageUrlValidator.isValidImageUrl(videoDetail.getCover())) {
|
|
|
+ throw new CustomizeException(ExceptionCodeEnum.PARAMS_ERROR, "保底视频封面异常,请查看:" + videoId);
|
|
|
}
|
|
|
MessageAttachment messageAttachment = new MessageAttachment();
|
|
|
messageAttachment.setMiniprogramVideoId(videoId);
|