fix: 列表查询修改
This commit is contained in:
@@ -29,12 +29,6 @@
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-loadbalancer</artifactId>
|
||||
<version>3.0.6</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>reactor-core</artifactId>
|
||||
<groupId>io.projectreactor</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
|
@@ -18,9 +18,11 @@ import com.schisandra.oss.common.entity.Result;
|
||||
import com.schisandra.oss.domain.bo.SchisandraOssQiniuBO;
|
||||
import com.schisandra.oss.domain.redis.RedisUtil;
|
||||
import com.schisandra.oss.domain.service.SchisandraOssQiniuDomainService;
|
||||
import com.thoughtworks.xstream.annotations.XStreamImplicitCollection;
|
||||
import io.minio.errors.*;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.util.StreamUtils;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -113,6 +115,7 @@ public class SchisandraOssQiniuController {
|
||||
* @date: 2024/6/26 13:55
|
||||
*/
|
||||
@GetMapping("listDir")
|
||||
@Cacheable(value = "qiniuListDir",key = "#target + #userId + #dirName",unless = "#result == null")
|
||||
public Result<String> listQiniuInfo(@RequestParam String userId, @RequestParam String prefix, @RequestParam String bucket) throws Exception {
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
QiNiuOssClient bean = SpringUtil.getBean(OssConstant.OssType.QINIU + userId);
|
||||
@@ -132,6 +135,7 @@ public class SchisandraOssQiniuController {
|
||||
* @date: 2024/6/27 9:41
|
||||
*/
|
||||
@PostMapping("renameFile")
|
||||
@CacheEvict(value = "qiniuListDir",key = "#target + #userId + #dirName")
|
||||
public Result renameQiniuFile(@RequestParam String userId, @RequestParam String bucket, @RequestParam String oldFileName, @RequestParam String newFileName) throws IOException {
|
||||
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
@@ -156,6 +160,7 @@ public class SchisandraOssQiniuController {
|
||||
* @date: 2024/6/27 9:52
|
||||
*/
|
||||
@PostMapping("copyFile")
|
||||
@CacheEvict(value = "qiniuListDir",key = "#target + #userId + #dirName")
|
||||
public Result copyQiniuFile(@RequestParam String userId, @RequestParam String bucket, @RequestParam String oldFilePath, @RequestParam String newFilePath) throws IOException {
|
||||
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
@@ -230,6 +235,7 @@ public class SchisandraOssQiniuController {
|
||||
* @date: 2024/7/8 14:34
|
||||
*/
|
||||
@PostMapping("deleteFile")
|
||||
@CacheEvict(value = "qiniuListDir",key = "#target + #userId + #dirName")
|
||||
public Result deleteQiniuFile(@RequestParam String bucket, @RequestParam String userId, @RequestParam String filePath) {
|
||||
Preconditions.checkNotNull(bucket, "不能为空");
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
@@ -252,6 +258,7 @@ public class SchisandraOssQiniuController {
|
||||
* @date: 2024/7/8 14:34
|
||||
*/
|
||||
@PostMapping("uploadFile")
|
||||
@CacheEvict(value = "qiniuListDir",key = "#target + #userId + #dirName")
|
||||
public Result<OssInfo> uploadQiniuFile(@RequestParam String userId, @RequestParam MultipartFile file, @RequestParam String fileName, @RequestParam String bucket) throws IOException {
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
Preconditions.checkNotNull(fileName, "不能为空");
|
||||
@@ -311,6 +318,7 @@ public class SchisandraOssQiniuController {
|
||||
* @date: 2024/7/8 17:38
|
||||
*/
|
||||
@PostMapping("deleteBucket")
|
||||
@CacheEvict(value = "qiniuBucket",key = "#userId+#bucket")
|
||||
public Result deleteBucket(@RequestParam String userId, @RequestParam String bucket) {
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
Preconditions.checkNotNull(bucket, "不能为空");
|
||||
@@ -332,6 +340,7 @@ public class SchisandraOssQiniuController {
|
||||
*/
|
||||
@SneakyThrows
|
||||
@PostMapping("createBucket")
|
||||
@CacheEvict(value = "qiniuBucket",key = "#userId+#bucket")
|
||||
public Result<String> createBucket(@RequestParam String userId, @RequestParam String bucket, @RequestParam String region) {
|
||||
Preconditions.checkNotNull(userId, "不能为空");
|
||||
Preconditions.checkNotNull(bucket, "不能为空");
|
||||
|
@@ -108,8 +108,18 @@ public class AliOssClient implements StandardOssClient {
|
||||
}
|
||||
|
||||
public List<OssInfo> listAliInfo(String bucket, String prefix){
|
||||
ObjectListing objectListing=null;
|
||||
if (prefix == null) {
|
||||
objectListing = oss.listObjects(bucket, prefix);
|
||||
}else {
|
||||
int index = prefix.lastIndexOf("/");
|
||||
if (index < prefix.length() - 1) {
|
||||
objectListing = oss.listObjects(bucket, prefix+"/");
|
||||
}else {
|
||||
objectListing = oss.listObjects(bucket, prefix);
|
||||
}
|
||||
}
|
||||
// 列举文件。如果不设置Prefix,则列举存储空间下的所有文件。如果设置Prefix,则列举包含指定前缀的文件。
|
||||
ObjectListing objectListing = oss.listObjects(bucket, prefix);
|
||||
List<OSSObjectSummary> sums = objectListing.getObjectSummaries();
|
||||
List<OssInfo> infos = new ArrayList<>();
|
||||
if(prefix == ""){
|
||||
|
@@ -205,10 +205,16 @@ public class MinioOssClient implements StandardOssClient {
|
||||
if (StringUtils.isEmpty(dirName)) {
|
||||
results = minioClient.listObjects(
|
||||
ListObjectsArgs.builder().bucket(bucket).recursive(false).build());
|
||||
} else {
|
||||
int index=dirName.lastIndexOf("/");
|
||||
if (index<dirName.length()-1){
|
||||
results = minioClient.listObjects(
|
||||
ListObjectsArgs.builder().prefix(dirName+"/").bucket(bucket).recursive(false).build());
|
||||
}else {
|
||||
results = minioClient.listObjects(
|
||||
ListObjectsArgs.builder().prefix(dirName).bucket(bucket).recursive(false).build());
|
||||
}
|
||||
}
|
||||
List<OssInfo> infos = new ArrayList<>();
|
||||
results.forEach(r -> {
|
||||
OssInfo info = new OssInfo();
|
||||
|
@@ -101,7 +101,12 @@ public class QiNiuOssClient implements StandardOssClient {
|
||||
*/
|
||||
public List<OssInfo> listfile(String bucket, String prefix) {
|
||||
String delimiter = "";
|
||||
|
||||
if (prefix != null) {
|
||||
int index=prefix.lastIndexOf("/");
|
||||
if (index <prefix.length()-1) {
|
||||
prefix=prefix+"/";
|
||||
}
|
||||
}
|
||||
BucketManager.FileListIterator fileListIterator = bucketManager.createFileListIterator(bucket, prefix, 1000, delimiter);
|
||||
List<OssInfo> infos = new ArrayList<>();
|
||||
while (fileListIterator.hasNext()){
|
||||
|
@@ -200,6 +200,12 @@ public class TencentOssClient implements StandardOssClient {
|
||||
}
|
||||
|
||||
public HashMap<String, String> listTargetDir(String bucket, String dirName) {
|
||||
if (dirName != null) {
|
||||
int index=dirName.lastIndexOf("/");
|
||||
if (index<dirName.length()-1){
|
||||
dirName=dirName+"/";
|
||||
}
|
||||
}
|
||||
ListObjectsRequest listObjectsRequest = new ListObjectsRequest();
|
||||
listObjectsRequest.setBucketName(bucket);
|
||||
listObjectsRequest.setPrefix(dirName);
|
||||
|
Reference in New Issue
Block a user