Pārlūkot izejas kodu

素材库, 上传image图片 处理thumb

wuweihao 2 gadi atpakaļ
vecāks
revīzija
46af63d6f7

+ 7 - 7
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/FodderServiceImpl.java

@@ -103,10 +103,7 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
         // 文件名校验长度
         String prefix = StringUtils.substringBeforeLast(fileName, ".");
         if (prefix.length() > 50) {
-
-            // return Result.failure(3003, "文件名称不允许超过50个字节");
             prefix = StrUtil.sub(prefix, 0, 50);
-
         }
         String suffix = StringUtils.substringAfterLast(fileName, ".");
         String newName = time + "." + suffix;
@@ -166,10 +163,13 @@ public class FodderServiceImpl extends IBaseServiceImpl<FodderEntity, Long> impl
                 ossUrl = configConstant.ossDomain + ossPath;
 
                 if (type.equals("image")) {
-                    // 图片大于1MB生成缩略图, 小于1MB使用原图作为缩略图
-
-                    iconPath = ossUrl;
-
+                    // 2022-10-27,图片大于1MB生成缩略图, 小于1MB使用原图作为缩略图
+                    if (size > 1024){
+                        iconPath = convertAndUploadOss(
+                                savePath, configConstant.ossBasePath + "fodder", configConstant.ossDomain, 300, 150, "/thumb_" + newName);
+                    } else {
+                        iconPath = ossUrl;
+                    }
 
                     // todo 这个是很耗新能的,如果新能有问题,改用前端
                     dpi = ImageUtil.dpi(file);

+ 3 - 0
720yun_fd_manage/gis_service/src/main/java/com/gis/service/impl/WorkServiceImpl.java

@@ -426,6 +426,7 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
      * 更新二维码
      */
     private Boolean updateQrCode(String id, String logoUrl) {
+        long startTime = System.currentTimeMillis();
 
         // 网络下载logo图片
         logoUrl = logoUrl + "?m=" + System.currentTimeMillis();
@@ -436,10 +437,12 @@ public class WorkServiceImpl extends IBaseStrServiceImpl<WorkEntity, String> imp
             log.error("logo.jpg文件不存在");
             return false;
         }
+        DateUtils.spendTime(startTime, "logo网络下载");
         log.info("网络下载logo完成");
         String shareUrl = configConstant.domain4dKK + "/panorama/show.html?id=" + id;
         qrCodeUtils.diyLogoQrCode(shareUrl, configConstant.serverBasePath, configConstant.ossBasePath, configConstant.ossDomain, id, logoPath);
         log.info("二维码更新完成");
+        DateUtils.spendTime(startTime, "logo上传oss完成");
         return true;
     }