|
@@ -1,5 +1,6 @@
|
|
|
package cn.reghao.oss.store.db.repository;
|
|
package cn.reghao.oss.store.db.repository;
|
|
|
|
|
|
|
|
|
|
+import cn.reghao.oss.api.dto.FileInfo;
|
|
|
import cn.reghao.oss.store.db.mapper.DataBlockMapper;
|
|
import cn.reghao.oss.store.db.mapper.DataBlockMapper;
|
|
|
import cn.reghao.oss.store.db.mapper.FileMetaMapper;
|
|
import cn.reghao.oss.store.db.mapper.FileMetaMapper;
|
|
|
import cn.reghao.oss.store.model.po.DataBlock;
|
|
import cn.reghao.oss.store.model.po.DataBlock;
|
|
@@ -13,7 +14,9 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author reghao
|
|
* @author reghao
|
|
@@ -89,4 +92,36 @@ public class ObjectRepository {
|
|
|
public ObjectMeta getObjectMetaById(String objectId) {
|
|
public ObjectMeta getObjectMetaById(String objectId) {
|
|
|
return fileMetaMapper.findObjectMetaById(objectId);
|
|
return fileMetaMapper.findObjectMetaById(objectId);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public List<FileInfo> getFiles(String pid, int pageSize, String nextObjectId) {
|
|
|
|
|
+ return fileMetaMapper.findByPid(pid, pageSize, nextObjectId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public List<FileInfo> getFiles(int pageNumber, int pageSize) {
|
|
|
|
|
+ String bucket = "";
|
|
|
|
|
+ String prefix = "image/i/";
|
|
|
|
|
+ String startAfter = "image/cover/";
|
|
|
|
|
+ startAfter = "";
|
|
|
|
|
+ Integer maxKeys = 10;
|
|
|
|
|
+
|
|
|
|
|
+ StringBuilder regex = new StringBuilder();
|
|
|
|
|
+ //regex.append("^").append(prefix).append("([^/])+/?$");
|
|
|
|
|
+ regex.append(prefix);
|
|
|
|
|
+ List<FileMeta> list;
|
|
|
|
|
+ if (startAfter.isBlank()) {
|
|
|
|
|
+ list = fileMetaMapper.findAll0(bucket, maxKeys, regex.toString());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ list = fileMetaMapper.findAll2(bucket, prefix, startAfter, maxKeys);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return list.stream().map(fileMeta -> {
|
|
|
|
|
+ String objectId = fileMeta.getObjectId();
|
|
|
|
|
+ String objectName = fileMeta.getObjectName();
|
|
|
|
|
+ int fileType = fileMeta.getFileType();
|
|
|
|
|
+ String filename = fileMeta.getFilename();
|
|
|
|
|
+ long size = fileMeta.getSize();
|
|
|
|
|
+ LocalDateTime updateTime = fileMeta.getUpdateTime();
|
|
|
|
|
+ return new FileInfo();
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|