|
@@ -1,6 +1,8 @@
|
|
|
package cn.reghao.dfs.store.task;
|
|
package cn.reghao.dfs.store.task;
|
|
|
|
|
|
|
|
import cn.reghao.dfs.store.db.repository.MediaRepository;
|
|
import cn.reghao.dfs.store.db.repository.MediaRepository;
|
|
|
|
|
+import cn.reghao.dfs.store.db.repository.ObjectRepository;
|
|
|
|
|
+import cn.reghao.dfs.store.model.po.FileMeta;
|
|
|
import cn.reghao.dfs.store.model.vo.ObjectProp;
|
|
import cn.reghao.dfs.store.model.vo.ObjectProp;
|
|
|
import cn.reghao.dfs.store.model.vo.ObjectResult;
|
|
import cn.reghao.dfs.store.model.vo.ObjectResult;
|
|
|
import cn.reghao.dfs.store.service.FileStoreService;
|
|
import cn.reghao.dfs.store.service.FileStoreService;
|
|
@@ -27,16 +29,48 @@ public class ImageFileProcessor {
|
|
|
private final FileStoreService fileStoreService;
|
|
private final FileStoreService fileStoreService;
|
|
|
private final ObjectNameService objectNameService;
|
|
private final ObjectNameService objectNameService;
|
|
|
private final PutObjectService putObjectService;
|
|
private final PutObjectService putObjectService;
|
|
|
|
|
+ private final ObjectRepository objectRepository;
|
|
|
|
|
|
|
|
public ImageFileProcessor(MediaRepository mediaRepository, FileStoreService fileStoreService,
|
|
public ImageFileProcessor(MediaRepository mediaRepository, FileStoreService fileStoreService,
|
|
|
- ObjectNameService objectNameService, PutObjectService putObjectService) {
|
|
|
|
|
|
|
+ ObjectNameService objectNameService, PutObjectService putObjectService,
|
|
|
|
|
+ ObjectRepository objectRepository) {
|
|
|
this.mediaRepository = mediaRepository;
|
|
this.mediaRepository = mediaRepository;
|
|
|
this.fileStoreService = fileStoreService;
|
|
this.fileStoreService = fileStoreService;
|
|
|
this.objectNameService = objectNameService;
|
|
this.objectNameService = objectNameService;
|
|
|
this.putObjectService = putObjectService;
|
|
this.putObjectService = putObjectService;
|
|
|
|
|
+ this.objectRepository = objectRepository;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void process(String objectName, String objectId, String absolutePath) {
|
|
|
|
|
|
|
+ public void process(ObjectResult objectResult) {
|
|
|
|
|
+ String objectId = objectResult.getObjectId();
|
|
|
|
|
+ boolean duplicate = objectResult.isDuplicate();
|
|
|
|
|
+ if (duplicate) {
|
|
|
|
|
+ String dupObjectId = objectResult.getDupObjectId();
|
|
|
|
|
+ ImageFile imageFile = mediaRepository.findImageFile(dupObjectId);
|
|
|
|
|
+ String originalUrl = imageFile.getOriginalUrl();
|
|
|
|
|
+ String originalObjectName = originalUrl.replace("", "");
|
|
|
|
|
+ FileMeta fileMeta = objectRepository.getByObjectName(originalObjectName);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ String originalUrl1 = "";
|
|
|
|
|
+
|
|
|
|
|
+ String jpegUrl = imageFile.getWebpUrl();
|
|
|
|
|
+ String jpegUrl1 = "";
|
|
|
|
|
+
|
|
|
|
|
+ String webpUrl = imageFile.getThumbnailUrl();
|
|
|
|
|
+ String webpUrl1 = "";
|
|
|
|
|
+
|
|
|
|
|
+ int width = imageFile.getWidth();
|
|
|
|
|
+ int height = imageFile.getHeight();
|
|
|
|
|
+ boolean horizontal = imageFile.getHorizontal();
|
|
|
|
|
+
|
|
|
|
|
+ ImageFile imageFile1 = new ImageFile(objectId, width, height, horizontal, originalUrl1, jpegUrl1, webpUrl1);
|
|
|
|
|
+ mediaRepository.saveImageFile(imageFile1);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String objectName = objectResult.getObjectName();
|
|
|
|
|
+ String absolutePath = objectResult.getAbsolutePath();
|
|
|
try {
|
|
try {
|
|
|
String format = ImageOps.getFormat(new File(absolutePath));
|
|
String format = ImageOps.getFormat(new File(absolutePath));
|
|
|
String jpegUrl;
|
|
String jpegUrl;
|