|
@@ -18,11 +18,13 @@ import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformGzhAccount;
|
|
|
import com.tzld.piaoquan.api.model.po.contentplatform.ContentPlatformVideo;
|
|
|
import com.tzld.piaoquan.api.model.vo.contentplatform.api.VideoIdTitleVO;
|
|
|
import com.tzld.piaoquan.api.model.vo.contentplatform.api.VideoPageUrlVO;
|
|
|
+import com.tzld.piaoquan.api.service.CgiReplyService;
|
|
|
import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformAccountService;
|
|
|
import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformApiService;
|
|
|
import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformCooperateAccountService;
|
|
|
import com.tzld.piaoquan.api.service.contentplatform.ContentPlatformPlanService;
|
|
|
-import com.tzld.piaoquan.growth.common.service.MessageAttachmentService;
|
|
|
+import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
|
|
|
+import com.tzld.piaoquan.growth.common.model.po.CgiReplyBucketData;
|
|
|
import com.tzld.piaoquan.growth.common.utils.RedisUtils;
|
|
|
import com.tzld.piaoquan.growth.common.utils.page.Page;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -45,6 +47,8 @@ public class ContentPlatformApiServiceImpl implements ContentPlatformApiService
|
|
|
private ContentPlatformPlanMapperExt planMapperExt;
|
|
|
@Autowired
|
|
|
private ContentPlatformCooperateAccountService gzhAccountService;
|
|
|
+ @Autowired
|
|
|
+ private CgiReplyService cgiReplyService;
|
|
|
|
|
|
@Autowired
|
|
|
private RedisUtils redisUtils;
|
|
@@ -116,39 +120,64 @@ public class ContentPlatformApiServiceImpl implements ContentPlatformApiService
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<VideoPageUrlVO> getVideoPageUrl(String token, GetVideoPageUrlParam param) {
|
|
|
+ public List<CommonResponse<List<VideoPageUrlVO>>> getVideoPageUrl(String token, GetVideoPageUrlParam param) {
|
|
|
ContentPlatformAccount account = checkToken(token);
|
|
|
if (CollectionUtils.isEmpty(param.getPlanList()) || param.getPlanList().size() > 3) {
|
|
|
throw new CommonException(ExceptionEnum.API_PAGE_URL_SIZE_TOO_LARGE);
|
|
|
}
|
|
|
- List<VideoPageUrlVO> result = new ArrayList<>();
|
|
|
+ List<CommonResponse<List<VideoPageUrlVO>>> result = new ArrayList<>();
|
|
|
List<Long> videoIds = param.getPlanList().stream().flatMap(o -> o.getVideoIds().stream()).collect(Collectors.toList());
|
|
|
List<ContentPlatformVideo> videoList = planMapperExt.getVideoListByIds(videoIds);
|
|
|
Map<Long, ContentPlatformVideo> videoMap = videoList.stream().collect(Collectors.toMap(ContentPlatformVideo::getVideoId, video -> video));
|
|
|
- List<ContentPlatformGzhAccount> gzhAccountList = gzhAccountService.getAccountListByIds();
|
|
|
+ List<String> ghIds = param.getPlanList().stream().map(GetVideoPageUrlParam.PlanItem::getGhId).collect(Collectors.toList());
|
|
|
+ List<ContentPlatformGzhAccount> gzhAccountList = gzhAccountService.getAccountListByGhIds(ghIds, account.getId());
|
|
|
Map<String, ContentPlatformGzhAccount> gzhAccountMap = gzhAccountList.stream()
|
|
|
.collect(Collectors.toMap(ContentPlatformGzhAccount::getGhId, gzhAccount -> gzhAccount));
|
|
|
LoginUserContext.setLoginUser(account);
|
|
|
for (GetVideoPageUrlParam.PlanItem item : param.getPlanList()) {
|
|
|
- GzhPlanSaveParam saveParam = new GzhPlanSaveParam();
|
|
|
- saveParam.setPublishStage(PublishStageEnum.USER.getVal());
|
|
|
- ContentPlatformGzhAccount gzhAccount = gzhAccountMap.get(item.getGhId());
|
|
|
- saveParam.setAccountId(gzhAccount.getId());
|
|
|
- saveParam.setScene(0);
|
|
|
- saveParam.setType(item.getType());
|
|
|
- saveParam.setSelectVideoType(0);
|
|
|
- List<GzhPlanVideoContentItemParam> videoItemList = new ArrayList<>();
|
|
|
- for (Long videoId : item.getVideoIds()) {
|
|
|
- ContentPlatformVideo video = videoMap.get(videoId);
|
|
|
- GzhPlanVideoContentItemParam videoItem = new GzhPlanVideoContentItemParam();
|
|
|
- videoItem.setVideoId(video.getVideoId());
|
|
|
- videoItem.setTitle(video.getTitle());
|
|
|
- videoItem.setCover(video.getCover());
|
|
|
- videoItem.setVideo(video.getVideo());
|
|
|
- videoItemList.add(videoItem);
|
|
|
+ int code = 0;
|
|
|
+ String msg = "";
|
|
|
+ List<VideoPageUrlVO> data = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ GzhPlanSaveParam saveParam = new GzhPlanSaveParam();
|
|
|
+ saveParam.setPublishStage(PublishStageEnum.USER.getVal());
|
|
|
+ ContentPlatformGzhAccount gzhAccount = gzhAccountMap.get(item.getGhId());
|
|
|
+ saveParam.setAccountId(gzhAccount.getId());
|
|
|
+ saveParam.setScene(0);
|
|
|
+ saveParam.setType(item.getType());
|
|
|
+ saveParam.setSelectVideoType(0);
|
|
|
+ List<GzhPlanVideoContentItemParam> videoItemList = new ArrayList<>();
|
|
|
+ for (Long videoId : item.getVideoIds()) {
|
|
|
+ ContentPlatformVideo video = videoMap.get(videoId);
|
|
|
+ GzhPlanVideoContentItemParam videoItem = new GzhPlanVideoContentItemParam();
|
|
|
+ videoItem.setVideoId(video.getVideoId());
|
|
|
+ videoItem.setTitle(video.getTitle());
|
|
|
+ videoItem.setCover(video.getCover());
|
|
|
+ videoItem.setVideo(video.getVideo());
|
|
|
+ videoItemList.add(videoItem);
|
|
|
+ }
|
|
|
+ saveParam.setVideoList(videoItemList);
|
|
|
+ planService.gzhPlanSave(saveParam);
|
|
|
+ List<CgiReplyBucketData> replyBucketDataList = cgiReplyService.getCgiReplyBucketDataListByGhIdVideoId(
|
|
|
+ gzhAccount.getGhId(), item.getVideoIds(), "manual");
|
|
|
+ for (CgiReplyBucketData cgiReplyBucketData : replyBucketDataList) {
|
|
|
+ VideoPageUrlVO vo = new VideoPageUrlVO();
|
|
|
+ vo.setVideoId(cgiReplyBucketData.getMiniVideoId());
|
|
|
+ vo.setTitle(cgiReplyBucketData.getTitle());
|
|
|
+ vo.setCover(cgiReplyBucketData.getCoverUrl());
|
|
|
+ vo.setPageUrl(cgiReplyBucketData.getMiniPagePath());
|
|
|
+ data.add(vo);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ code = -1;
|
|
|
+ msg = e.getMessage();
|
|
|
+ } finally {
|
|
|
+ CommonResponse<List<VideoPageUrlVO>> response = new CommonResponse<>();
|
|
|
+ response.setCode(code);
|
|
|
+ response.setMsg(msg);
|
|
|
+ response.setData(data);
|
|
|
+ result.add(response);
|
|
|
}
|
|
|
- saveParam.setVideoList(videoItemList);
|
|
|
- planService.gzhPlanSave(saveParam);
|
|
|
}
|
|
|
LoginUserContext.remove();
|
|
|
return result;
|