| | |
| | | import cn.lili.modules.member.entity.dos.Member; |
| | | import cn.lili.modules.member.service.FootprintService; |
| | | import cn.lili.modules.member.service.MemberService; |
| | | import cn.lili.modules.permission.entity.dos.AdminUser; |
| | | import cn.lili.modules.permission.service.AdminUserService; |
| | | import cn.lili.modules.search.entity.dos.EsGoodsIndex; |
| | | import cn.lili.rocketmq.RocketmqSendCallbackBuilder; |
| | | import cn.lili.rocketmq.tags.CommentTagsEnum; |
| | |
| | | private final VideoGoodsService videoGoodsService; |
| | | private final KitchenTypeService kitchenTypeService; |
| | | private final Cache cache; |
| | | |
| | | private final AdminUserService adminUserService; |
| | | private final RocketmqCustomProperties rocketmqCustomProperties; |
| | | private final RocketMQTemplate rocketMQTemplate; |
| | | private final ThumbsUpRecordService thumbsUpRecordService; |
| | |
| | | String destination = rocketmqCustomProperties.getVideoTopic() + ":" + VideoTagsEnum.ES_DOC_ADD_OR_UPDATE.name(); |
| | | rocketMQTemplate.asyncSend(destination, JSON.toJSONString(videoIndex), RocketmqSendCallbackBuilder.commonCallback()); |
| | | return Result.ok("发布成功,视频审核中~"); |
| | | } @Override |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result systemPublish(WxVideoForm form) { |
| | | // 1.保存视频 |
| | |
| | | // 3. 获取视频临时访问地址、设置视频标签 |
| | | page.getRecords().forEach(v -> { |
| | | v.setTagList(tagMap.get(v.getId())); |
| | | v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverUrl())); |
| | | String coverUrl = v.getCoverUrl(); |
| | | if (StringUtils.isNotBlank(coverUrl)&&!coverUrl.contains("http")) { |
| | | v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverUrl())); |
| | | } |
| | | v.getGoodsList().forEach(goods ->{ |
| | | if (StringUtils.isNotBlank(goods.getThumbnail())&&!goods.getThumbnail().contains("http")) { |
| | | goods.setThumbnail(cosUtil.getPreviewUrl(goods.getThumbnail())); |
| | |
| | | case "recommend":// 加载推荐视频 |
| | | baseMapper.recommendVideo(page, query); |
| | | //推荐视频重新排序 |
| | | WxVideoVO wxVideoVO = null; |
| | | if (StringUtils.isNotBlank(query.getVideoId())) { |
| | | wxVideoVO = baseMapper.recommendVideoByVideoId(query); |
| | | } |
| | | List<WxVideoVO> records = page.getRecords(); |
| | | Collections.shuffle(records); |
| | | if (wxVideoVO!=null) { |
| | | records.set(0, wxVideoVO); |
| | | } |
| | | buildRecommendVideoList(page, query.getVideoId()); |
| | | // WxVideoVO wxVideoVO = null; |
| | | // if (StringUtils.isNotBlank(query.getVideoId())) { |
| | | // wxVideoVO = baseMapper.recommendVideoByVideoId(query); |
| | | // } |
| | | // List<WxVideoVO> records = page.getRecords(); |
| | | // Collections.shuffle(records); |
| | | // if (wxVideoVO!=null) { |
| | | // records.set(0, wxVideoVO); |
| | | // } |
| | | break; |
| | | case "author": // 加载视频主页我发布的视频 |
| | | AuthorVideoQuery query1 = new AuthorVideoQuery(); |
| | |
| | | v.setCommentNum(this.getCommentNum(v.getId(), v.getCommentNum())); |
| | | v.setCollectNum(this.getCollectNum(v.getId(), v.getCollectNum())); |
| | | v.setThumbsUpNum(this.getThumbsUpNum(v.getId(), v.getThumbsUpNum())); |
| | | v.setAuthorAvatar(cosUtil.getPreviewUrl(v.getAuthorAvatar())); |
| | | String authorAvatar = v.getAuthorAvatar(); |
| | | if (StringUtils.isNotBlank(authorAvatar)&&!authorAvatar.contains("http")) { |
| | | v.setAuthorAvatar(cosUtil.getPreviewUrl(v.getAuthorAvatar())); |
| | | } |
| | | if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) { |
| | | v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey())); |
| | | v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey())); |
| | |
| | | public Result healthRecommendVideo(WxHealthVideoQuery query) { |
| | | IPage<WxVideoVO> page = PageUtil.getPage(query, WxVideoVO.class); |
| | | //获取大健康视频列表 |
| | | |
| | | baseMapper.recommendHealthVideo(page,query); |
| | | buildRecommendVideoList(page, query.getVideoId()); |
| | | |
| | | if (page.getTotal() > 0) { |
| | | page.getRecords().forEach(v -> { |
| | | v.setAuthorAvatar(cosUtil.getPreviewUrl(v.getAuthorAvatar())); |
| | |
| | | @Override |
| | | public Result kitchenRecommendVideo(WxKitchenVideoQuery query) { |
| | | IPage<WxVideoVO> page = PageUtil.getPage(query, WxVideoVO.class); |
| | | baseMapper.wxKitchenVideoQuery(page, query); |
| | | page.getRecords().forEach(v -> { |
| | | baseMapper.wxKitchenVideoQuery(page, query); |
| | | |
| | | buildRecommendVideoList(page, query.getVideoId()); |
| | | |
| | | page.getRecords().forEach(v -> { |
| | | v.setAuthorAvatar(cosUtil.getPreviewUrl(v.getAuthorAvatar())); |
| | | if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) { |
| | | v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey())); |
| | |
| | | } |
| | | }); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | | /** |
| | | * |
| | | * @param page |
| | | * @param videoId videoId推荐的视频id |
| | | */ |
| | | private void buildRecommendVideoList(IPage<WxVideoVO> page, String videoId) { |
| | | //查询到有视频列表 |
| | | |
| | | if(org.apache.commons.collections.CollectionUtils.isNotEmpty(page.getRecords())){ |
| | | //现将视频顺序打乱 |
| | | Collections.shuffle(page.getRecords()); |
| | | |
| | | WxVideoVO wxVideoVO = null; |
| | | if (StringUtils.isNotBlank(videoId)){ |
| | | VideoQuery videoQuery = new VideoQuery(); |
| | | videoQuery.setVideoId(videoId); |
| | | wxVideoVO = baseMapper.recommendVideoByVideoId(videoQuery); |
| | | |
| | | boolean found = false; |
| | | int foundIndex = -1; |
| | | |
| | | List<WxVideoVO> records = page.getRecords(); |
| | | //判断二维码过来的videoId是否存在与page.getRecords重复 记录下标 |
| | | for (int i = 0; i < records.size(); i++) { |
| | | if (wxVideoVO.getId().equals(records.get(i).getId())) { |
| | | found = true; |
| | | foundIndex = i; |
| | | break; |
| | | } |
| | | } |
| | | if (found){ |
| | | WxVideoVO matchedRecord = records.remove(foundIndex); |
| | | records.add(0, matchedRecord); |
| | | }else { |
| | | // 如果没找到,替换首位 |
| | | records.set(0, wxVideoVO); |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public Result getAuthorInfo(String authorId) { |
| | | VideoAccountVO vo = baseMapper.getAuthorInfo(authorId, UserContext.getCurrentUserId()); |
| | | AdminUser adminUser = adminUserService.getById(authorId); |
| | | VideoAccountVO vo; |
| | | if (Objects.isNull(adminUser)) { |
| | | vo = baseMapper.getAuthorInfo(authorId, UserContext.getCurrentUserId()); |
| | | }else { |
| | | vo = baseMapper.getAuthorInfoAdmin(authorId, UserContext.getCurrentUserId()); |
| | | } |
| | | vo.setSelf(authorId.equals(UserContext.getCurrentUserId())); |
| | | // 查询获赞数 |
| | | List<String> videoIds = baseMapper.getVideoIdsByAuthor(authorId); |