|
@@ -19,6 +19,8 @@ import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
|
|
import vip.xiaonuo.auth.core.util.StpLoginUserUtil;
|
|
|
import vip.xiaonuo.disk.commpen.ProducerCommpen;
|
|
import vip.xiaonuo.disk.commpen.ProducerCommpen;
|
|
@@ -30,6 +32,7 @@ import vip.xiaonuo.disk.mapper.ImageMapper;
|
|
|
import vip.xiaonuo.disk.mapper.ResourceFileMapper;
|
|
import vip.xiaonuo.disk.mapper.ResourceFileMapper;
|
|
|
import vip.xiaonuo.disk.mapper.ResourceUserFileMapper;
|
|
import vip.xiaonuo.disk.mapper.ResourceUserFileMapper;
|
|
|
import vip.xiaonuo.disk.mapper.UploadTaskMapper;
|
|
import vip.xiaonuo.disk.mapper.UploadTaskMapper;
|
|
|
|
|
+import vip.xiaonuo.disk.service.IStorageReService;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import javax.imageio.ImageIO;
|
|
import javax.imageio.ImageIO;
|
|
@@ -74,7 +77,8 @@ public class MinioUtil {
|
|
|
private ProducerCommpen producer;
|
|
private ProducerCommpen producer;
|
|
|
@Resource
|
|
@Resource
|
|
|
private KafKaProducerUtil kafKaProducerUtil;
|
|
private KafKaProducerUtil kafKaProducerUtil;
|
|
|
-
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IStorageReService storageReService;
|
|
|
@Resource
|
|
@Resource
|
|
|
UploadTaskMapper uploadTaskMapper;
|
|
UploadTaskMapper uploadTaskMapper;
|
|
|
|
|
|
|
@@ -104,7 +108,14 @@ public class MinioUtil {
|
|
|
* @param md5List
|
|
* @param md5List
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public List<ResourceUserFile> checkFilesExits(List<UploadFile> md5List) {
|
|
|
|
|
|
|
+ public ResponseEntity<?> checkFilesExits(List<UploadFile> md5List) {
|
|
|
|
|
+ long totalSize = md5List.stream()
|
|
|
|
|
+ .mapToLong(UploadFile::getSize)
|
|
|
|
|
+ .sum();
|
|
|
|
|
+ boolean isCheckSuccess = storageReService.checkStorage(StpLoginUserUtil.getLoginUser().getId(),totalSize);
|
|
|
|
|
+ if (!isCheckSuccess) {
|
|
|
|
|
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("存储空间不足");
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
List<ResourceUserFile> noExitList = new ArrayList<>();
|
|
List<ResourceUserFile> noExitList = new ArrayList<>();
|
|
|
md5List.forEach(item -> {
|
|
md5List.forEach(item -> {
|
|
@@ -144,7 +155,7 @@ public class MinioUtil {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
});
|
|
});
|
|
|
- return noExitList;
|
|
|
|
|
|
|
+ return ResponseEntity.ok(noExitList);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|