| | |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | switch (api) { |
| | | case 1: |
| | | list.addAll(aliyun_1(company)); |
| | | List<Map<String, Object>> maps = aliyun_1(company); |
| | | if (Cools.isEmpty(maps)){ |
| | | break; |
| | | } |
| | | list.addAll(maps); |
| | | break; |
| | | } |
| | | return list; |
| | |
| | | * 阿里云市场API |
| | | */ |
| | | private static List<Map<String, Object>> aliyun_1(String company) { |
| | | if (Cools.isEmpty(company) || company.length()<=3){ |
| | | return null; |
| | | } |
| | | ArrayList<Map<String, Object>> list = new ArrayList<>(); |
| | | try { |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (Cools.isEmpty(jsonObject)){ |
| | | throw new CoolException("无返回结果"); |
| | | } |
| | | if (Integer.parseInt(jsonObject.get("error_code").toString()) == 0) { |
| | | JSONObject result = JSON.parseObject(jsonObject.get("result").toString()); |
| | | List<JSONObject> data = JSON.parseArray(result.get("data").toString(), JSONObject.class); |
| | |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | if (e.getMessage().equals("无返回结果")){ |
| | | throw new CoolException("无返回结果"); |
| | | } |
| | | e.printStackTrace(); |
| | | } |
| | | return list; |