修改文件查询接口,添加异常处理

This commit is contained in:
ajaxfan
2021-04-16 14:55:34 +08:00
parent 88fa5eb9d5
commit d6d3aabd7a
4 changed files with 11 additions and 12 deletions

View File

@ -23,6 +23,7 @@ import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.AttachmentEntity;
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.DownloadEntity;
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.model.UploadObject;
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.service.DocumentCenterService;
import com.chinaunicom.ebtp.mall.cloud.attachment.sdk.vo.query.QueryResult;
import cn.hutool.core.util.IdUtil;
import lombok.extern.slf4j.Slf4j;
@ -79,18 +80,20 @@ public class DefaultAttachmentClient implements AttachmentClient {
String json = documentCenterService.fetchDetails(businessIdList);
log.debug("document center return: {}", json);
AttachmentDetail detail = new AttachmentDetail();
Optional<QueryResult> op = modelConvertor.toQueryResult(json);
// 组织数据存储
modelConvertor.toQueryResult(json).ifPresent(result -> {
Optional.ofNullable(result.getData()).ifPresent(data -> {
if (op.isPresent()) {
AttachmentDetail detail = new AttachmentDetail();
Optional.ofNullable(op.get().getData()).ifPresent(data -> {
data.forEach(item -> {
detail.add(new AttachmentEntity().setBid(item.getObjectId()).setId(item.getFileId())
.setFilename(item.getOriginalName()).setKey(item.getFileName()));
});
});
});
return Optional.of(detail);
return Optional.of(detail);
}
return Optional.empty();
}
/**

View File

@ -32,7 +32,7 @@ public class DocumentCenterServiceFallback implements DocumentCenterService {
@Override
public byte[] download(String fileId) {
return null;
return new byte[0];
}
}

View File

@ -6,4 +6,4 @@ server.max-http-header-size=2048576
# document center id
document.center.service.id=core-service-document-center
document.center.ip-address=http://10.238.25.112:8100/doc/
document.center.ip-address=http://10.242.31.158:8806/doc/

View File

@ -5,15 +5,11 @@ import org.springframework.stereotype.Component;
import com.chinaunicom.mall.ebtp.cloud.security.starter.client.UserCenterClient;
import com.chinaunicom.mall.ebtp.cloud.security.starter.entity.SecurityUser;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Component
public class UserCenterClientFallback implements UserCenterClient {
@Override
public SecurityUser getUserInfo() {
log.error("Feign Fallback.");
return new SecurityUser();
}