|
@@ -1,7 +1,9 @@
|
|
|
package com.tzld.piaoquan.api.remote;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.tzld.piaoquan.api.common.exception.CommonException;
|
|
|
import com.tzld.piaoquan.growth.common.component.HttpPoolClient;
|
|
|
+import com.tzld.piaoquan.growth.common.utils.DateUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -52,7 +54,7 @@ public class AigcApiService {
|
|
|
JSONObject data = res.getJSONObject("data");
|
|
|
return data.getString("qrcodeStr");
|
|
|
} catch (Exception e) {
|
|
|
- log.error("getVideoDetailRequest error", e);
|
|
|
+ log.error("generateQrcode error", e);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
@@ -70,7 +72,7 @@ public class AigcApiService {
|
|
|
JSONObject data = res.getJSONObject("data");
|
|
|
return data.getString("id");
|
|
|
} catch (Exception e) {
|
|
|
- log.error("getVideoDetailRequest error", e);
|
|
|
+ log.error("getAuthResult error", e);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
@@ -84,7 +86,7 @@ public class AigcApiService {
|
|
|
JSONObject res = JSONObject.parseObject(post);
|
|
|
return res.getJSONObject("data");
|
|
|
} catch (Exception e) {
|
|
|
- log.error("getVideoDetailRequest error", e);
|
|
|
+ log.error("getAccountDetail error", e);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
@@ -92,18 +94,26 @@ public class AigcApiService {
|
|
|
public String createPublishPlan(String publishAccountId, String name) {
|
|
|
String url = aigcApiHost + "/publish/plan/save";
|
|
|
JSONObject params = getPublishPlanAddParam(publishAccountId, name);
|
|
|
+ JSONObject res = null;
|
|
|
try {
|
|
|
String post = httpPoolClient.post(url, getAigcPostParam(params));
|
|
|
- JSONObject res = JSONObject.parseObject(post);
|
|
|
- JSONObject data = res.getJSONObject("data");
|
|
|
- return data.getString("id");
|
|
|
+ res = JSONObject.parseObject(post);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("getVideoDetailRequest error", e);
|
|
|
+ log.error("createPublishPlan error", e);
|
|
|
}
|
|
|
- return null;
|
|
|
+ if (Objects.isNull(res)) {
|
|
|
+ throw new CommonException(3000, "创建计划失败,请稍后重试");
|
|
|
+ }
|
|
|
+ Integer code = res.getInteger("code");
|
|
|
+ if (code != 0) {
|
|
|
+ throw new CommonException(3000, res.getString("msg"));
|
|
|
+ }
|
|
|
+ JSONObject data = res.getJSONObject("data");
|
|
|
+ return data.getString("id");
|
|
|
}
|
|
|
|
|
|
private JSONObject getPublishPlanAddParam(String publishAccountId, String name) {
|
|
|
+ String dateStr = DateUtil.getCurrentDateStr("yyyyMMdd");
|
|
|
JSONObject params = JSONObject.parseObject("{\n" +
|
|
|
" \"accountIds\": [\n" +
|
|
|
" \"" + publishAccountId + "\"\n" +
|
|
@@ -114,7 +124,7 @@ public class AigcApiService {
|
|
|
" \"contentModal\": 7,\n" +
|
|
|
" \"douyinPublishAccoutSetting\": [],\n" +
|
|
|
" \"filterMatchMode\": 1,\n" +
|
|
|
- " \"name\": \" 自动回复-" + name + "\",\n" +
|
|
|
+ " \"name\": \"自动回复-" + dateStr + "-" + name + "\",\n" +
|
|
|
" \"publishAccoutJson\": \"\",\n" +
|
|
|
" \"publishBgmType\": 0,\n" +
|
|
|
" \"publishDate\": \"\",\n" +
|
|
@@ -163,7 +173,7 @@ public class AigcApiService {
|
|
|
String post = httpPoolClient.post(url, getAigcPostParam(params));
|
|
|
JSONObject res = JSONObject.parseObject(post);
|
|
|
} catch (Exception e) {
|
|
|
- log.error("getVideoDetailRequest error", e);
|
|
|
+ log.error("closePublishPlan error", e);
|
|
|
}
|
|
|
}
|
|
|
}
|