| | |
| | | |
| | | /** |
| | | * 批量删除 |
| | | * |
| | | * @param ids |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * id删除 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param query |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 根据id查找 |
| | | * |
| | | * @param id |
| | | * @return |
| | | */ |
| | |
| | | |
| | | /** |
| | | * 列表 |
| | | * |
| | | * @return |
| | | */ |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Result sysUpdatePublish(WxVideoForm form) { |
| | | Video video = baseMapper.selectById(form.getId()); |
| | | if (Objects.isNull(video)) { |
| | | return Result.error("修改视频不存在"); |
| | | } |
| | | // 1.修改视频 |
| | | WxVideoForm.getEntityByForm(form, video); |
| | | video.setStatus(VideoStatusEnum.AUDITING.getValue()); |
| | | video.setCoverUrl(form.getCover()); |
| | | video.setVideoType(VideoTypeEnum.VIDEO.getValue()); |
| | | if (VideoContentTypeEnum.IMG.getValue().equals(form.getVideoContentType())) { |
| | | video.setVideoImgs(JSON.toJSONString(form.getVideoImgs())); |
| | | } |
| | | baseMapper.updateById(video); |
| | | // 2.处理标签---删除之前的视频标签关系,再新增 |
| | | new LambdaUpdateChainWrapper<>(videoTagRefService.getBaseMapper()) |
| | | .eq(VideoTagRef::getVideoId, video.getId()) |
| | | .remove(); |
| | | List<SimpleVideoTagVO> esTagList = new ArrayList<>(2); |
| | | List<VideoTagRef> videoTagRefs = form.getTags().stream().map(tag -> { |
| | | VideoTagRef videoTagRef = new VideoTagRef(); |
| | | videoTagRef.setVideoId(video.getId()); |
| | | if (StringUtils.isBlank(tag.getId())) { |
| | | VideoTag videoTag = new LambdaQueryChainWrapper<>(videoTagService.getBaseMapper()) |
| | | .eq(VideoTag::getTagName, tag.getTagName()) |
| | | .one(); |
| | | if (Objects.nonNull(videoTag)) { |
| | | videoTagRef.setVideoTagId(videoTag.getId()); |
| | | } else { |
| | | videoTag = new VideoTag(); |
| | | videoTag.setTagName(tag.getTagName()); |
| | | videoTag.setCreateType(TagCreateTypeEnum.USER.getValue()); |
| | | videoTagService.save(videoTag); |
| | | videoTagRef.setVideoTagId(videoTag.getId()); |
| | | } |
| | | } else { |
| | | videoTagRef.setVideoTagId(tag.getId()); |
| | | } |
| | | SimpleVideoTagVO esTag = new SimpleVideoTagVO(); |
| | | esTag.setVideoId(video.getId()); |
| | | esTag.setTagName(tag.getTagName()); |
| | | esTag.setId(tag.getId()); |
| | | esTagList.add(esTag); |
| | | return videoTagRef; |
| | | }).collect(Collectors.toList()); |
| | | videoTagRefService.saveBatch(videoTagRefs); |
| | | // 3. 保存视频文件信息 |
| | | lmkFileService.addByForm(form.getFileInfo()); |
| | | // 4. 处理选择的商品,先删除之前的再新增 |
| | | new LambdaUpdateChainWrapper<>(videoGoodsService.getBaseMapper()) |
| | | .eq(VideoGoods::getVideoId, video.getId()) |
| | | .remove(); |
| | | List<VideoGoods> videoGoods = new ArrayList<>(2); |
| | | if (CollectionUtils.isNotEmpty(form.getGoodsList())) { |
| | | for (int i = 0; i < form.getGoodsList().size(); i++) { |
| | | VideoGoods e = new VideoGoods(); |
| | | e.setVideoId(video.getId()); |
| | | e.setGoodsId(form.getGoodsList().get(i).getGoodsId()); |
| | | e.setGoodsSkuId(form.getGoodsList().get(i).getGoodsSkuId()); |
| | | e.setGoodsNum(form.getGoodsList().get(i).getGoodsNum()); |
| | | e.setOrderNum(i); |
| | | videoGoods.add(e); |
| | | } |
| | | videoGoodsService.saveBatch(videoGoods); |
| | | } |
| | | // 5. 更新es中的数据,mq异步处理 |
| | | VideoIndex videoIndex = new VideoIndex(); |
| | | BeanUtils.copyProperties(video, videoIndex); |
| | | String avatar = ""; |
| | | String name = ""; |
| | | //设置用户信息头像 |
| | | VideoUserBaseInfo videoSysUserBaseInfo = baseMapper.getVideoSysUserBaseInfo(video.getAuthorId()); |
| | | |
| | | if (videoSysUserBaseInfo != null) { |
| | | avatar = videoSysUserBaseInfo.getAvatar(); |
| | | name = videoSysUserBaseInfo.getNickName(); |
| | | } |
| | | VideoUserBaseInfo videoMemUserBaseInfo = baseMapper.getVideoMemUserBaseInfo(video.getAuthorId()); |
| | | if (videoMemUserBaseInfo != null) { |
| | | avatar = videoMemUserBaseInfo.getAvatar(); |
| | | name = videoMemUserBaseInfo.getNickName(); |
| | | } |
| | | videoIndex.setAuthorName(name); |
| | | videoIndex.setAuthorAvatar(avatar); |
| | | videoIndex.setCoverFileKey(video.getCoverUrl()); |
| | | List<VideoGoodsDetailVO> esGoodsList = videoGoods.stream().map(goods -> { |
| | | VideoGoodsDetailVO vo = new VideoGoodsDetailVO(); |
| | | BeanUtils.copyProperties(goods, vo); |
| | | return vo; |
| | | }).collect(Collectors.toList()); |
| | | videoIndex.setGoodsList(esGoodsList); |
| | | videoIndex.setTagList(esTagList); |
| | | String destination = rocketmqCustomProperties.getVideoTopic() + ":" + VideoTagsEnum.ES_DOC_ADD_OR_UPDATE.name(); |
| | | rocketMQTemplate.asyncSend(destination, JSON.toJSONString(videoIndex), RocketmqSendCallbackBuilder.commonCallback()); |
| | | return Result.ok("发布成功,视频审核中~"); |
| | | } |
| | | |
| | | @Override |
| | | public Result managerPage(ManagerVideoQuery query) { |
| | | IPage<VideoVO> page = PageUtil.getPage(query, VideoVO.class); |
| | | // 1. 先查出视频信息 |
| | |
| | | page.getRecords().forEach(v -> { |
| | | v.setTagList(tagMap.get(v.getId())); |
| | | String coverUrl = v.getCoverUrl(); |
| | | if (StringUtils.isNotBlank(coverUrl)&&!coverUrl.contains("http")) { |
| | | 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")) { |
| | | v.getGoodsList().forEach(goods -> { |
| | | if (StringUtils.isNotBlank(goods.getThumbnail()) && !goods.getThumbnail().contains("http")) { |
| | | goods.setThumbnail(cosUtil.getPreviewUrl(goods.getThumbnail())); |
| | | } |
| | | |
| | |
| | | } |
| | | if (VideoContentTypeEnum.VIDEO.getValue().equals(v.getVideoContentType())) { |
| | | v.setVideoUrl(cosUtil.getPreviewUrl(v.getVideoFileKey())); |
| | | v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey())); |
| | | String coverFileKey = v.getCoverFileKey(); |
| | | v.setCoverUrl(cosUtil.getPreviewUrl(coverFileKey)); |
| | | } 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())); |
| | | } |
| | |
| | | IPage<WxVideoVO> page = PageUtil.getPage(query, WxVideoVO.class); |
| | | //获取大健康视频列表 |
| | | |
| | | baseMapper.recommendHealthVideo(page,query); |
| | | baseMapper.recommendHealthVideo(page, query); |
| | | buildRecommendVideoList(page, query.getVideoId()); |
| | | |
| | | if (page.getTotal() > 0) { |
| | |
| | | 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())); |
| | | v.setCoverUrl(cosUtil.getPreviewUrl(v.getCoverFileKey())); |
| | | } |
| | | }); |
| | | 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())); |
| | | } |
| | | }); |
| | | return Result.ok().data(page.getRecords()).total(page.getTotal()); |
| | | } |
| | | |
| | |
| | | private void buildRecommendVideoList(IPage<WxVideoVO> page, String videoId) { |
| | | //查询到有视频列表 |
| | | |
| | | if(org.apache.commons.collections.CollectionUtils.isNotEmpty(page.getRecords())){ |
| | | if (org.apache.commons.collections.CollectionUtils.isNotEmpty(page.getRecords())) { |
| | | //现将视频顺序打乱 |
| | | Collections.shuffle(page.getRecords()); |
| | | |
| | | WxVideoVO wxVideoVO = null; |
| | | if (StringUtils.isNotBlank(videoId)){ |
| | | if (StringUtils.isNotBlank(videoId)) { |
| | | VideoQuery videoQuery = new VideoQuery(); |
| | | videoQuery.setVideoId(videoId); |
| | | wxVideoVO = baseMapper.recommendVideoByVideoId(videoQuery); |
| | | wxVideoVO = baseMapper.recommendVideoByVideoId(videoQuery); |
| | | |
| | | boolean found = false; |
| | | int foundIndex = -1; |
| | |
| | | break; |
| | | } |
| | | } |
| | | if (found){ |
| | | if (found) { |
| | | WxVideoVO matchedRecord = records.remove(foundIndex); |
| | | records.add(0, matchedRecord); |
| | | }else { |
| | | } else { |
| | | // 如果没找到,替换首位 |
| | | records.set(0, wxVideoVO); |
| | | |
| | |
| | | AdminUser adminUser = adminUserService.getById(authorId); |
| | | VideoAccountVO vo; |
| | | if (Objects.isNull(adminUser)) { |
| | | vo = baseMapper.getAuthorInfo(authorId, UserContext.getCurrentUserId()); |
| | | }else { |
| | | vo = baseMapper.getAuthorInfo(authorId, UserContext.getCurrentUserId()); |
| | | } else { |
| | | vo = baseMapper.getAuthorInfoAdmin(authorId, UserContext.getCurrentUserId()); |
| | | } |
| | | vo.setSelf(authorId.equals(UserContext.getCurrentUserId())); |
| | |
| | | if (page.getTotal() > 0) { |
| | | Map<String, List<SimpleVideoTagVO>> tagMap = videoTagRefService.getTagsByVideoIds( |
| | | page.getRecords().stream().map(VideoVO::getId).collect(Collectors.toList()) |
| | | ).stream().collect(Collectors.groupingBy(SimpleVideoTagVO::getVideoId));; |
| | | ).stream().collect(Collectors.groupingBy(SimpleVideoTagVO::getVideoId)); |
| | | ; |
| | | // 3. 获取视频临时访问地址、设置视频标签 |
| | | page.getRecords().forEach(v -> { |
| | | v.setTagList(tagMap.get(v.getId())); |
| | |
| | | Assert.notNull(entity, "记录不存在"); |
| | | String videoType = entity.getVideoType(); |
| | | if (!VideoTypeEnum.HEALTH.getValue().equals(videoType)) { |
| | | log.error("删除非大健康视频视频id为------->"+id); |
| | | log.error("删除非大健康视频视频id为------->" + id); |
| | | return Result.error("删除失败"); |
| | | } |
| | | baseMapper.deleteById(id); |
| | |
| | | Assert.notNull(entity, "记录不存在"); |
| | | String videoType = entity.getVideoType(); |
| | | if (!VideoTypeEnum.COOK.getValue().equals(videoType)) { |
| | | log.error("删除非大神厨视频视频id为------->"+id); |
| | | log.error("删除非大神厨视频视频id为------->" + id); |
| | | return Result.error("删除失败"); |
| | | } |
| | | baseMapper.deleteById(id); |
| | |
| | | } |
| | | } |
| | | // 标识该视频需要通过定时任务统计收藏数 |
| | | if (Objects.nonNull(video) && ! video.getCollectNumJob()) { |
| | | if (Objects.nonNull(video) && !video.getCollectNumJob()) { |
| | | new LambdaUpdateChainWrapper<>(baseMapper) |
| | | .eq(Video::getId, video.getId()) |
| | | .set(Video::getCollectNumJob, Boolean.TRUE) |
| | |
| | | } |
| | | } |
| | | // 标识该视频需要通过定时任务统计收藏数 |
| | | if (Objects.nonNull(video) && ! video.getCollectNumJob()) { |
| | | if (Objects.nonNull(video) && !video.getCollectNumJob()) { |
| | | new LambdaUpdateChainWrapper<>(baseMapper) |
| | | .eq(Video::getId, video.getId()) |
| | | .set(Video::getThumbsUpNumJob, Boolean.TRUE) |