| | |
| | | query2.setAuthorId(query.getAuthorId()); |
| | | baseMapper.getAuthorCollectVideoPage(page, query2); |
| | | break; |
| | | case "like": |
| | | AuthorVideoQuery query3 = new AuthorVideoQuery(); |
| | | query3.setAuthorId(query.getAuthorId()); |
| | | baseMapper.getAuthorLikeVideoPage(page, query3); |
| | | default: |
| | | break; |
| | | } |
| | |
| | | IPage<WxVideoVO> page = PageUtil.getPage(query, WxVideoVO.class); |
| | | query.setAuthorSelf(UserContext.getCurrentUserId().equals(query.getAuthorId())); |
| | | baseMapper.getAuthorVideoPage(page, query); |
| | | for (WxVideoVO vo : page.getRecords()) { |
| | | if (VideoContentTypeEnum.VIDEO.getValue().equals(vo.getVideoContentType())) { |
| | | vo.setVideoUrl(cosUtil.getPreviewUrl(vo.getVideoFileKey())); |
| | | vo.setCoverUrl(cosUtil.getPreviewUrl(vo.getCoverFileKey())); |
| | | } else if (VideoContentTypeEnum.IMG.getValue().equals(vo.getVideoContentType()) && StringUtils.isNotBlank(vo.getVideoImgs())) { |
| | | vo.setImgs(JSON.parseArray(vo.getVideoImgs(), String.class).stream().map(fileKey -> cosUtil.getPreviewUrl(fileKey)).collect(Collectors.toList())); |
| | | List<String> videoIds = page.getRecords().stream().map(WxVideoVO::getId).collect(Collectors.toList()); |
| | | Map<String, List<SimpleVideoTagVO>> tagMap = videoTagRefService.getTagsByVideoIds(videoIds) |
| | | .stream() |
| | | .collect(Collectors.groupingBy(SimpleVideoTagVO::getVideoId)); |
| | | Map<String, List<SimpleMyCollectVO>> collectMap = myCollectService.getCollectsByVideoIds(videoIds) |
| | | .stream() |
| | | .collect(Collectors.groupingBy(SimpleMyCollectVO::getRefId)); |
| | | Map<String, List<SimpleMyThumbsUpVO>> thumbsUpMap = thumbsUpRecordService.getThumbssByVideoIds(videoIds) |
| | | .stream() |
| | | .collect(Collectors.groupingBy(SimpleMyThumbsUpVO::getRefId)); |
| | | List<String> subscribes = mySubscribeService.getSubscribesByUserId(UserContext.getCurrentUserId()); |
| | | if (CollectionUtils.isNotEmpty(page.getRecords())) { |
| | | for (WxVideoVO v : page.getRecords()) { |
| | | v.setTagList(tagMap.get(v.getId())); |
| | | v.setCollected(CollectionUtils.isNotEmpty(collectMap.get(v.getId()))); |
| | | v.setThumbsUp(CollectionUtils.isNotEmpty(thumbsUpMap.get(v.getId()))); |
| | | v.setCommentNum(this.getCommentNum(v.getId(), v.getCommentNum())); |
| | | v.setCollectNum(this.getCollectNum(v.getId(), v.getCollectNum())); |
| | | v.setThumbsUpNum(this.getThumbsUpNum(v.getId(), v.getThumbsUpNum())); |
| | | if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) { |
| | | v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey())); |
| | | v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey())); |
| | | } else if (VideoContentTypeEnum.IMG.getValue().equals(v.getVideoContentType()) && StringUtils.isNotBlank(v.getVideoImgs())) { |
| | | v.setImgs(JSON.parseArray(v.getVideoImgs(), String.class).stream().map(fileKey -> cosUtil.getPreviewUrl(fileKey)).collect(Collectors.toList())); |
| | | } |
| | | v.setOptions(VideoSupportOpEnum.getVideoOpByStatus(v.getStatus())); |
| | | if (CollectionUtils.isNotEmpty(v.getGoodsList())) { |
| | | v.getGoodsList().stream().forEach(goods -> { |
| | | goods.setThumbnail(cosUtil.getPreviewUrl(goods.getThumbnail())); |
| | | }); |
| | | } |
| | | v.setSubscribeThisAuthor(subscribes.contains(v.getAuthorId())); |
| | | } |
| | | |
| | | |
| | | vo.setOptions(VideoSupportOpEnum.getVideoOpByStatus(vo.getStatus())); |
| | | } |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | |
| | | public Result getAuthorCollectVideoPage(AuthorVideoQuery query) { |
| | | IPage<WxVideoVO> page = PageUtil.getPage(query, WxVideoVO.class); |
| | | baseMapper.getAuthorCollectVideoPage(page, query); |
| | | for (WxVideoVO vo : page.getRecords()) { |
| | | if (VideoContentTypeEnum.VIDEO.getValue().equals(vo.getVideoContentType())) { |
| | | vo.setVideoUrl(cosUtil.getPreviewUrl(vo.getVideoFileKey())); |
| | | vo.setCoverUrl(cosUtil.getPreviewUrl(vo.getCoverFileKey())); |
| | | } else if (VideoContentTypeEnum.IMG.getValue().equals(vo.getVideoContentType()) && StringUtils.isNotBlank(vo.getVideoImgs())) { |
| | | vo.setImgs(JSON.parseArray(vo.getVideoImgs(), String.class).stream().map(fileKey -> cosUtil.getPreviewUrl(fileKey)).collect(Collectors.toList())); |
| | | if (CollectionUtils.isNotEmpty(page.getRecords())) { |
| | | List<String> videoIds = page.getRecords().stream().map(WxVideoVO::getId).collect(Collectors.toList()); |
| | | Map<String, List<SimpleVideoTagVO>> tagMap = videoTagRefService.getTagsByVideoIds(videoIds) |
| | | .stream() |
| | | .collect(Collectors.groupingBy(SimpleVideoTagVO::getVideoId)); |
| | | Map<String, List<SimpleMyThumbsUpVO>> thumbsUpMap = thumbsUpRecordService.getThumbssByVideoIds(videoIds) |
| | | .stream() |
| | | .collect(Collectors.groupingBy(SimpleMyThumbsUpVO::getRefId)); |
| | | List<String> subscribes = mySubscribeService.getSubscribesByUserId(UserContext.getCurrentUserId()); |
| | | for (WxVideoVO v : page.getRecords()) { |
| | | v.setTagList(tagMap.get(v.getId())); |
| | | v.setCollected(Boolean.TRUE); |
| | | v.setThumbsUp(CollectionUtils.isNotEmpty(thumbsUpMap.get(v.getId()))); |
| | | v.setCommentNum(this.getCommentNum(v.getId(), v.getCommentNum())); |
| | | v.setCollectNum(this.getCollectNum(v.getId(), v.getCollectNum())); |
| | | v.setThumbsUpNum(this.getThumbsUpNum(v.getId(), v.getThumbsUpNum())); |
| | | if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) { |
| | | v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey())); |
| | | v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey())); |
| | | } else if (VideoContentTypeEnum.IMG.getValue().equals(v.getVideoContentType()) && StringUtils.isNotBlank(v.getVideoImgs())) { |
| | | v.setImgs(JSON.parseArray(v.getVideoImgs(), String.class).stream().map(fileKey -> cosUtil.getPreviewUrl(fileKey)).collect(Collectors.toList())); |
| | | } |
| | | if (CollectionUtils.isNotEmpty(v.getGoodsList())) { |
| | | v.getGoodsList().stream().forEach(goods -> { |
| | | goods.setThumbnail(cosUtil.getPreviewUrl(goods.getThumbnail())); |
| | | }); |
| | | } |
| | | v.setSubscribeThisAuthor(subscribes.contains(v.getAuthorId())); |
| | | } |
| | | vo.setCollected(Boolean.TRUE); |
| | | } |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | | @Override |
| | | public Result getAuthorLikeVideoPage(AuthorVideoQuery query) { |
| | | IPage<WxVideoVO> page = PageUtil.getPage(query, WxVideoVO.class); |
| | | baseMapper.getAuthorLikeVideoPage(page, query); |
| | | if (CollectionUtils.isNotEmpty(page.getRecords())) { |
| | | List<String> videoIds = page.getRecords().stream().map(WxVideoVO::getId).collect(Collectors.toList()); |
| | | Map<String, List<SimpleVideoTagVO>> tagMap = videoTagRefService.getTagsByVideoIds(videoIds) |
| | | .stream() |
| | | .collect(Collectors.groupingBy(SimpleVideoTagVO::getVideoId)); |
| | | Map<String, List<SimpleMyCollectVO>> collectMap = myCollectService.getCollectsByVideoIds(videoIds) |
| | | .stream() |
| | | .collect(Collectors.groupingBy(SimpleMyCollectVO::getRefId)); |
| | | List<String> subscribes = mySubscribeService.getSubscribesByUserId(UserContext.getCurrentUserId()); |
| | | for (WxVideoVO v : page.getRecords()) { |
| | | v.setTagList(tagMap.get(v.getId())); |
| | | v.setCollected(CollectionUtils.isNotEmpty(collectMap.get(v.getId()))); |
| | | v.setThumbsUp(Boolean.TRUE); |
| | | v.setCommentNum(this.getCommentNum(v.getId(), v.getCommentNum())); |
| | | v.setCollectNum(this.getCollectNum(v.getId(), v.getCollectNum())); |
| | | v.setThumbsUpNum(this.getThumbsUpNum(v.getId(), v.getThumbsUpNum())); |
| | | if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) { |
| | | v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey())); |
| | | v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey())); |
| | | } else if (VideoContentTypeEnum.IMG.getValue().equals(v.getVideoContentType()) && StringUtils.isNotBlank(v.getVideoImgs())) { |
| | | v.setImgs(JSON.parseArray(v.getVideoImgs(), String.class).stream().map(fileKey -> cosUtil.getPreviewUrl(fileKey)).collect(Collectors.toList())); |
| | | } |
| | | if (CollectionUtils.isNotEmpty(v.getGoodsList())) { |
| | | v.getGoodsList().stream().forEach(goods -> { |
| | | goods.setThumbnail(cosUtil.getPreviewUrl(goods.getThumbnail())); |
| | | }); |
| | | } |
| | | v.setSubscribeThisAuthor(subscribes.contains(v.getAuthorId())); |
| | | } |
| | | } |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |