|
@@ -1,5 +1,7 @@
|
|
|
package cn.com.ctop.kuaishou.modules.batch.service.impl;
|
|
|
|
|
|
+import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
+import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.common.module.utils.HttpUtils;
|
|
|
import cn.com.ctop.common.module.utils.KuaishouInterfaceConstant;
|
|
@@ -13,6 +15,7 @@ import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -38,6 +41,9 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
|
|
|
@Autowired
|
|
|
private KuaishouTemplateMapper templateMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICtopOauthTokenService tokenService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<JSONObject> getJsonArrByAccountId(Long accountId, Integer platformOs, Boolean autoTarget) {
|
|
|
return templateMapper.getJsonArrByAccountId(accountId, platformOs, autoTarget);
|
|
@@ -508,4 +514,83 @@ public class KuaishouTemplateServiceImpl extends ServiceImpl<KuaishouTemplateMap
|
|
|
}
|
|
|
return returnJson;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询加速探索信息
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @throws
|
|
|
+ * @author ZHAOXA
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Result<Object> getbehaviorInterest(Long accountId) {
|
|
|
+ try {
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.BEHAVIOR_INTEREST;
|
|
|
+ Map<String, String> header = new HashMap<>();
|
|
|
+ header.put("Access-Token", token.getAccessToken());
|
|
|
+ header.put("Content-Type", "application/json");
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id", accountId);
|
|
|
+ String result = HttpUtils.httpPostRequest(url, params, header);
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ if (!Check.isNull(resultJson)) {
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
+ if (code == 0) {
|
|
|
+ return Result.ok(resultJson.getJSONObject("data"));
|
|
|
+ } else {
|
|
|
+ log.info(" 获取行为与兴趣类目失败,accountId:{},返回信息:{}", accountId, resultJson);
|
|
|
+ return Result.error("获取行为与兴趣类目失败," + resultJson.getString("message"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取行为与兴趣类目失败", e);
|
|
|
+ }
|
|
|
+ return Result.error("获取行为与兴趣类目失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result<Object> getKeywordQuery(JSONObject data) {
|
|
|
+ try {
|
|
|
+ Long accountId = data.getLong("accountId");
|
|
|
+ String query_str = data.getString("query_str");
|
|
|
+ Integer type = data.getInteger("type");
|
|
|
+ JSONArray ids = data.getJSONArray("ids");
|
|
|
+ if (Check.isNull(accountId) || Check.isNull(type)) {
|
|
|
+ return Result.error("缺失参数");
|
|
|
+ }
|
|
|
+ if (Check.isNull(query_str) && Check.isNull(ids)) {
|
|
|
+ return Result.error("缺失参数");
|
|
|
+ }
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.KEYWORD_QUERY;
|
|
|
+ Map<String, String> header = new HashMap<>();
|
|
|
+ header.put("Access-Token", token.getAccessToken());
|
|
|
+ header.put("Content-Type", "application/json");
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.put("advertiser_id", accountId);
|
|
|
+ params.put("type", type);
|
|
|
+ if (!Check.isNull(query_str)) {
|
|
|
+ params.put("query_str", query_str);
|
|
|
+ }
|
|
|
+ if (!Check.isNull(ids)) {
|
|
|
+ params.put("ids", ids);
|
|
|
+ }
|
|
|
+ String result = HttpUtils.httpPostRequest(url, params, header);
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ if (!Check.isNull(resultJson)) {
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
+ if (code == 0) {
|
|
|
+ return Result.ok(resultJson.getJSONObject("data"));
|
|
|
+ } else {
|
|
|
+ log.info("获取行为兴趣关键词失败,accountId:{},返回信息:{}", accountId, resultJson);
|
|
|
+ return Result.error("获取行为兴趣关键词失败," + resultJson.getString("message"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("获取行为兴趣关键词失败", e);
|
|
|
+ }
|
|
|
+ return Result.error("获取行为兴趣关键词失败");
|
|
|
+ }
|
|
|
}
|