feat(后端): 联调修改4
parent
f107d97cf8
commit
2e90f5684f
|
@ -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())) {
|
||||
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());
|
||||
|
|
|
@ -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<ImageMapper, Image>
|
|||
return Result.successResult();
|
||||
} else {
|
||||
PageResult<ImageRes> convert = PageResult.convertIPage(imageIPage, ImageRes.class);
|
||||
List<ImageRes> data = convert.getData();
|
||||
List<ImageRes> 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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue