|
@@ -231,13 +231,15 @@ public class CommunityArticleController extends BaseController {
|
|
|
//检查附近是否是需要加水印
|
|
|
boolean isWaterMark = communityArticle.isWaterMark();
|
|
|
boolean isFillWater = communityArticle.isFillWater();
|
|
|
- log.info("isWaterMark:{},isFillWater:{}", isWaterMark, isFillWater);
|
|
|
+ log.info("isWaterMark:{},isFillWater:{},Images:{}", isWaterMark, isFillWater, communityArticle.getImages());
|
|
|
if (isWaterMark && null != communityArticle.getImages()) {
|
|
|
+ log.info("需要做图片/视频修改...");
|
|
|
//获取用户名
|
|
|
String nickName = SecurityUtils.getLoginUser().getUser().getNickName();
|
|
|
// 添加水印
|
|
|
for (CommunityImagesVo image : communityArticle.getImages()) {
|
|
|
String fileType = FileUtils.getFileTypeFromUrl(image.getImages());
|
|
|
+ log.info("fileType:{}", fileType);
|
|
|
if ("image".equals(fileType)) {
|
|
|
// 本地临时水印文件路径
|
|
|
String tempWatermarkFile = System.getProperty("java.io.tmpdir") + File.separator + "watermark_" + FileUtils.getName(image.getImages());
|
|
@@ -255,6 +257,22 @@ public class CommunityArticleController extends BaseController {
|
|
|
String fileNameResult = OssUtils.uploadFile(tempWatermarkFile);
|
|
|
image.setImages(fileNameResult.replace("https://cysd.oss-cn-shanghai.aliyuncs.com", "http://file.iciyuanshidai.com/"));
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ if ("video".equals(fileType)) {
|
|
|
+ String tempThumbnailFile = System.getProperty("java.io.tmpdir") + File.separator + "thumbnail.jpg";
|
|
|
+
|
|
|
+ boolean screenshotSuccess = FileUtils.screenShots(image.getImages(), tempThumbnailFile, "00:00:01");
|
|
|
+ if (!screenshotSuccess) {
|
|
|
+ throw new RuntimeException("生成视频缩略图失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 上传缩略图到OSS
|
|
|
+ String thumbnailPath = OssUtils.uploadFile(tempThumbnailFile);
|
|
|
+ image.setCompressedImages(thumbnailPath.replace("https://cysd.oss-cn-shanghai.aliyuncs.com", "http://file.iciyuanshidai.com/"));
|
|
|
+ // 删除临时缩略图文件
|
|
|
+ new File(tempThumbnailFile).delete();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|