refactor: 优化部分代码
修复 Sonar 扫描问题
This commit is contained in:
parent
bcdcf888fb
commit
d5716d661f
@ -118,8 +118,7 @@ public class StorageServiceImpl extends BaseServiceImpl<StorageMapper, StorageDO
|
|||||||
String bucketName = req.getBucketName();
|
String bucketName = req.getBucketName();
|
||||||
String domain = req.getDomain();
|
String domain = req.getDomain();
|
||||||
StorageTypeEnum type = req.getType();
|
StorageTypeEnum type = req.getType();
|
||||||
switch (type) {
|
if (StorageTypeEnum.LOCAL.equals(type)) {
|
||||||
case LOCAL -> {
|
|
||||||
ValidationUtils.throwIfBlank(bucketName, "存储路径不能为空");
|
ValidationUtils.throwIfBlank(bucketName, "存储路径不能为空");
|
||||||
ValidationUtils.throwIfBlank(domain, "自定义域名不能为空");
|
ValidationUtils.throwIfBlank(domain, "自定义域名不能为空");
|
||||||
ValidationUtils.throwIf(!URLUtils.isHttpUrl(domain), "自定义域名格式错误");
|
ValidationUtils.throwIf(!URLUtils.isHttpUrl(domain), "自定义域名格式错误");
|
||||||
@ -131,8 +130,7 @@ public class StorageServiceImpl extends BaseServiceImpl<StorageMapper, StorageDO
|
|||||||
fileStorageList.addAll(FileStorageServiceBuilder.buildLocalPlusFileStorage(Collections
|
fileStorageList.addAll(FileStorageServiceBuilder.buildLocalPlusFileStorage(Collections
|
||||||
.singletonList(config)));
|
.singletonList(config)));
|
||||||
SpringWebUtils.registerResourceHandler(MapUtil.of(URLUtil.url(req.getDomain()).getPath(), bucketName));
|
SpringWebUtils.registerResourceHandler(MapUtil.of(URLUtil.url(req.getDomain()).getPath(), bucketName));
|
||||||
}
|
} else if (StorageTypeEnum.S3.equals(type)) {
|
||||||
case S3 -> {
|
|
||||||
String accessKey = req.getAccessKey();
|
String accessKey = req.getAccessKey();
|
||||||
String secretKey = req.getSecretKey();
|
String secretKey = req.getSecretKey();
|
||||||
String endpoint = req.getEndpoint();
|
String endpoint = req.getEndpoint();
|
||||||
@ -151,7 +149,6 @@ public class StorageServiceImpl extends BaseServiceImpl<StorageMapper, StorageDO
|
|||||||
.singletonList(config), null));
|
.singletonList(config), null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unload(StorageReq req) {
|
public void unload(StorageReq req) {
|
||||||
|
Loading…
Reference in New Issue
Block a user