feat: (REQ-3846) 获取图片链接优化

This commit is contained in:
xudawei 2025-04-09 14:38:57 +08:00
parent 46bcebb08e
commit 4d4f49d034
2 changed files with 40 additions and 1 deletions

View File

@ -11,15 +11,23 @@ import cn.axzo.nanopart.doc.api.bizattri.response.SearchNodeBizAttributesRespons
import cn.axzo.nanopart.doc.api.bizattri.response.UpdateNodeBizAttributesResponse;
import cn.axzo.nanopart.doc.api.bizattri.response.UpsertNodeBizAttributesResponse;
import cn.axzo.nanopart.doc.entity.NodeBizAttributes;
import cn.axzo.nanopart.doc.integration.DocOssGateway;
import cn.axzo.oss.http.model.ApiSignUrlDownloadRequest;
import cn.axzo.oss.http.model.ApiSignUrlDownloadResponse;
import cn.azxo.framework.common.model.CommonResponse;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.google.common.collect.Lists;
import com.google.common.collect.Sets;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.web.bind.annotation.RestController;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
@ -33,6 +41,8 @@ public class NodeBizAttributesApiController implements NodeBizAttributesApi {
private final NodeBizAttributesManager nodeBizAttributesManager;
private final DocOssGateway docOssGateway;
/**
* 创建结点配置信息
* @return 节点code
@ -77,8 +87,34 @@ public class NodeBizAttributesApiController implements NodeBizAttributesApi {
if (CollectionUtil.isEmpty(attributes)) {
return Collections.emptyList();
}
return attributes.stream().map(item -> SearchNodeBizAttributesResponse.builder()
List<SearchNodeBizAttributesResponse> responseList = attributes.stream().map(item -> SearchNodeBizAttributesResponse.builder()
.nodeCode(item.getNodeCode())
.drawMaterials(BeanUtil.copyToList(item.getAttributes(), CreateNodeBizAttributesRequest.DrawMaterial.class)).build()).collect(Collectors.toList());
//dwgUrl/picUrl重新赋值
this.rechangeDwgPicUrl(responseList);
return responseList;
}
/**
* dwgUrl/picUrl重新赋值
*/
private void rechangeDwgPicUrl(List<SearchNodeBizAttributesResponse> responseList) {
List<CreateNodeBizAttributesRequest.DrawMaterial> drawMaterials = responseList.stream().flatMap(item -> item.getDrawMaterials().stream()).collect(Collectors.toList());
List<CreateNodeBizAttributesRequest.Content> contentList = drawMaterials.stream().flatMap(item -> item.getContents().stream()).collect(Collectors.toList());
Set<String> dwgUrlList = contentList.stream().map(CreateNodeBizAttributesRequest.Content::getDwgUrl).collect(Collectors.toSet());
Set<String> picUrlList = contentList.stream().map(CreateNodeBizAttributesRequest.Content::getPicUrl).collect(Collectors.toSet());
Set<String> fileKeys = Sets.newHashSet();
fileKeys.addAll(dwgUrlList);
fileKeys.addAll(picUrlList);
List<ApiSignUrlDownloadResponse> apiSignUrlDownloadResponses = docOssGateway.signUrlFetchDownload(ApiSignUrlDownloadRequest.builder().fileKeys(Lists.newArrayList(fileKeys)).build());
Map<String, String> collect = apiSignUrlDownloadResponses.stream().collect(Collectors.toMap(item -> item.getFileKey(), value -> value.getSignUrl(), (x, y) -> x));
contentList.forEach(item -> {
item.setDwgUrl(StringUtils.isNotEmpty(collect.get(item.getDwgUrl())) ? collect.get(item.getDwgUrl()) : item.getDwgUrl());
item.setPicUrl(StringUtils.isNotEmpty(collect.get(item.getPicUrl())) ? collect.get(item.getPicUrl()) : item.getPicUrl());
});
}
}

View File

@ -73,6 +73,8 @@ public class FeignConfig implements RequestInterceptor, EnvironmentAware {
private String thorUrl;
@Value("${orgGateway:http://dev-app.axzo.cn/org-gateway}")
private String orgGatewayUrl;
@Value("${ossEnvUrl:http://dev-app.axzo.cn/oss}")
private String ossEnvUrl;
private static String POD_NAMESPACE;
@ -114,6 +116,7 @@ public class FeignConfig implements RequestInterceptor, EnvironmentAware {
url = url.replace("http://attendance:8080", attendanceApi);
url = url.replace("http://thor:8080", thorUrl);
url = url.replace("http://org-gateway:8080", orgGatewayUrl);
url = url.replace("http://oss:9123", ossEnvUrl);
String profile = environment.getProperty("spring.profiles.active");
if(Objects.equals(profile, "test") && url.contains("dev-app.axzo.cn")) {
url = url.replace("dev-app", "test-api");