| | |
| | | return Result.ok("发布成功,视频审核中~"); |
| | | } |
| | | |
| | | @Override |
| | | public Result updatePublish(WxVideoForm form) { |
| | | Video video = baseMapper.selectById(form.getId()); |
| | | if (Objects.isNull(video)) { |
| | | return Result.error("修改视频不存在"); |
| | | } |
| | | // 1.修改视频 |
| | | WxVideoForm.getEntityByForm(form, video); |
| | | video.setAuthorId(UserContext.getCurrentUserId()); |
| | | 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<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()); |
| | | } |
| | | return videoTagRef; |
| | | }).collect(Collectors.toList()); |
| | | videoTagRefService.saveBatch(videoTagRefs); |
| | | // 3. 保存视频文件信息 |
| | | lmkFileService.addByForm(form.getFileInfo()); |
| | | // 4. 处理选择的商品,先删除之前的再新增 |
| | | new LambdaUpdateChainWrapper<>(videoGoodsService.getBaseMapper()) |
| | | .eq(VideoGoods::getVideoId, video.getId()) |
| | | .remove(); |
| | | if (CollectionUtils.isNotEmpty(form.getGoodsList())) { |
| | | List<VideoGoods> videoGoods = new ArrayList<>(2); |
| | | 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.setGoodsNum(form.getGoodsList().get(i).getGoodsNum()); |
| | | e.setOrderNum(i); |
| | | videoGoods.add(e); |
| | | } |
| | | videoGoodsService.saveBatch(videoGoods); |
| | | } |
| | | return Result.ok("发布成功,视频审核中~"); |
| | | } |
| | | |
| | | @Override |
| | | public Result managerPage(ManagerVideoQuery query) { |
| | |
| | | .set(Video::getStatus, VideoStatusEnum.DISABLE.getValue()) |
| | | .update(); |
| | | // TODO 将下架原因以通知的方式告知用户 |
| | | return Result.ok("下架成功"); |
| | | } |
| | | |
| | | @Override |
| | | public Result buyerDownVideo(String id) { |
| | | new LambdaUpdateChainWrapper<>(baseMapper) |
| | | .eq(Video::getId, id) |
| | | .set(Video::getStatus, VideoStatusEnum.DISABLE.getValue()) |
| | | .update(); |
| | | return Result.ok("下架成功"); |
| | | } |
| | | |
| | |
| | | if (Objects.isNull(vo)) { |
| | | return Result.error("视频不存在"); |
| | | } |
| | | vo.setCoverUrl(cosUtil.getPreviewUrl(vo.getCoverFileKey())); |
| | | // vo.setVideoUrl(cosUtil.getPreviewUrl(vo.getVideoFileKey())); |
| | | vo.setVideoUrl("https://videos.pexels.com/video-files/13602965/13602965-hd_1920_1080_30fps.mp4"); |
| | | 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<WxVideoTagForm> tags = videoTagRefService.getTagsByVideoIds(Arrays.asList(vo.getId())) |
| | | .stream() |
| | | .map(i -> { |