From 2e90f5684f4c59dea76cee765a08598c053987ca Mon Sep 17 00:00:00 2001 From: rdpnr_puzhi <13060209078@163.com> Date: Wed, 13 Aug 2025 09:44:09 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=90=8E=E7=AB=AF):=20=E8=81=94=E8=B0=83?= =?UTF-8?q?=E4=BF=AE=E6=94=B94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../project/service/impl/ClientServiceImpl.java | 11 ++++++++++- .../project/service/impl/ImageServiceImpl.java | 12 ++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/nex-be/src/main/java/com/unisinsight/project/service/impl/ClientServiceImpl.java b/nex-be/src/main/java/com/unisinsight/project/service/impl/ClientServiceImpl.java index 0f967ee..db5c29e 100644 --- a/nex-be/src/main/java/com/unisinsight/project/service/impl/ClientServiceImpl.java +++ b/nex-be/src/main/java/com/unisinsight/project/service/impl/ClientServiceImpl.java @@ -14,6 +14,7 @@ import com.unisinsight.project.mapper.ImageMapper; import com.unisinsight.project.service.ClientService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -37,6 +38,9 @@ public class ClientServiceImpl implements ClientService { @Resource private DeviceImageMappingMapper deviceImageMappingMapper; + // 请求bt配置 + @Value("${file.upload.bt-url}") + private String btUrl; @Override public Result getImageList(String deviceId, String token) { @@ -60,7 +64,12 @@ public class ClientServiceImpl implements ClientService { hashMap.put("name", e.getImageName()); } if (StringUtils.isNotBlank(e.getBtPath())) { - hashMap.put("torrent", e.getBtPath()); + if (e.getBtPath().contains("http://") || e.getBtPath().contains("https://")) { + hashMap.put("torrent", e.getBtPath()); + } else { + String fileName = e.getBtPath().substring(Math.max(e.getBtPath().lastIndexOf("\\"), e.getBtPath().lastIndexOf("/")) + 1); + hashMap.put("torrent", btUrl + "/api/vdi/file/down/" + fileName); + } } return hashMap; }).collect(Collectors.toList()); diff --git a/nex-be/src/main/java/com/unisinsight/project/service/impl/ImageServiceImpl.java b/nex-be/src/main/java/com/unisinsight/project/service/impl/ImageServiceImpl.java index 2f255f0..a3b746d 100644 --- a/nex-be/src/main/java/com/unisinsight/project/service/impl/ImageServiceImpl.java +++ b/nex-be/src/main/java/com/unisinsight/project/service/impl/ImageServiceImpl.java @@ -30,6 +30,8 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.List; +import java.util.stream.Collectors; /** * @author rdpnr_puzhi @@ -71,6 +73,16 @@ public class ImageServiceImpl extends ServiceImpl return Result.successResult(); } else { PageResult convert = PageResult.convertIPage(imageIPage, ImageRes.class); + List data = convert.getData(); + List collect = data.stream().distinct().peek(e -> { + if (StringUtils.isNotBlank(e.getBtPath())) { + if (!e.getBtPath().contains("http://") || !e.getBtPath().contains("https://")) { + String fileName = e.getBtPath().substring(Math.max(e.getBtPath().lastIndexOf("\\"), e.getBtPath().lastIndexOf("/")) + 1); + e.setBtPath(btUrl + "/api/vdi/file/down/" + fileName); + } + } + }).collect(Collectors.toList()); + convert.setData(collect); return Result.successResult(convert); } }