|
@@ -10,7 +10,6 @@ import com.tzld.piaoquan.wecom.model.bo.VideoDetail;
|
|
|
import com.tzld.piaoquan.wecom.model.po.MessageAttachment;
|
|
|
import com.tzld.piaoquan.wecom.model.po.MessageAttachmentExample;
|
|
|
import com.tzld.piaoquan.wecom.model.po.Staff;
|
|
|
-import com.tzld.piaoquan.wecom.model.vo.MiniprogramVo;
|
|
|
import com.tzld.piaoquan.wecom.service.MessageAttachmentService;
|
|
|
import com.tzld.piaoquan.wecom.utils.DateUtil;
|
|
|
import com.tzld.piaoquan.wecom.utils.HttpClientUtil;
|
|
@@ -26,7 +25,6 @@ import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
|
|
|
import static com.tzld.piaoquan.wecom.common.constant.MessageConstant.appid;
|
|
|
-import static com.tzld.piaoquan.wecom.common.constant.MessageConstant.carrierIdMap;
|
|
|
import static com.tzld.piaoquan.wecom.common.constant.OtherServerURL.POST_ADD_TENCENT;
|
|
|
import static com.tzld.piaoquan.wecom.common.constant.OtherServerURL.POST_VIDEO_DETAIL_URL;
|
|
|
import static com.tzld.piaoquan.wecom.common.constant.RedisConstant.GUARANTEED_MINIPROGRAM_KEY;
|
|
@@ -63,32 +61,27 @@ public class MessageAttachmentServiceImpl implements MessageAttachmentService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void createGuaranteedMiniprogram(List<MiniprogramVo> miniprogramVoList) {
|
|
|
+ public void createGuaranteedMiniprogram(List<Long> videoIds) {
|
|
|
+ if (CollectionUtils.isEmpty(videoIds)) {
|
|
|
+ throw new CustomizeException(PARAMS_ERROR);
|
|
|
+ }
|
|
|
+ Map<Long, VideoDetail> coverMap = getVideoDetail(videoIds);
|
|
|
List<MessageAttachment> messageAttachmentList = new ArrayList<>();
|
|
|
- List<Long> videoList = new ArrayList<>();
|
|
|
- for (MiniprogramVo miniprogramVo : miniprogramVoList) {
|
|
|
- if (miniprogramVo.getVideoId() == null) {
|
|
|
- throw new CustomizeException(PARAMS_ERROR);
|
|
|
- }
|
|
|
+ for (Long videoId : videoIds) {
|
|
|
MessageAttachment messageAttachment = new MessageAttachment();
|
|
|
- BeanUtils.copyProperties(miniprogramVo, messageAttachment);
|
|
|
- messageAttachment.setMiniprogramVideoId(miniprogramVo.getVideoId());
|
|
|
- messageAttachment.setType(MessageAttachmentTypeEnum.MINIPROGRAM.getType());
|
|
|
- messageAttachmentList.add(messageAttachment);
|
|
|
- videoList.add(miniprogramVo.getVideoId());
|
|
|
- }
|
|
|
- Map<Long, VideoDetail> coverMap = getVideoDetail(videoList);
|
|
|
- for (MessageAttachment messageAttachment : messageAttachmentList) {
|
|
|
- VideoDetail videoDetail = coverMap.get(messageAttachment.getMiniprogramVideoId());
|
|
|
+ VideoDetail videoDetail = coverMap.get(videoId);
|
|
|
if (videoDetail == null || StringUtils.isEmpty(videoDetail.getCover()) || StringUtils.isEmpty(videoDetail.getTitle())) {
|
|
|
throw new RuntimeException("获取视频详情异常");
|
|
|
}
|
|
|
+ messageAttachment.setMiniprogramVideoId(videoId);
|
|
|
+ messageAttachment.setType(MessageAttachmentTypeEnum.MINIPROGRAM.getType());
|
|
|
messageAttachment.setCover(videoDetail.getCover());
|
|
|
messageAttachment.setTitle(videoDetail.getTitle());
|
|
|
messageAttachment.setAppid(appid);
|
|
|
+ messageAttachmentList.add(messageAttachment);
|
|
|
}
|
|
|
addMiniprogram(messageAttachmentList);
|
|
|
- for (Long video : videoList) {
|
|
|
+ for (Long video : videoIds) {
|
|
|
redisTemplate.opsForList().rightPush(GUARANTEED_MINIPROGRAM_KEY, video);
|
|
|
}
|
|
|
}
|