Merge branch 'feature/joint_log' into 'pre'
获取fileKey接口优化调整 See merge request infra/oss!59
This commit is contained in:
commit
a122a042a3
@ -49,12 +49,6 @@ public class FileServiceImpl implements FileService {
|
|||||||
|
|
||||||
private static final String FILE_UPLOAD_CODE = "OSS_FILE_UPLOAD";
|
private static final String FILE_UPLOAD_CODE = "OSS_FILE_UPLOAD";
|
||||||
private static final String FILE_UPLOAD_NAME = "文件上传";
|
private static final String FILE_UPLOAD_NAME = "文件上传";
|
||||||
private static final String APPCODE_FACE = "face";
|
|
||||||
private static final String SCENE_FACE = "face";
|
|
||||||
private static final String APPCODE_IDCARD = "idcard";
|
|
||||||
private static final String SCENE_IDCARD = "idcard";
|
|
||||||
private static final String APPCODE_BANKCARD = "bankcard";
|
|
||||||
private static final String SCENE_BANKCARD = "bankcard";
|
|
||||||
|
|
||||||
private static final String IS_URL = "https://";
|
private static final String IS_URL = "https://";
|
||||||
|
|
||||||
@ -102,7 +96,7 @@ public class FileServiceImpl implements FileService {
|
|||||||
}
|
}
|
||||||
//String tgtFileKey = Utility.generateFileKey(file.getDirectory(), file.getFileUuid(), file.getFileFormat());
|
//String tgtFileKey = Utility.generateFileKey(file.getDirectory(), file.getFileUuid(), file.getFileFormat());
|
||||||
//兼容app端oss历史上传文件的url处理
|
//兼容app端oss历史上传文件的url处理
|
||||||
String tgtFileKey = file.getFileUrl().substring(file.getFileUrl().indexOf(".com/") + 5);
|
String tgtFileKey = file.getFileUrl().substring(file.getFileUrl().indexOf(HTTP_COM) + 5);
|
||||||
log.debug("delete tgtFileKey = {}", tgtFileKey);
|
log.debug("delete tgtFileKey = {}", tgtFileKey);
|
||||||
String bucketName = file.getBucketName();
|
String bucketName = file.getBucketName();
|
||||||
if (file.getFileUrl().contains(APP_PRO_BUCKET_NAME)) {
|
if (file.getFileUrl().contains(APP_PRO_BUCKET_NAME)) {
|
||||||
@ -171,7 +165,7 @@ public class FileServiceImpl implements FileService {
|
|||||||
}
|
}
|
||||||
//String tgtFileKey = Utility.generateFileKey(file.getDirectory(), file.getFileUuid(), file.getFileFormat());
|
//String tgtFileKey = Utility.generateFileKey(file.getDirectory(), file.getFileUuid(), file.getFileFormat());
|
||||||
//兼容app端oss历史上传文件的url处理
|
//兼容app端oss历史上传文件的url处理
|
||||||
String tgtFileKey = file.getFileUrl().substring(file.getFileUrl().indexOf(".com/") + 5);
|
String tgtFileKey = file.getFileUrl().substring(file.getFileUrl().indexOf(HTTP_COM) + 5);
|
||||||
log.info("file download tgtFileKey = {}", tgtFileKey);
|
log.info("file download tgtFileKey = {}", tgtFileKey);
|
||||||
String bucketName = file.getBucketName();
|
String bucketName = file.getBucketName();
|
||||||
if (file.getFileUrl().contains(APP_PRO_BUCKET_NAME)) {
|
if (file.getFileUrl().contains(APP_PRO_BUCKET_NAME)) {
|
||||||
@ -356,6 +350,9 @@ public class FileServiceImpl implements FileService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void asyncSaveFile(List<FindFileKeyResponse> resList) {
|
private void asyncSaveFile(List<FindFileKeyResponse> resList) {
|
||||||
|
if (CollectionUtil.isEmpty(resList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
List<CompletableFuture<Void>> completableFutures = new ArrayList<>(resList.size() / 10 + 1);
|
List<CompletableFuture<Void>> completableFutures = new ArrayList<>(resList.size() / 10 + 1);
|
||||||
Lists.partition(resList, 10).forEach(findFileKeyResponses ->
|
Lists.partition(resList, 10).forEach(findFileKeyResponses ->
|
||||||
completableFutures.add(CompletableFuture.runAsync(() ->
|
completableFutures.add(CompletableFuture.runAsync(() ->
|
||||||
@ -366,19 +363,10 @@ public class FileServiceImpl implements FileService {
|
|||||||
|
|
||||||
private File saveFile(FindFileKeyResponse response) {
|
private File saveFile(FindFileKeyResponse response) {
|
||||||
String url = response.getUrl();
|
String url = response.getUrl();
|
||||||
|
String tgtFileKey = url.substring(url.indexOf(HTTP_COM) + 5);
|
||||||
String appCode = "", bizScene = "";
|
String appCode = tgtFileKey.substring(0, tgtFileKey.indexOf("/"));
|
||||||
if (url.contains(APPCODE_FACE)) {
|
String bizScene = getBizScene(appCode);
|
||||||
appCode = APPCODE_FACE;
|
if (StringUtils.isEmpty(bizScene)) {
|
||||||
bizScene = SCENE_FACE;
|
|
||||||
} else if(url.contains(APPCODE_IDCARD)) {
|
|
||||||
appCode = APPCODE_IDCARD;
|
|
||||||
bizScene = SCENE_IDCARD;
|
|
||||||
} else if(url.contains(APPCODE_BANKCARD)) {
|
|
||||||
appCode = APPCODE_BANKCARD;
|
|
||||||
bizScene = SCENE_BANKCARD;
|
|
||||||
}
|
|
||||||
if (StringUtils.isEmpty(appCode) || StringUtils.isEmpty(bizScene)) {
|
|
||||||
throw new BizException(CodeEnum.APP_CODE_NOT_FOUND);
|
throw new BizException(CodeEnum.APP_CODE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
// 通过appcode获取文件渠道桶信息
|
// 通过appcode获取文件渠道桶信息
|
||||||
@ -414,6 +402,24 @@ public class FileServiceImpl implements FileService {
|
|||||||
return ossFile;
|
return ossFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getBizScene(String appCode) {
|
||||||
|
String bizScene = "";
|
||||||
|
switch (appCode) {
|
||||||
|
case "face":
|
||||||
|
bizScene = "face";
|
||||||
|
break;
|
||||||
|
case "idcard":
|
||||||
|
bizScene = "idcard";
|
||||||
|
break;
|
||||||
|
case "bankcard":
|
||||||
|
bizScene = "bankcard";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return bizScene;
|
||||||
|
}
|
||||||
|
|
||||||
private List<FindFileKeyResponse> setFileKeyResByUrl(List<String> urlList) {
|
private List<FindFileKeyResponse> setFileKeyResByUrl(List<String> urlList) {
|
||||||
List<FindFileKeyResponse> resList = new ArrayList<>();
|
List<FindFileKeyResponse> resList = new ArrayList<>();
|
||||||
urlList.stream().forEach(url -> {
|
urlList.stream().forEach(url -> {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user