|
@@ -0,0 +1,114 @@
|
|
|
+package com.sp.module.video;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.sp.director.base.UserLoginInfo;
|
|
|
+import com.sp.director.ienum.BaseReviewIenum;
|
|
|
+import com.sp.director.module.focus.service.IUserFocusService;
|
|
|
+import com.sp.director.module.video.dto.UserVideoRecommendDTO;
|
|
|
+import com.sp.director.module.video.param.UserPublishVideoParam;
|
|
|
+import com.sp.director.module.video.service.IUserVideoRecommendService;
|
|
|
+import com.sp.director.module.video.service.IUserVideoService;
|
|
|
+import com.sp.director.module.video.service.IVideoLikeService;
|
|
|
+import com.sp.director.module.video.vo.UserVideoVO;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.junit.Test;
|
|
|
+import org.junit.runner.RunWith;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+import org.springframework.test.annotation.Rollback;
|
|
|
+import org.springframework.test.context.junit4.SpringRunner;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @Descrption
|
|
|
+ * @Author: 十一
|
|
|
+ * @Date: 2021/3/18
|
|
|
+ * @Version V1.0
|
|
|
+ **/
|
|
|
+@RunWith(SpringRunner.class)
|
|
|
+@SpringBootTest
|
|
|
+@Slf4j
|
|
|
+@Rollback(value = false)
|
|
|
+public class VideoTest {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserVideoRecommendService userVideoRecommendService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserVideoService userVideoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IUserFocusService userFocusService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IVideoLikeService videoLikeService;
|
|
|
+
|
|
|
+ private Long videoId;
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void publishVideo(){
|
|
|
+ UserPublishVideoParam param = new UserPublishVideoParam();
|
|
|
+ param.setVideoCover("https://directorout.oss-cn-shenzhen.aliyuncs.com/defaultHeadImg/avatar_1.png");
|
|
|
+ param.setVideoUrl("https://media.w3.org/2010/05/sintel/trailer.mp4");
|
|
|
+ param.setContent("my video");
|
|
|
+ param.setHeight(1980);
|
|
|
+ param.setWidth(789);
|
|
|
+ videoId = userVideoService.publishVideo(10001001L, param);
|
|
|
+ log.error("发布视频成功{}",videoId);
|
|
|
+ verifyVideo();
|
|
|
+ recommendVideo();
|
|
|
+ videoRecommendList();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void verifyVideo(){
|
|
|
+ userVideoRecommendService.verifyUserVideo(videoId, BaseReviewIenum.Pass,null);
|
|
|
+ log.error("审核视频:{}",videoId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void recommendVideo(){
|
|
|
+ userVideoRecommendService.recommendVideo(videoId);
|
|
|
+ log.error("推荐视频:{}",videoId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Test
|
|
|
+ public void videoRecommendList(){
|
|
|
+ UserLoginInfo userLoginInfo = new UserLoginInfo();
|
|
|
+ userLoginInfo.setUserId(10001001L);
|
|
|
+ List<UserVideoVO> resultList = new ArrayList<>();
|
|
|
+ List<Long> userIdList = new ArrayList<>();
|
|
|
+ List<Long> videoIdList = new ArrayList<>();
|
|
|
+ Map<Long,Long> userFocusMap = new HashMap<>();
|
|
|
+ Map<Long, Long> userVideoLikeMap = new HashMap<>();;
|
|
|
+ List<UserVideoRecommendDTO> videoList = userVideoRecommendService.queryRecommendVideoList(null);
|
|
|
+ if(!videoList.isEmpty() ){
|
|
|
+ videoList.stream().forEach(v ->{
|
|
|
+ userIdList.add(v.getUserId());
|
|
|
+ videoIdList.add(v.getVideoId());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if( Objects.nonNull(userLoginInfo) && !userIdList.isEmpty() ){
|
|
|
+ userFocusMap = userFocusService.checkUserFocusByFocusUserIdList(userLoginInfo.getUserId(), userIdList);
|
|
|
+ userVideoLikeMap = videoLikeService.checkUserLikeByVideoList(userLoginInfo.getUserId(), videoIdList);
|
|
|
+ }
|
|
|
+ for (UserVideoRecommendDTO dto : videoList) {
|
|
|
+ UserVideoVO vo = new UserVideoVO();
|
|
|
+ BeanUtils.copyProperties(dto,vo);
|
|
|
+ vo.setVideoId(dto.getVideoId().toString());
|
|
|
+ if( null != userFocusMap ){
|
|
|
+ Long focusUser = userFocusMap.get(vo.getUserId());
|
|
|
+ vo.setFocus(focusUser == null ? false : true);
|
|
|
+ }
|
|
|
+ if( null != userVideoLikeMap ){
|
|
|
+ Long videoLike = userVideoLikeMap.get(vo.getVideoId());
|
|
|
+ vo.setFocus(videoLike == null ? false : true);
|
|
|
+ }
|
|
|
+ resultList.add(vo);
|
|
|
+ }
|
|
|
+ log.error("推荐的视频列表");
|
|
|
+ log.error(JSON.toJSONString(resultList));
|
|
|
+ }
|
|
|
+}
|