|
|
@ -1,11 +1,16 @@ |
|
|
package cn.chjyj.szwh; |
|
|
package cn.chjyj.szwh; |
|
|
|
|
|
|
|
|
|
|
|
import cn.chjyj.szwh.utils.RequestUtils; |
|
|
|
|
|
import cn.chjyj.szwh.utils.SignUtils; |
|
|
import cn.chjyj.szwh.utils.SzwhApiUtils; |
|
|
import cn.chjyj.szwh.utils.SzwhApiUtils; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import org.junit.Test; |
|
|
import org.junit.Test; |
|
|
import org.springframework.boot.test.context.SpringBootTest; |
|
|
import org.springframework.boot.test.context.SpringBootTest; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
|
@SpringBootTest |
|
|
@SpringBootTest |
|
|
public class ApiTest { |
|
|
public class ApiTest { |
|
|
@Test |
|
|
@Test |
|
|
@ -46,4 +51,28 @@ public class ApiTest { |
|
|
JSONObject json = SzwhApiUtils.synchInfo(); |
|
|
JSONObject json = SzwhApiUtils.synchInfo(); |
|
|
System.out.println(json); |
|
|
System.out.println(json); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
public void fjtest(){ |
|
|
|
|
|
String url="http://localhost:90/as.json"; |
|
|
|
|
|
//创建签名
|
|
|
|
|
|
String sign = SignUtils.createSign("entrust"); |
|
|
|
|
|
// 请求头
|
|
|
|
|
|
Map<String, Object> hmap = new HashMap(); |
|
|
|
|
|
hmap.put("entrust_token", sign); |
|
|
|
|
|
JSONObject jsonObject = RequestUtils.GetData(url, hmap); |
|
|
|
|
|
// 抽取data
|
|
|
|
|
|
// String data = jsonObject.getString("data");
|
|
|
|
|
|
JSONArray jsonArray = jsonObject.getJSONArray("data"); |
|
|
|
|
|
for(int i=0;i<jsonArray.size();i++){ |
|
|
|
|
|
JSONObject dataJson = (JSONObject) jsonArray.get(i); |
|
|
|
|
|
// System.out.println(dataJson.getString("timeStamp"));
|
|
|
|
|
|
String nsdstr = dataJson.getString("sourceData"); |
|
|
|
|
|
JSONObject nsdjson = JSONObject.parseObject(nsdstr); |
|
|
|
|
|
String cover = nsdjson.getString("cover"); |
|
|
|
|
|
//System.out.println(cover);
|
|
|
|
|
|
String goodsId= nsdjson.getString("identifier"); |
|
|
|
|
|
System.out.println(goodsId); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|