增加sonar测试并修复sonar测试的问题
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package com.central.file.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
package com.central.file.config;
|
||||
|
||||
import java.util.EnumMap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -19,7 +20,7 @@ import com.central.file.model.FileType;
|
||||
@Configuration
|
||||
public class OssServiceFactory {
|
||||
|
||||
private Map<FileType, IFileService> map = new HashMap<>();
|
||||
private Map<FileType, IFileService> map = new EnumMap<>(FileType.class);
|
||||
@Autowired
|
||||
private IFileService aliyunOssServiceImpl;
|
||||
|
||||
|
||||
-1
@@ -5,7 +5,6 @@ import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.central.common.model.SysUser;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
|
||||
-1
@@ -6,7 +6,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.aliyun.oss.OSSClient;
|
||||
import com.central.file.mapper.FileMapper;
|
||||
import com.central.file.model.FileInfo;
|
||||
import com.central.file.model.FileType;
|
||||
|
||||
|
||||
-9
@@ -40,15 +40,6 @@ public class QiniuOssServiceImplI extends AbstractIFileService implements Initia
|
||||
return FileType.QINIU;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传凭证
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private String getUploadToken() {
|
||||
return this.auth.uploadToken(bucket, null, 3600, putPolicy);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uploadFile(MultipartFile file, FileInfo fileInfo) throws Exception {
|
||||
// 调用put方法上传
|
||||
|
||||
@@ -6,6 +6,7 @@ import java.io.InputStream;
|
||||
import java.util.Date;
|
||||
|
||||
import com.central.file.model.FileInfo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@@ -13,7 +14,11 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
* @author zlt
|
||||
* 文件工具类
|
||||
*/
|
||||
@Slf4j
|
||||
public class FileUtil {
|
||||
private FileUtil() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static FileInfo getFileInfo(MultipartFile file) throws Exception {
|
||||
String md5 = fileMd5(file.getInputStream());
|
||||
@@ -37,7 +42,7 @@ public class FileUtil {
|
||||
try {
|
||||
return DigestUtils.md5Hex(inputStream);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
log.error("fileMd5-error", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -54,7 +59,7 @@ public class FileUtil {
|
||||
file.transferTo(targetFile);
|
||||
return path;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("saveFile-error", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user