12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- package com.tzld.piaoquan.api.component;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.tzld.piaoquan.common.component.HttpPoolClient;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Component;
- import java.util.HashMap;
- import java.util.List;
- import java.util.Map;
- import java.util.UUID;
- @Slf4j
- @Component
- public class TouLiuHttpClient {
- @Autowired
- private HttpPoolClient httpPoolClient;
- public String sendAdFlowAddRequest(String baseUrl,
- String videoId,
- String putScene,
- String channel,
- String remark,
- String putTypeOne,
- String putTypeTwo,
- String putTypeThree,
- String putCarrierId) {
- String url = baseUrl + "/ad/put/flow/add/tencent";
- UUID uuid = UUID.randomUUID();
- String jsonBody = "{" +
- "\"videoId\":\"" + videoId + "\"," +
- "\"putScene\":\"" + putScene + "\"," +
- "\"channel\":\"" + channel + "\"," +
- "\"remark\":\"" + remark + "\"," +
- "\"putTypeOne\":\"" + putTypeOne + "\"," +
- "\"putTypeTwo\":\"" + putTypeTwo + "\"," +
- "\"putTypeThree\":\"" + putTypeThree + "\"," +
- "\"putCarrierId\":\"" + putCarrierId + "\"," +
- "\"path\":\"" + "pages/category" + "\"," +
- "\"requestParam\":{" +
- "\"jumpPage\":\"" + "pages/user-videos?id=" + videoId + "&fromGzh=1&rootShareId=" + uuid + "&shareId=" + uuid + "&rootSourceId=[rootSourceId]" + "\"" +
- "}" +
- "}";
- try {
- return httpPoolClient.post(url, jsonBody);
- } catch (Exception e) {
- log.error("sendAdFlowAddRequest error", e);
- }
- return "";
- }
- public Map<Long, String> getVideoDetailRequest(List<Long> videoIds) {
- Map<Long, String> map = new HashMap<>();
- try {
- String url = "https://longvideoapi.piaoquantv.com/longvideoapi/openapi/video/batchSelectVideoInfo";
- JSONObject params = new JSONObject();
- params.put("videoIdList", videoIds);
- String post = httpPoolClient.post(url, JSONObject.toJSONString(params));
- JSONObject res = JSONObject.parseObject(post);
- JSONArray data = res.getJSONArray("data");
- for (int i = 0; i < data.size(); i++) {
- JSONObject jsonObject = data.getJSONObject(i);
- Long videoId = jsonObject.getLong("id");
- String shareImgPath = jsonObject.getString("shareImgPath");
- map.put(videoId, shareImgPath);
- }
- } catch (Exception e) {
- log.error("getVideoDetailRequest error", e);
- }
- return map;
- }
- }
|