Commit a7f61b2c by 李传峰

Merge branch 'release' into 'master'

feat: [10073776] 多渠道

See merge request rays/pcloud-book!1614
parents 2e65cc1b 3b00bf89
...@@ -6,6 +6,7 @@ package com.pcloud.book.consumer.user; ...@@ -6,6 +6,7 @@ package com.pcloud.book.consumer.user;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.pcloud.channelcenter.base.exceptions.ChannelBizException; import com.pcloud.channelcenter.base.exceptions.ChannelBizException;
import com.pcloud.channelcenter.channel.dto.BiliVideoDTO;
import com.pcloud.channelcenter.channel.dto.DouyinVideoDTO; import com.pcloud.channelcenter.channel.dto.DouyinVideoDTO;
import com.pcloud.channelcenter.channel.service.ChannelCenterService; import com.pcloud.channelcenter.channel.service.ChannelCenterService;
import com.pcloud.channelcenter.qrcode.dto.AdviserQrcodeSceneDTO; import com.pcloud.channelcenter.qrcode.dto.AdviserQrcodeSceneDTO;
...@@ -408,4 +409,18 @@ public class ChannelConsr { ...@@ -408,4 +409,18 @@ public class ChannelConsr {
} }
return douyinVideoDTOMap; return douyinVideoDTOMap;
} }
public Map<String, BiliVideoDTO> getBiliVideoByItemIds(List<String> itemIds) {
Map<String, BiliVideoDTO> biliVideoDTOMap = new HashMap<>();
if (CollUtil.isEmpty(itemIds)) {
return biliVideoDTOMap;
}
try {
biliVideoDTOMap = ResponseHandleUtil.parseMap(channelCenterService.getBiliVideoByItemIds(itemIds), String.class, BiliVideoDTO.class);
} catch (BizException e) {
LOGGER.warn("channelCenterService.getBiliVideoByItemIds" + e.getMessage(), e);
}
return biliVideoDTOMap;
}
} }
...@@ -10,6 +10,8 @@ import com.pcloud.book.group.dto.MultiChannelContentDTO; ...@@ -10,6 +10,8 @@ import com.pcloud.book.group.dto.MultiChannelContentDTO;
import com.pcloud.book.group.dto.MultiChannelContentItemDTO; import com.pcloud.book.group.dto.MultiChannelContentItemDTO;
import com.pcloud.book.group.entity.MultiChannelContent; import com.pcloud.book.group.entity.MultiChannelContent;
import com.pcloud.book.group.entity.MultiChannelContentItem; import com.pcloud.book.group.entity.MultiChannelContentItem;
import com.pcloud.channelcenter.base.constants.ChannelTypeEnum;
import com.pcloud.channelcenter.channel.dto.BiliVideoDTO;
import com.pcloud.channelcenter.channel.dto.DouyinVideoDTO; import com.pcloud.channelcenter.channel.dto.DouyinVideoDTO;
import com.pcloud.common.core.aspect.ParamLog; import com.pcloud.common.core.aspect.ParamLog;
import com.pcloud.common.exceptions.BizException; import com.pcloud.common.exceptions.BizException;
...@@ -138,23 +140,73 @@ public class MultiChannelContentBizImpl implements MultiChannelContentBiz { ...@@ -138,23 +140,73 @@ public class MultiChannelContentBizImpl implements MultiChannelContentBiz {
return multiChannelContentDTOS; return multiChannelContentDTOS;
} }
List<MultiChannelContent> multiChannelContents = multiChannelContentDao.selectList(multiChannelContentIds); List<MultiChannelContent> multiChannelContents = multiChannelContentDao.selectList(multiChannelContentIds);
List<MultiChannelContentItemDTO> multiChannelContentItemDTOS = multiChannelContentItemBiz.getByMultiChannelContentId(multiChannelContentIds); if (CollUtil.isEmpty(multiChannelContents)) {
if (CollUtil.isEmpty(multiChannelContents) || CollUtil.isEmpty(multiChannelContentItemDTOS)) {
return multiChannelContentDTOS; return multiChannelContentDTOS;
} }
multiChannelContentDTOS = BeanUtil.copyToList(multiChannelContents, MultiChannelContentDTO.class); List<Long> contentIds4Douyin = multiChannelContents.stream().filter(e -> ChannelTypeEnum.DOUYIN.code.equals(e.getChannelType())).map(f -> f.getId()).collect(Collectors.toList());
List<String> itemIds = multiChannelContentItemDTOS.stream().map(e -> e.getItemId()).collect(Collectors.toList()); List<Long> contentIds4Bili = multiChannelContents.stream().filter(e -> ChannelTypeEnum.BILI.code.equals(e.getChannelType())).map(f -> f.getId()).collect(Collectors.toList());
Map<String, DouyinVideoDTO> douyinVideoDTOMap = channelConsr.getDouyinVideoByItemIds(itemIds); if (CollUtil.isNotEmpty(contentIds4Douyin)) {
multiChannelContentItemDTOS.stream().forEach(e -> { //填充抖音视频
if (CollUtil.isNotEmpty(douyinVideoDTOMap) || null != douyinVideoDTOMap.get(e.getItemId())) { multiChannelContentDTOS = getMultiChannelContentDTOS4Douyin(multiChannelContentDTOS, multiChannelContents, contentIds4Douyin);
DouyinVideoDTO douyinVideoDTO = douyinVideoDTOMap.get(e.getItemId()); }
BeanUtil.copyProperties(douyinVideoDTO, e, "id"); if (CollUtil.isNotEmpty(contentIds4Bili)) {
} //填充bili视频
}); multiChannelContentDTOS = getMultiChannelContentDTOS4Bili(multiChannelContentDTOS, multiChannelContents, contentIds4Bili);
Map<Long, List<MultiChannelContentItemDTO>> itemDTOMap = multiChannelContentItemDTOS.stream().collect(Collectors.groupingBy(MultiChannelContentItemDTO::getMultiChannelContentId)); }
multiChannelContentDTOS.stream().forEach(e -> { return multiChannelContentDTOS;
e.setMultiChannelContentItems(itemDTOMap.get(e.getId())); }
});
private List<MultiChannelContentDTO> getMultiChannelContentDTOS4Bili(List<MultiChannelContentDTO> multiChannelContentDTOS, List<MultiChannelContent> multiChannelContents, List<Long> contentIds4Bili) {
//获取抖音视频
List<MultiChannelContentItemDTO> multiChannelContentItemDTOS = multiChannelContentItemBiz.getByMultiChannelContentId(contentIds4Bili);
List<MultiChannelContentDTO> multiChannelContentDTOS4Bili = new ArrayList<>();
if (CollUtil.isNotEmpty(multiChannelContentItemDTOS)) {
multiChannelContentDTOS4Bili = BeanUtil.copyToList(multiChannelContents, MultiChannelContentDTO.class);
List<String> itemIds = multiChannelContentItemDTOS.stream().map(e -> e.getItemId()).collect(Collectors.toList());
Map<String, BiliVideoDTO> biliVideoDTOMap = channelConsr.getBiliVideoByItemIds(itemIds);
multiChannelContentItemDTOS.stream().forEach(e -> {
if (CollUtil.isNotEmpty(biliVideoDTOMap) || null != biliVideoDTOMap.get(e.getItemId())) {
BiliVideoDTO biliVideoDTO = biliVideoDTOMap.get(e.getItemId());
BeanUtil.copyProperties(biliVideoDTO, e, "id");
}
});
Map<Long, List<MultiChannelContentItemDTO>> itemDTOMap = multiChannelContentItemDTOS.stream().collect(Collectors.groupingBy(MultiChannelContentItemDTO::getMultiChannelContentId));
multiChannelContentDTOS4Bili.stream().forEach(e -> {
List<MultiChannelContentItemDTO> multiChannelContentItems = CollUtil.isEmpty(e.getMultiChannelContentItems()) ? new ArrayList<>() : e.getMultiChannelContentItems();
if (CollUtil.isNotEmpty(itemDTOMap.get(e.getId()))) {
multiChannelContentItems.addAll(itemDTOMap.get(e.getId()));
e.setMultiChannelContentItems(multiChannelContentItems);
multiChannelContentDTOS.add(e);
}
});
}
return multiChannelContentDTOS;
}
private List<MultiChannelContentDTO> getMultiChannelContentDTOS4Douyin(List<MultiChannelContentDTO> multiChannelContentDTOS, List<MultiChannelContent> multiChannelContents, List<Long> contentIds4Douyin) {
//获取抖音视频
List<MultiChannelContentItemDTO> multiChannelContentItemDTOS = multiChannelContentItemBiz.getByMultiChannelContentId(contentIds4Douyin);
List<MultiChannelContentDTO> multiChannelContentDTOS4Douyin = new ArrayList<>();
if ( CollUtil.isNotEmpty(multiChannelContentItemDTOS)) {
multiChannelContentDTOS4Douyin = BeanUtil.copyToList(multiChannelContents, MultiChannelContentDTO.class);
List<String> itemIds = multiChannelContentItemDTOS.stream().map(e -> e.getItemId()).collect(Collectors.toList());
Map<String, DouyinVideoDTO> douyinVideoDTOMap = channelConsr.getDouyinVideoByItemIds(itemIds);
multiChannelContentItemDTOS.stream().forEach(e -> {
if (CollUtil.isNotEmpty(douyinVideoDTOMap) || null != douyinVideoDTOMap.get(e.getItemId())) {
DouyinVideoDTO douyinVideoDTO = douyinVideoDTOMap.get(e.getItemId());
BeanUtil.copyProperties(douyinVideoDTO, e, "id");
}
});
Map<Long, List<MultiChannelContentItemDTO>> itemDTOMap = multiChannelContentItemDTOS.stream().collect(Collectors.groupingBy(MultiChannelContentItemDTO::getMultiChannelContentId));
multiChannelContentDTOS4Douyin.stream().forEach(e -> {
List<MultiChannelContentItemDTO> multiChannelContentItems = CollUtil.isEmpty(e.getMultiChannelContentItems()) ? new ArrayList<>() : e.getMultiChannelContentItems();
if (CollUtil.isNotEmpty(itemDTOMap.get(e.getId()))) {
multiChannelContentItems.addAll(itemDTOMap.get(e.getId()));
e.setMultiChannelContentItems(multiChannelContentItems);
multiChannelContentDTOS.add(e);
}
});
}
return multiChannelContentDTOS; return multiChannelContentDTOS;
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment