uploadFirmware 上传固件接口

This commit is contained in:
Guoqs
2024-05-21 15:32:40 +08:00
parent 724d3ca4b7
commit ca543b57de
2 changed files with 46 additions and 1 deletions

View File

@@ -227,6 +227,23 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils {
return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS);
}
/**
* 去除http(s)://开头
* @param link
* @return
*/
public static String removeHttp(String link) {
String result;
if (StringUtils.startsWith(link, Constants.HTTP)) {
result = link.replace(Constants.HTTP, "");
} else if (StringUtils.startsWith(link, Constants.HTTPS)) {
result = link.replace(Constants.HTTPS, "");
} else {
result = link;
}
return result;
}
/**
* 字符串转set
*

View File

@@ -2,6 +2,7 @@ package com.jsowell.pile.service;
import com.google.common.collect.Lists;
import com.jsowell.common.constant.CacheConstants;
import com.jsowell.common.constant.Constants;
import com.jsowell.common.core.redis.RedisCache;
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
import com.jsowell.common.exception.BusinessException;
@@ -223,7 +224,8 @@ public class PileRemoteService {
String ip;
try {
ip = InetAddress.getByName(serverAddress).getHostAddress();
String server = StringUtils.removeHttp(serverAddress);
ip = InetAddress.getByName(server).getHostAddress();
} catch (UnknownHostException e) {
throw new BusinessException("", "无法解析出IP");
}
@@ -238,6 +240,32 @@ public class PileRemoteService {
ykcPushCommandService.pushUpdateFileCommand(command);
}
public static void main(String[] args) {
//获取百度IP地址
try {
System.out.println("www.baidu.com的地址: "+InetAddress.getByName("www.baidu.com").getHostAddress());
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
//获取百度IP地址
try {
System.out.println("jsowell的地址: "+InetAddress.getByName("apitest.jsowellcloud.com").getHostAddress());
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
String serverAddress = "http://apitest.jsowellcloud.com";
String ip;
try {
String server = StringUtils.removeHttp(serverAddress);;
ip = InetAddress.getByName(server).getHostAddress();
} catch (UnknownHostException e) {
throw new BusinessException("", "无法解析出IP");
}
System.out.println("=====" + ip);
}
/**
* 远程账户余额更新
*/