修改 飞鹅 新 url 地址和接口名
This commit is contained in:
parent
491ed806d8
commit
91a8b4ea5f
@ -40,7 +40,7 @@ import java.util.List;
|
||||
public class FeieUtil {
|
||||
private static final Logger logger = LoggerFactory.getLogger(FeieUtil.class);
|
||||
@Value("${feieyun.url}")
|
||||
public String URL = "";//不需要修改
|
||||
public String FeieyunURL = "";//不需要修改
|
||||
@Value("${feieyun.user}")
|
||||
public String USER = "";//*必填*:账号名
|
||||
@Value("${feieyun.ukey}")
|
||||
@ -96,7 +96,7 @@ public class FeieUtil {
|
||||
public Pair<Boolean, String> addPrinter(String printerInfo) {
|
||||
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
|
||||
nvps.add(new BasicNameValuePair("printerContent", printerInfo));
|
||||
JSONObject reps = sendHttpPost2("printerAddlist", nvps);
|
||||
JSONObject reps = sendHttpPost2(FeieyunURL + "printerAddlist", "Open_printerAddlist", nvps);
|
||||
if (reps == null) {
|
||||
return Pair.of(false, "打印机未返回数据,操作失败");
|
||||
}
|
||||
@ -124,7 +124,7 @@ public class FeieUtil {
|
||||
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
|
||||
nvps.add(new BasicNameValuePair("snlist", snList));
|
||||
|
||||
FeiePrinterApiRes reps = sendHttpPost("printerDelList", nvps);
|
||||
FeiePrinterApiRes reps = sendHttpPost(FeieyunURL + "printerDelList", "Open_printerDelList", nvps);
|
||||
logger.info("飞鹅删除打印机返回数据:{}", reps);
|
||||
if (reps != null && reps.getRet().equals(0)) {
|
||||
return Pair.of(true, "打印机删除成功!");
|
||||
@ -150,7 +150,7 @@ public class FeieUtil {
|
||||
nvps.add(new BasicNameValuePair("sn", sn));
|
||||
nvps.add(new BasicNameValuePair("content", printContent));
|
||||
|
||||
FeiePrinterApiRes<String> reps = sendHttpPost("printMsg", nvps);
|
||||
FeiePrinterApiRes<String> reps = sendHttpPost(FeieyunURL + "printMsg", "Open_printMsg", nvps);
|
||||
if (reps != null && reps.getRet().equals(0)) {
|
||||
// 返回打印编号,如:816501678_20160919184316_1419533539
|
||||
return reps.getData();
|
||||
@ -201,7 +201,7 @@ public class FeieUtil {
|
||||
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
|
||||
nvps.add(new BasicNameValuePair("sn", sn));
|
||||
|
||||
FeiePrinterApiRes<String> reps = sendHttpPost("delPrinterSqs", nvps);
|
||||
FeiePrinterApiRes<String> reps = sendHttpPost(FeieyunURL + "delPrinterSqs", "Open_delPrinterSqs", nvps);
|
||||
if (reps != null && reps.getRet().equals(0)) {
|
||||
return true;
|
||||
}
|
||||
@ -226,11 +226,12 @@ public class FeieUtil {
|
||||
/**
|
||||
* 发送 http post 请求
|
||||
*
|
||||
* @param apiName
|
||||
* @param apiUrl 如:https://api.feieyun.cn/Api/Open/printMsg
|
||||
* @param apiName 接口名称,如:Open_printMsg
|
||||
* @param paramPair
|
||||
* @return
|
||||
*/
|
||||
private FeiePrinterApiRes sendHttpPost(String apiName, List<NameValuePair> paramPair) {
|
||||
private FeiePrinterApiRes sendHttpPost(String apiUrl, String apiName, List<NameValuePair> paramPair) {
|
||||
if (StrUtil.isBlank(apiName) || CollectionUtil.isEmpty(paramPair)) {
|
||||
return new FeiePrinterApiRes().fail("缺少必要参数!");
|
||||
}
|
||||
@ -245,7 +246,7 @@ public class FeieUtil {
|
||||
.setDefaultRequestConfig(requestConfig)
|
||||
.build();
|
||||
|
||||
HttpPost post = new HttpPost(URL);
|
||||
HttpPost post = new HttpPost(apiUrl);
|
||||
|
||||
paramPair.add(new BasicNameValuePair("user", USER));
|
||||
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
||||
@ -262,7 +263,7 @@ public class FeieUtil {
|
||||
HttpEntity httpentity = response.getEntity();
|
||||
if (httpentity != null) {
|
||||
String result = EntityUtils.toString(httpentity);
|
||||
logger.debug("飞鹅云返回到信息:{}", result);
|
||||
logger.info("飞鹅云返回到信息:{}", result);
|
||||
return JsonUtil.json2object(result, FeiePrinterApiRes.class);
|
||||
}
|
||||
}
|
||||
@ -275,7 +276,7 @@ public class FeieUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
private JSONObject sendHttpPost2(String apiName, List<NameValuePair> paramPair) {
|
||||
private JSONObject sendHttpPost2(String apiUrl, String apiName, List<NameValuePair> paramPair) {
|
||||
if (StrUtil.isBlank(apiName) || CollectionUtil.isEmpty(paramPair)) {
|
||||
logger.info("缺少必要参数!");
|
||||
return null;
|
||||
@ -291,7 +292,7 @@ public class FeieUtil {
|
||||
.setDefaultRequestConfig(requestConfig)
|
||||
.build();
|
||||
|
||||
HttpPost post = new HttpPost(URL);
|
||||
HttpPost post = new HttpPost(apiUrl);
|
||||
|
||||
paramPair.add(new BasicNameValuePair("user", USER));
|
||||
String STIME = String.valueOf(System.currentTimeMillis() / 1000);
|
||||
@ -308,7 +309,7 @@ public class FeieUtil {
|
||||
HttpEntity httpentity = response.getEntity();
|
||||
if (httpentity != null) {
|
||||
String result = EntityUtils.toString(httpentity);
|
||||
logger.debug("飞鹅云返回到信息:{}", result);
|
||||
logger.info("飞鹅云返回到信息:{}", result);
|
||||
return JSONUtil.parseObj(result);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user