package com.zy.asrs.third;
|
|
import com.alibaba.fastjson.JSON;
|
import com.zy.common.utils.HttpHandler;
|
|
import java.io.IOException;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
public class TokenUtils {
|
private static String clientId = "xincai";
|
|
private static String clientSecret = "123456";
|
|
private static String erpId = "1130021";
|
|
private static String tokenUrl = "/getMsg/v2/createToken";
|
|
public static Map<String, Object> getToken(String ip) {
|
Map<String, Object> data = new HashMap<>();
|
Map<String, String> tokenData = new HashMap<>();
|
tokenData.put("clientId", clientId);
|
tokenData.put("clientSecret", clientSecret);
|
tokenData.put("erpId", erpId);
|
String response = null;
|
try {
|
response = new HttpHandler.Builder()
|
.setUri(ip)
|
.setPath(tokenUrl)
|
.setJson(JSON.toJSONString(tokenData))
|
.build()
|
.doPost();
|
} catch (IOException e) {
|
throw new RuntimeException(e);
|
}
|
MesResponse jsonObject = JSON.parseObject(response, MesResponse.class);
|
if (jsonObject.getCode().equals(200)) {
|
data.put("token", JSON.parseObject(jsonObject.getData()).getString("token"));
|
}
|
return null;
|
}
|
|
|
}
|