|
@@ -10,6 +10,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.context.annotation.Primary;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -23,6 +24,15 @@ import java.util.*;
|
|
|
@Service
|
|
|
@Primary
|
|
|
public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserDataService {
|
|
|
+ @Value("${bytedance.appId}")
|
|
|
+ private String bytedanceAppId;
|
|
|
+ @Value("${bytedance.secret}")
|
|
|
+ private String bytedanceSecret;
|
|
|
+ @Value("${bytedance.url.api-prefix}")
|
|
|
+ private String bytedanceApiUrl;
|
|
|
+ @Value("${bytedance.url.ad-get}")
|
|
|
+ private String bytedanceAdGetUrl;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ICtopOauthTokenService tokenService;
|
|
|
@Autowired
|
|
@@ -85,14 +95,11 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
@Override
|
|
|
public Map<String, Object> getAdvertiserInfo(String accountId, String token) {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
- // CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
|
|
|
- //2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_advertiser_info");
|
|
|
+ String url = bytedanceApiUrl + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_advertiser_info");
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
headers.put("Access-Token", token);
|
|
|
TreeMap<String, Object> params = new TreeMap<>();
|
|
|
- //TODO jsonArray
|
|
|
params.put("advertiser_ids", "[" + accountId + "]");
|
|
|
String result = HttpUtils.httpGetRequest(url, headers, params);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
@@ -125,18 +132,13 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
|
|
|
@Override
|
|
|
public JSONArray advertiserList(String token) {
|
|
|
- Map<String, Object> resultMap = new HashMap<>();
|
|
|
- // CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
|
|
|
- //2: 根据token以及用户id获取用户信息数据
|
|
|
String url = "https://ad.oceanengine.com/open_api/oauth2/advertiser/get/";
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
TreeMap<String, Object> params = new TreeMap<>();
|
|
|
params.put("access_token", token);
|
|
|
- String appId = PropertiesUtils.getValue("bytedance_config", "bytedance_appid");
|
|
|
- String secret = PropertiesUtils.getValue("bytedance_config", "bytedance_secret");
|
|
|
- params.put("secret", secret);
|
|
|
- params.put("app_id", appId);
|
|
|
+ params.put("secret", bytedanceSecret);
|
|
|
+ params.put("app_id", bytedanceAppId);
|
|
|
String result = HttpUtils.httpGetRequest(url, headers, params);
|
|
|
JSONObject jsonObject = JSONObject.parseObject(result);
|
|
|
log.info("返回信息:{}", jsonObject);
|
|
@@ -147,12 +149,9 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
JSONArray listArr = dataJson.getJSONArray("list");
|
|
|
if (!Check.isNull(listArr)) {
|
|
|
return listArr;
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
return new JSONArray();
|
|
|
}
|
|
|
|
|
@@ -161,7 +160,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
JSONArray getIds = new JSONArray();
|
|
|
getIds.add(id);
|
|
|
// 请求地址
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_get");
|
|
|
+ String url = bytedanceApiUrl + bytedanceAdGetUrl;
|
|
|
// 请求参数
|
|
|
Map<String, Object> filtering = new HashMap<>();
|
|
|
filtering.put("ids", getIds);
|
|
@@ -203,7 +202,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
}
|
|
|
|
|
|
// 请求地址
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_get");
|
|
|
+ String url = bytedanceApiUrl + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_get");
|
|
|
// 请求参数
|
|
|
Map<String, Object> filtering = new HashMap<>();
|
|
|
if (null != getIds && getIds.size() > 0) {
|
|
@@ -257,7 +256,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_get");
|
|
|
+ String url = bytedanceApiUrl + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_get");
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
@@ -291,7 +290,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_creative_material_get");
|
|
|
+ String url = bytedanceApiUrl + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_creative_material_get");
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
@@ -351,13 +350,11 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
|
|
|
|
|
|
public JSONObject getCreative(CtopOauthToken token, String date, int pageNumber) {
|
|
|
- final Long advertiser_id = token.getAccountId(); //操作的广告主id
|
|
|
// 请求地址
|
|
|
String url = "https://ad.oceanengine.com/open_api/2/creative/get/";
|
|
|
-
|
|
|
// 请求参数
|
|
|
JSONObject param = new JSONObject();
|
|
|
- param.put("advertiser_id", advertiser_id);
|
|
|
+ param.put("advertiser_id", token.getAccountId());
|
|
|
param.put("page", pageNumber);
|
|
|
param.put("page_size", 100);
|
|
|
if (null != date && !"".equals(date.trim())) {
|
|
@@ -379,7 +376,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
}
|
|
|
}
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_status");
|
|
|
+ String url = bytedanceApiUrl + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_status");
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
@@ -431,7 +428,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
}
|
|
|
}
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_bid");
|
|
|
+ String url = bytedanceApiUrl + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_bid");
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
@@ -482,7 +479,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
}
|
|
|
}
|
|
|
//2: 根据token以及用户id获取用户信息数据
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_budget");
|
|
|
+ String url = bytedanceApiUrl + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_update_budget");
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
@@ -533,7 +530,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
ResultMapUtils.setResultMap(resultMap, StatusCode.COMMON_PARAM_ERROR);
|
|
|
return resultMap;
|
|
|
}
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_dmp_custom_audience_select");
|
|
|
+ String url = bytedanceApiUrl + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_dmp_custom_audience_select");
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
headers.put("Access-Token", token.getAccessToken());
|
|
@@ -573,7 +570,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
public Map<String, Object> getAdvertiserCampaignList(String accountId) {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
CtopOauthToken cTopOauthToken = tokenService.getOauthTokenByAccountId(accountId);
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_get");
|
|
|
+ String url = bytedanceApiUrl + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_campaign_get");
|
|
|
Map<String, String> headers = new HashMap<>();
|
|
|
headers.put("Content-Type", "application/json");
|
|
|
headers.put("Access-Token", cTopOauthToken.getAccessToken());
|
|
@@ -751,10 +748,10 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
public void getBytedancePlanList(String accountId, String accessToken, int pageNum, String createDate, String updateDate) {
|
|
|
-
|
|
|
// 请求地址
|
|
|
- String url = PropertiesUtils.getValue("bytedance_config", "bytedance_api_url") + PropertiesUtils.getValue("bytedance_config", "bytedance_v2_ad_get");
|
|
|
+ String url = bytedanceApiUrl + bytedanceAdGetUrl;
|
|
|
// 请求参数
|
|
|
Map<String, Object> filtering = new HashMap<>();
|
|
|
if (null != createDate && !"".equals(createDate)) {
|