소스 검색

更新对图片文件的处理

reghao 2 년 전
부모
커밋
91344c40b5

+ 13 - 4
dfs-store/src/main/java/cn/reghao/dfs/store/controller/ObjectUploadController.java

@@ -7,6 +7,8 @@ import cn.reghao.dfs.store.service.FileStoreService;
 import cn.reghao.dfs.store.service.ObjectNameService;
 import cn.reghao.dfs.store.service.PutObjectService;
 import cn.reghao.dfs.store.task.FileProcessor;
+import cn.reghao.dfs.store.util.ObjectUtil;
+import cn.reghao.dfs.store.util.StringUtil;
 import cn.reghao.jutil.jdk.result.WebResult;
 import cn.reghao.jutil.jdk.security.DigestUtil;
 import cn.reghao.jutil.web.ServletUtil;
@@ -45,13 +47,13 @@ public class ObjectUploadController {
         this.fileProcessor = fileProcessor;
     }
 
-    //@PutMapping(value = "/**")
-    @PutMapping(value = "/")
+    @PutMapping(value = "/**")
     public String putObject(@RequestBody File file) {
         try {
             HttpServletRequest servletRequest = ServletUtil.getRequest();
             int channelId = Integer.parseInt(servletRequest.getHeader("x-channel-id"));
             String sha256sum = servletRequest.getHeader("x-content-sha256sum");
+            String objectName = ObjectUtil.getObjectName();
             boolean ret = channelValidateService.validate(file, channelId);
             if (!ret) {
                 return WebResult.failWithMsg("the format or size of upload file error");
@@ -67,8 +69,9 @@ public class ObjectUploadController {
             String contentId = UUID.randomUUID().toString().replace("-", "");
             File savedFile = fileStoreService.saveFile(file, contentId);
 
-            ObjectProp objectProp = objectNameService.getObjectProp(channelId);
             String originalFilename = file.getName();
+            String suffix = StringUtil.getSuffix(originalFilename);
+            ObjectProp objectProp = objectNameService.getObjectProp(channelId, suffix);
             ObjectResult objectResult = putObjectService.putObject(objectProp, contentId, savedFile, originalFilename, sha256sum1);
 
             UploadFileRet uploadFileRet = fileProcessor.process(objectResult, channelId);
@@ -94,12 +97,18 @@ public class ObjectUploadController {
         File savedFile = fileStoreService.saveFile(file.getInputStream(), contentId, size);
         boolean ret = channelValidateService.validate(savedFile, channelId);
         if (!ret) {
+            FileUtils.deleteQuietly(savedFile);
             return WebResult.failWithMsg("the format or size of upload file error");
         }
 
         String sha256sum1 = DigestUtil.sha256sum(savedFile.getAbsolutePath());
-        ObjectProp objectProp = objectNameService.getObjectProp(channelId);
         String originalFilename = file.getOriginalFilename();
+        if (originalFilename == null) {
+            originalFilename = "";
+        }
+
+        String suffix = StringUtil.getSuffix(originalFilename);
+        ObjectProp objectProp = objectNameService.getObjectProp(channelId, suffix);
         ObjectResult objectResult = putObjectService.putObject(objectProp, contentId, savedFile, originalFilename, sha256sum1);
 
         UploadFileRet uploadFileRet = fileProcessor.process(objectResult, channelId);

+ 2 - 2
dfs-store/src/main/java/cn/reghao/dfs/store/model/po/FileMeta.java

@@ -18,13 +18,13 @@ import lombok.Setter;
 public class FileMeta extends BaseObject<Integer> {
     private String objectName;
     private String objectId;
+    private String pid;
     private String contentId;
+    private String sha256sum;
     private String filename;
     private Long size;
     private Integer fileType;
     private String contentType;
-    private String sha256sum;
-    private String pid;
     private Long uploadBy;
     private Boolean diskFile;
     private int acl;

+ 13 - 0
dfs-store/src/main/java/cn/reghao/dfs/store/model/po/ImageFile.java

@@ -1,6 +1,7 @@
 package cn.reghao.dfs.store.model.po;
 
 import cn.reghao.jutil.jdk.db.BaseObject;
+import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.NoArgsConstructor;
@@ -47,4 +48,16 @@ public class ImageFile extends BaseObject<Integer> {
         this.webpObjectId = webpObjectId;
         this.webpUrl = webpUrl;
     }
+
+    public ImageFile(String imageFileId, String jpegObjectId, String jpegUrl, Integer width, Integer height,
+                     Boolean horizontal, String thumbnailObjectId, String thumbnailUrl) {
+        this.imageFileId = imageFileId;
+        this.width = width;
+        this.height = height;
+        this.horizontal = horizontal;
+        this.jpegObjectId = jpegObjectId;
+        this.jpegUrl = jpegUrl;
+        this.thumbnailObjectId = thumbnailObjectId;
+        this.thumbnailUrl = thumbnailUrl;
+    }
 }

+ 6 - 2
dfs-store/src/main/java/cn/reghao/dfs/store/service/ObjectMultipartUploadService.java

@@ -4,6 +4,7 @@ import cn.reghao.dfs.store.config.OssProperties;
 import cn.reghao.dfs.store.db.mapper.FileMetaMapper;
 import cn.reghao.dfs.store.model.dto.PathUrl;
 import cn.reghao.dfs.store.model.vo.ObjectProp;
+import cn.reghao.dfs.store.util.StringUtil;
 import cn.reghao.oss.api.rest.UploadFilePart;
 import cn.reghao.oss.api.rest.UploadPrepare;
 import cn.reghao.oss.api.rest.UploadPrepareRet;
@@ -76,7 +77,9 @@ public class ObjectMultipartUploadService {
         String sha256sum = uploadFilePart.getIdentifier();
         FileMeta fileMeta = fileMetaMapper.findBySha256sum(sha256sum);
         if (fileMeta != null) {
-            ObjectProp objectProp = objectNameService.getObjectProp(uploadFilePart.getChannelId());
+            String objectName = fileMeta.getObjectName();
+            String suffix = StringUtil.getSuffix(objectName);
+            ObjectProp objectProp = objectNameService.getObjectProp(uploadFilePart.getChannelId(), suffix);
             putObjectService.copyObject(objectProp, filename, fileMeta);
 
             String url = String.format("https://%s/%s", domain, objectProp);
@@ -113,7 +116,8 @@ public class ObjectMultipartUploadService {
             }
 
             int channelId = uploadFilePart.getChannelId();
-            ObjectProp objectProp = objectNameService.getObjectProp(channelId);
+            String suffix = StringUtil.getSuffix(filename);
+            ObjectProp objectProp = objectNameService.getObjectProp(channelId, suffix);
             File savedFile = new File(absolutePath);
             putObjectService.putObject(objectProp, contentId, savedFile, filename, absolutePath);
 

+ 2 - 2
dfs-store/src/main/java/cn/reghao/dfs/store/service/ObjectNameService.java

@@ -34,14 +34,14 @@ public class ObjectNameService {
         return url.replace(String.format("//%s/", domain), "");
     }
 
-    public ObjectProp getObjectProp(int channelId) throws Exception {
+    public ObjectProp getObjectProp(int channelId, String suffix) throws Exception {
         UploadChannel channel = UploadChannel.getUploadChannel(channelId);
         if (channel == null) {
             throw new Exception("channelId 不合法");
         }
 
         String objectPrefix = channel.getPrefix();
-        String objectName = objectPrefix + UUID.randomUUID().toString().replace("-", "");
+        String objectName = objectPrefix + UUID.randomUUID().toString().replace("-", "") + suffix;
         boolean diskFile;
         int acl;
         if (channelId == UploadChannel.disk.getCode()) {

+ 1 - 14
dfs-store/src/main/java/cn/reghao/dfs/store/task/DiskFileProcessor.java

@@ -2,8 +2,6 @@ package cn.reghao.dfs.store.task;
 
 import cn.reghao.dfs.store.model.vo.ObjectResult;
 import cn.reghao.dfs.store.service.ObjectNameService;
-import cn.reghao.dfs.store.service.PutObjectService;
-import cn.reghao.dfs.store.util.StringUtil;
 import cn.reghao.oss.api.rest.UploadFileRet;
 import org.springframework.stereotype.Service;
 
@@ -13,11 +11,9 @@ import org.springframework.stereotype.Service;
  */
 @Service
 public class DiskFileProcessor {
-    private final PutObjectService putObjectService;
     private final ObjectNameService objectNameService;
 
-    public DiskFileProcessor(PutObjectService putObjectService, ObjectNameService objectNameService) {
-        this.putObjectService = putObjectService;
+    public DiskFileProcessor(ObjectNameService objectNameService) {
         this.objectNameService = objectNameService;
     }
 
@@ -25,15 +21,6 @@ public class DiskFileProcessor {
         String objectName = objectResult.getObjectName();
         String objectId = objectResult.getObjectId();
         String url = objectNameService.getObjectUrl(objectName);
-        boolean duplicate = objectResult.isDuplicate();
-        if (duplicate) {
-            String suffix = StringUtil.getSuffix(objectName);
-            ObjectResult objectResult1 = putObjectService.copyObject(objectName, suffix);
-            String objectId1 = objectResult1.getObjectId();
-            String url1 = objectNameService.getObjectUrl(objectResult1.getObjectName());
-            return new UploadFileRet(objectId1, url1);
-        }
-
         return new UploadFileRet(objectId, url);
     }
 }

+ 8 - 2
dfs-store/src/main/java/cn/reghao/dfs/store/task/FileProcessor.java

@@ -21,7 +21,7 @@ public class FileProcessor {
     private final ImageFileProcessor imageFileProcessor;
     private final VideoFileProcessor videoFileProcessor;
     private final AudioFileProcessor audioFileProcessor;
-    private DiskFileProcessor diskFileProcessor;
+    private final DiskFileProcessor diskFileProcessor;
 
     public FileProcessor(ImageFileProcessor imageFileProcessor, VideoFileProcessor videoFileProcessor,
                          AudioFileProcessor audioFileProcessor, DiskFileProcessor diskFileProcessor) {
@@ -46,10 +46,16 @@ public class FileProcessor {
                 uploadFileRet = videoFileProcessor.process(objectResult);
                 break;
             case cover:
+                uploadFileRet = imageFileProcessor.processCover(objectResult);
+                break;
             case avatar:
+                uploadFileRet = imageFileProcessor.processAvatar(objectResult);
+                break;
             case photo:
+                uploadFileRet = imageFileProcessor.processPhoto(objectResult);
+                break;
             case image:
-                uploadFileRet = imageFileProcessor.process(objectResult);
+                uploadFileRet = imageFileProcessor.processImage(objectResult);
                 break;
             case audio:
                 uploadFileRet = audioFileProcessor.process(objectResult);

+ 189 - 49
dfs-store/src/main/java/cn/reghao/dfs/store/task/ImageFileProcessor.java

@@ -11,6 +11,7 @@ import cn.reghao.jutil.jdk.security.DigestUtil;
 import cn.reghao.dfs.store.model.po.ImageFile;
 import cn.reghao.jutil.media.ImageOps;
 import cn.reghao.oss.api.rest.UploadFileRet;
+import net.coobird.thumbnailator.Thumbnails;
 import org.springframework.stereotype.Service;
 
 import javax.imageio.ImageIO;
@@ -39,64 +40,128 @@ public class ImageFileProcessor {
         this.putObjectService = putObjectService;
     }
 
-    public UploadFileRet process(ObjectResult objectResult) {
+    public UploadFileRet processCover(ObjectResult objectResult) {
         String originalObjectId = objectResult.getObjectId();
         boolean duplicate = objectResult.isDuplicate();
         if (duplicate) {
             String dupObjectId = objectResult.getDupObjectId();
             ImageFile imageFile = mediaRepository.findImageFile(dupObjectId);
 
-            String jpegObjectName = objectNameService.getObjectNameFromUrl(imageFile.getJpegUrl());
-            String format = StringUtil.getSuffix(jpegObjectName);
-            ObjectResult objectResult2 = putObjectService.copyObject(jpegObjectName, format);
-            String jpegObjectId = objectResult2.getObjectId();
-            String jpegUrl = objectNameService.getObjectUrl(objectResult2.getObjectName());
+            ObjectResult jpegResult = getCopiedObject(imageFile.getJpegUrl());
+            String jpegObjectId = jpegResult.getObjectId();
+            String jpegUrl = objectNameService.getObjectUrl(jpegResult.getObjectName());
 
-            String webpObjectName = objectNameService.getObjectNameFromUrl(imageFile.getWebpUrl());
-            ObjectResult objectResult3 = putObjectService.copyObject(webpObjectName, ".webp");
-            String webpObjectId = objectResult3.getObjectId();
-            String webpUrl = objectNameService.getObjectUrl(objectResult3.getObjectName());
+            int width = imageFile.getWidth();
+            int height = imageFile.getHeight();
+            boolean horizontal = imageFile.getHorizontal();
+            ImageFile imageFile1 = new ImageFile(originalObjectId, width, height, horizontal, jpegObjectId, jpegUrl);
+            mediaRepository.saveImageFile(imageFile1);
+            return new UploadFileRet(originalObjectId, jpegUrl);
+        }
+
+        String absolutePath = objectResult.getAbsolutePath();
+        String format = ImageOps.getFormat(new File(absolutePath));
+        try {
+            ObjectResult jpegResult = getJpegObject(objectResult, format);
+            String jpegObjectId = jpegResult.getObjectId();
+            String jpegUrl = objectNameService.getObjectUrl(jpegResult.getObjectName());
+
+            ImageOps.Size size = ImageOps.info(new File(absolutePath));
+            int width = size.getWidth();
+            int height = size.getHeight();
+            boolean horizontal = width > height;
+            ImageFile imageFile = new ImageFile(originalObjectId, width, height, horizontal, jpegObjectId, jpegUrl);
+            mediaRepository.saveImageFile(imageFile);
+            return new UploadFileRet(originalObjectId, jpegUrl);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public UploadFileRet processAvatar(ObjectResult objectResult) {
+        String originalObjectId = objectResult.getObjectId();
+        boolean duplicate = objectResult.isDuplicate();
+        if (duplicate) {
+            String dupObjectId = objectResult.getDupObjectId();
+            ImageFile imageFile = mediaRepository.findImageFile(dupObjectId);
+
+            ObjectResult jpegResult = getCopiedObject(imageFile.getJpegUrl());
+            String jpegObjectId = jpegResult.getObjectId();
+            String jpegUrl = objectNameService.getObjectUrl(jpegResult.getObjectName());
+
+            ObjectResult thumbnailResult = getCopiedObject(imageFile.getThumbnailUrl());
+            String thumbnailObjectId = thumbnailResult.getObjectId();
+            String thumbnailUrl = objectNameService.getObjectUrl(thumbnailResult.getObjectName());
 
             int width = imageFile.getWidth();
             int height = imageFile.getHeight();
             boolean horizontal = imageFile.getHorizontal();
+            ImageFile imageFile1 = new ImageFile(originalObjectId, jpegObjectId, jpegUrl, width, height, horizontal,
+                    thumbnailObjectId, thumbnailUrl);
+            mediaRepository.saveImageFile(imageFile1);
+            return new UploadFileRet(originalObjectId, jpegUrl);
+        }
+
+        String absolutePath = objectResult.getAbsolutePath();
+        String format = ImageOps.getFormat(new File(absolutePath));
+        try {
+            ObjectResult jpegResult = getJpegObject(objectResult, format);
+            String jpegObjectId = jpegResult.getObjectId();
+            String jpegUrl = objectNameService.getObjectUrl(jpegResult.getObjectName());
+
+            ObjectResult thumbnailResult = getThumbnailObject(objectResult);
+            String thumbnailObjectId = thumbnailResult.getObjectId();
+            String thumbnailUrl = objectNameService.getObjectUrl(thumbnailResult.getObjectName());
+
+            ImageOps.Size size = ImageOps.info(new File(absolutePath));
+            int width = size.getWidth();
+            int height = size.getHeight();
+            boolean horizontal = width > height;
+            ImageFile imageFile = new ImageFile(originalObjectId, jpegObjectId, jpegUrl, width, height, horizontal,
+                    thumbnailObjectId, thumbnailUrl);
+            mediaRepository.saveImageFile(imageFile);
+            return new UploadFileRet(originalObjectId, jpegUrl);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    public UploadFileRet processPhoto(ObjectResult objectResult) {
+        String originalObjectId = objectResult.getObjectId();
+        boolean duplicate = objectResult.isDuplicate();
+        if (duplicate) {
+            String dupObjectId = objectResult.getDupObjectId();
+            ImageFile imageFile = mediaRepository.findImageFile(dupObjectId);
 
+            ObjectResult jpegResult = getCopiedObject(imageFile.getJpegUrl());
+            String jpegObjectId = jpegResult.getObjectId();
+            String jpegUrl = objectNameService.getObjectUrl(jpegResult.getObjectName());
+
+            ObjectResult webpResult = getCopiedObject(imageFile.getWebpUrl());
+            String webpObjectId = webpResult.getObjectId();
+            String webpUrl = objectNameService.getObjectUrl(webpResult.getObjectName());
+
+            int width = imageFile.getWidth();
+            int height = imageFile.getHeight();
+            boolean horizontal = imageFile.getHorizontal();
             ImageFile imageFile1 = new ImageFile(originalObjectId, width, height, horizontal,
                     jpegObjectId, jpegUrl, webpObjectId, webpUrl);
             mediaRepository.saveImageFile(imageFile1);
-            return new UploadFileRet(jpegObjectId, jpegUrl);
+            return new UploadFileRet(originalObjectId, jpegUrl);
         }
 
-        String originalObjectName = objectResult.getObjectName();
         String absolutePath = objectResult.getAbsolutePath();
+        String format = ImageOps.getFormat(new File(absolutePath));
         try {
-            ObjectResult objectResult1;
-            String jpegObjectId;
-            String jpegUrl;
-            String webpObjectId;
-            String webpUrl;
-            String format = ImageOps.getFormat(new File(absolutePath));
-            if (imageFormats.contains(format)) {
-                String jpegObjectName = objectResult.getObjectName();
-                objectResult1 = putObjectService.copyObject(jpegObjectName, "."+format);
-                jpegObjectId = objectResult1.getObjectId();
-                jpegUrl = objectNameService.getObjectUrl(objectResult1.getObjectName());
-            } else {
-                ObjectResult objectResult2 = getJpegObject(originalObjectName, absolutePath);
-                jpegObjectId = objectResult2.getObjectId();
-                jpegUrl = objectNameService.getObjectUrl(objectResult2.getObjectName());
-            }
-
-            if (format.equals("webp")) {
-                String webpObjectName = objectResult.getObjectName();
-                ObjectResult objectResult3 = putObjectService.copyObject(webpObjectName, ".webp");
-                webpObjectId = objectResult3.getObjectId();
-                webpUrl = objectNameService.getObjectUrl(objectResult3.getObjectName());
-            } else {
-                ObjectResult objectResult3 = getWebpObject(originalObjectName, absolutePath);
-                webpObjectId = objectResult3.getObjectId();
-                webpUrl = objectNameService.getObjectUrl(objectResult3.getObjectName());
-            }
+            ObjectResult jpegResult = getJpegObject(objectResult, format);
+            String jpegObjectId = jpegResult.getObjectId();
+            String jpegUrl = objectNameService.getObjectUrl(jpegResult.getObjectName());
+
+            ObjectResult webpResult = getWebpObject(objectResult, format);
+            String webpObjectId = webpResult.getObjectId();
+            String webpUrl = objectNameService.getObjectUrl(webpResult.getObjectName());
 
             ImageOps.Size size = ImageOps.info(new File(absolutePath));
             int width = size.getWidth();
@@ -112,20 +177,95 @@ public class ImageFileProcessor {
         return null;
     }
 
-    private ObjectResult getJpegObject(String originalObjectName, String originalPath) throws Exception {
-        byte[] bytes = ImageOps.convert2jpg(new File(originalPath));
-        return saveImage(originalObjectName, bytes, ".jpeg");
+    public UploadFileRet processImage(ObjectResult objectResult) {
+        String originalObjectId = objectResult.getObjectId();
+        boolean duplicate = objectResult.isDuplicate();
+        if (duplicate) {
+            String dupObjectId = objectResult.getDupObjectId();
+            ImageFile imageFile = mediaRepository.findImageFile(dupObjectId);
+
+            ObjectResult jpegResult = getCopiedObject(imageFile.getJpegUrl());
+            String jpegObjectId = jpegResult.getObjectId();
+            String jpegUrl = objectNameService.getObjectUrl(jpegResult.getObjectName());
+
+            int width = imageFile.getWidth();
+            int height = imageFile.getHeight();
+            boolean horizontal = imageFile.getHorizontal();
+            ImageFile imageFile1 = new ImageFile(originalObjectId, width, height, horizontal, jpegObjectId, jpegUrl);
+            mediaRepository.saveImageFile(imageFile1);
+            return new UploadFileRet(originalObjectId, jpegUrl);
+        }
+
+        String absolutePath = objectResult.getAbsolutePath();
+        String format = ImageOps.getFormat(new File(absolutePath));
+        try {
+            ObjectResult jpegResult = getJpegObject(objectResult, format);
+            String jpegObjectId = jpegResult.getObjectId();
+            String jpegUrl = objectNameService.getObjectUrl(jpegResult.getObjectName());
+
+            ImageOps.Size size = ImageOps.info(new File(absolutePath));
+            int width = size.getWidth();
+            int height = size.getHeight();
+            boolean horizontal = width > height;
+            ImageFile imageFile = new ImageFile(originalObjectId, width, height, horizontal, jpegObjectId, jpegUrl);
+            mediaRepository.saveImageFile(imageFile);
+            return new UploadFileRet(originalObjectId, jpegUrl);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
     }
 
-    private ObjectResult getWebpObject(String originalObjectName, String originalPath) throws Exception {
-        BufferedImage bi = ImageIO.read(new File(originalPath));
-        ByteArrayOutputStream baos = new ByteArrayOutputStream();
-        ImageIO.write(bi, "webp", baos);
-        return saveImage(originalObjectName, baos.toByteArray(), ".webp");
+    private ObjectResult getCopiedObject(String url) {
+        String objectName = objectNameService.getObjectNameFromUrl(url);
+        String format = StringUtil.getSuffix(objectName);
+        return putObjectService.copyObject(objectName, format);
     }
 
-    private ObjectResult getThumbnailObject(String originalObjectName, String originalPath) throws Exception {
-        return null;
+    private ObjectResult getJpegObject(ObjectResult objectResult, String format) throws Exception {
+        String originalObjectName = objectResult.getObjectName();
+        String absolutePath = objectResult.getAbsolutePath();
+        ObjectResult objectResult1;
+        if (imageFormats.contains(format)) {
+            String jpegObjectName = objectResult.getObjectName();
+            objectResult1 = putObjectService.copyObject(jpegObjectName, "."+format);
+        } else {
+            byte[] bytes = ImageOps.convert2jpg(new File(absolutePath));
+            objectResult1 = saveImage(originalObjectName, bytes, ".jpeg");
+        }
+
+        return objectResult1;
+    }
+
+    private ObjectResult getWebpObject(ObjectResult objectResult, String format) throws Exception {
+        String originalObjectName = objectResult.getObjectName();
+        String absolutePath = objectResult.getAbsolutePath();
+        ObjectResult objectResult1;
+        if (format.equals("webp")) {
+            String webpObjectName = objectResult.getObjectName();
+            objectResult1 = putObjectService.copyObject(webpObjectName, ".webp");
+        } else {
+            BufferedImage bi = ImageIO.read(new File(absolutePath));
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ImageIO.write(bi, "webp", baos);
+            objectResult1 = saveImage(originalObjectName, baos.toByteArray(), ".webp");
+        }
+
+        return objectResult1;
+    }
+
+    private ObjectResult getThumbnailObject(ObjectResult objectResult) throws Exception {
+        String originalObjectName = objectResult.getObjectName();
+        String absolutePath = objectResult.getAbsolutePath();
+
+        int width = 480;
+        int height = 360;
+        BufferedImage bi = Thumbnails.of(absolutePath)
+                .size(width, height)
+                .asBufferedImage();
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        ImageIO.write(bi, "jpeg", baos);
+        return saveImage(originalObjectName, baos.toByteArray(), ".jpeg");
     }
 
     private ObjectResult saveImage(String originalObjectName, byte[] bytes, String suffix) throws Exception {

+ 4 - 4
dfs-store/src/main/resources/mapper/ImageFileMapper.xml

@@ -4,16 +4,16 @@
 <mapper namespace="cn.reghao.dfs.store.db.mapper.ImageFileMapper">
     <insert id="save" useGeneratedKeys="true" keyProperty="id">
         insert into image_file
-        (`id`,`deleted`,`create_time`,`update_time`,`image_file_id`,`width`,`height`,`horizontal`,`jpeg_url`,`webp_url`,`thumbnail_url`)
+        (`id`,`deleted`,`create_time`,`update_time`,`image_file_id`,`width`,`height`,`horizontal`,`jpeg_object_id`,`jpeg_url`,`webp_object_id`,`webp_url`,`thumbnail_object_id`,`thumbnail_url`)
         values 
-        (#{id},#{deleted},#{createTime},#{updateTime},#{imageFileId},#{width},#{height},#{horizontal},#{jpegUrl},#{webpUrl},#{thumbnailUrl})
+        (#{id},#{deleted},#{createTime},#{updateTime},#{imageFileId},#{width},#{height},#{horizontal},#{jpegObjectId},#{jpegUrl},#{webpObjectId},#{webpUrl},#{thumbnailObjectId},#{thumbnailUrl})
     </insert>
     <insert id="saveAll" useGeneratedKeys="true" keyProperty="id">
         insert into image_file
-        (`id`,`deleted`,`create_time`,`update_time`,`image_file_id`,`width`,`height`,`horizontal`,`jpeg_url`,`webp_url`,`thumbnail_url`)
+        (`id`,`deleted`,`create_time`,`update_time`,`image_file_id`,`width`,`height`,`horizontal`,`jpeg_object_id`,`jpeg_url`,`webp_object_id`,`webp_url`,`thumbnail_object_id`,`thumbnail_url`)
         values
         <foreach collection="list" item="item" index="index" separator=",">
-            (#{item.id},#{item.deleted},#{item.createTime},#{item.updateTime},#{item.imageFileId},#{item.width},#{item.height},#{item.horizontal},#{item.jpegUrl},#{item.webpUrl},#{item.thumbnailUrl})
+            (#{item.id},#{item.deleted},#{item.createTime},#{item.updateTime},#{item.imageFileId},#{item.width},#{item.height},#{item.horizontal},#{item.jpegObjectId},#{item.jpegUrl},#{item.webpObjectId},#{item.webpUrl},#{item.thumbnailObjectId},#{item.thumbnailUrl})
         </foreach>
     </insert>