| | |
| | | |
| | | import cn.lili.base.Result; |
| | | import cn.lili.common.exception.ServiceException; |
| | | import cn.lili.common.utils.StringUtils; |
| | | import cn.lili.cos.CosSTS; |
| | | import cn.lili.modules.lmk.domain.entity.LmkFile; |
| | | import cn.lili.modules.lmk.domain.entity.Video; |
| | | import cn.lili.modules.lmk.domain.form.FileInfoForm; |
| | | import cn.lili.modules.lmk.domain.vo.LmkFileVO; |
| | | import cn.lili.modules.lmk.mapper.LmkFileMapper; |
| | | import cn.lili.modules.lmk.mapper.VideoMapper; |
| | | import cn.lili.modules.lmk.service.LmkFileService; |
| | | import cn.lili.utils.COSUtil; |
| | | import cn.lili.utils.FileUtil; |
| | |
| | | private final LmkFileMapper lmkFileMapper; |
| | | private final COSUtil cosUtil; |
| | | |
| | | private final VideoMapper videoMapper; |
| | | @Override |
| | | public Result generateVideoCoverUrl(String videoId, Long snapshotTime, Integer width, Integer height){ |
| | | Video video = videoMapper.selectById(videoId); |
| | | if (video != null){ |
| | | if (StringUtils.isNotBlank(video.getCoverUrl())){ |
| | | return Result.ok().data(cosUtil.getPreviewUrl(video.getCoverUrl())); |
| | | } |
| | | //获得videoKey |
| | | try { |
| | | System.out.println(video.getVideoFileKey()); |
| | | MultipartFile file =cosUtil.captureVideoCoverAsMultipart(cosUtil.getPreviewUrl(video.getVideoFileKey()), width, height); |
| | | LmkFileVO fileVo = (LmkFileVO) this.uploadObject(file).get("data"); |
| | | video.setCoverUrl(fileVo.getFileKey()); |
| | | videoMapper.updateById(video); |
| | | return Result.ok().data(fileVo.getUrl()); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | } |
| | | return Result.ok(); |
| | | } |
| | | |
| | | @Override |
| | | public Result uploadObject(MultipartFile file) { |