wangyunpeng 2 hónapja
szülő
commit
1f0599f685

+ 1 - 1
api-module/src/main/java/com/tzld/piaoquan/api/controller/contentplatform/ContentPlatformApiController.java

@@ -45,7 +45,7 @@ public class ContentPlatformApiController {
     @ApiOperation(value = "获取视频嵌入路径")
     @PostMapping("/getVideoPageUrl")
     @JwtIgnore
-    public CommonResponse<List<VideoPageUrlVO>> getVideoPageUrl(HttpServletRequest request,
+    public CommonResponse<List<CommonResponse<List<VideoPageUrlVO>>>> getVideoPageUrl(HttpServletRequest request,
                                                                 @RequestBody GetVideoPageUrlParam param) {
         String token = request.getHeader("token");
         return CommonResponse.success(apiService.getVideoPageUrl(token, param));

+ 1 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/CgiReplyService.java

@@ -13,4 +13,5 @@ public interface CgiReplyService {
 
     List<CgiReplyBucketData> getCgiReplyBucketDataListByVideoId(Long videoId);
 
+    List<CgiReplyBucketData> getCgiReplyBucketDataListByGhIdVideoId(String ghId, List<Long> videoIds, String strategy);
 }

+ 2 - 1
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/ContentPlatformApiService.java

@@ -5,6 +5,7 @@ import com.tzld.piaoquan.api.model.param.contentplatform.api.GetTokenParam;
 import com.tzld.piaoquan.api.model.param.contentplatform.api.GetVideoPageUrlParam;
 import com.tzld.piaoquan.api.model.vo.contentplatform.api.VideoIdTitleVO;
 import com.tzld.piaoquan.api.model.vo.contentplatform.api.VideoPageUrlVO;
+import com.tzld.piaoquan.growth.common.common.base.CommonResponse;
 import com.tzld.piaoquan.growth.common.utils.page.Page;
 
 import java.util.List;
@@ -15,5 +16,5 @@ public interface ContentPlatformApiService {
 
     Page<VideoIdTitleVO> getContent(String token, GetContentPageParam param);
 
-    List<VideoPageUrlVO> getVideoPageUrl(String token, GetVideoPageUrlParam param);
+    List<CommonResponse<List<VideoPageUrlVO>>> getVideoPageUrl(String token, GetVideoPageUrlParam param);
 }

+ 2 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/ContentPlatformCooperateAccountService.java

@@ -38,4 +38,6 @@ public interface ContentPlatformCooperateAccountService {
     ContentPlatformGzhAccount getGzhAccount(String ghId);
 
     List<ContentPlatformGzhAccount> getAccountListByCreatorId(Long creatorId);
+
+    List<ContentPlatformGzhAccount> getAccountListByGhIds(List<String> ghIds, Long creatorId);
 }

+ 51 - 22
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformApiServiceImpl.java

@@ -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;

+ 7 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/contentplatform/impl/ContentPlatformCooperateAccountServiceImpl.java

@@ -180,6 +180,13 @@ public class ContentPlatformCooperateAccountServiceImpl implements ContentPlatfo
         return gzhAccountMapper.selectByExample(example);
     }
 
+    @Override
+    public List<ContentPlatformGzhAccount> getAccountListByGhIds(List<String> ghIds, Long creatorId) {
+        ContentPlatformGzhAccountExample example = new ContentPlatformGzhAccountExample();
+        example.createCriteria().andGhIdIn(ghIds).andCreateAccountIdEqualTo(creatorId);
+        return gzhAccountMapper.selectByExample(example);
+    }
+
     @Override
     public ContentPlatformGzhAccount getById(Long id) {
         return gzhAccountMapper.selectByPrimaryKey(id);

+ 8 - 0
api-module/src/main/java/com/tzld/piaoquan/api/service/impl/CgiReplyServiceImpl.java

@@ -106,4 +106,12 @@ public class CgiReplyServiceImpl implements CgiReplyService {
         example.createCriteria().andMiniVideoIdEqualTo(videoId).andIsDeleteEqualTo(0);
         return cgiReplyBucketDataMapper.selectByExample(example);
     }
+
+    @Override
+    public List<CgiReplyBucketData> getCgiReplyBucketDataListByGhIdVideoId(String ghId, List<Long> videoIds, String strategy) {
+        CgiReplyBucketDataExample example = new CgiReplyBucketDataExample();
+        example.createCriteria().andGhIdEqualTo(ghId).andMiniVideoIdIn(videoIds)
+                .andStrategyEqualTo(strategy).andIsDeleteEqualTo(0);
+        return cgiReplyBucketDataMapper.selectByExample(example);
+    }
 }