|
@@ -9,11 +9,14 @@ import cn.com.ctop.common.module.utils.PropertiesUtils;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalTemplateRel;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouDirectionalPackageMapper;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.mapper.KuaishouDirectionalTemplateRelMapper;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalTemplateRelService;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouTemplateService;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
@@ -25,8 +28,6 @@ import org.springframework.stereotype.Service;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
-import java.util.concurrent.ExecutorService;
|
|
|
-import java.util.concurrent.Executors;
|
|
|
|
|
|
/**
|
|
|
* 自动投放-定向包详情
|
|
@@ -44,18 +45,20 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
|
|
|
@Autowired
|
|
|
private KuaishouDirectionalPackageMapper packageMapper;
|
|
|
@Autowired
|
|
|
+ private KuaishouDirectionalTemplateRelMapper relMapper;
|
|
|
+ @Autowired
|
|
|
private IKuaishouDirectionalTemplateRelService relService;
|
|
|
@Autowired
|
|
|
private ICtopOauthTokenService oauthTokenService;
|
|
|
- static ExecutorService executorService = null;
|
|
|
|
|
|
@Override
|
|
|
- public Result<Object> createDirectionalPackage(String accessToken, JSONObject requestJson) {
|
|
|
+ public Result<Object> createDirectionalPackage(JSONObject requestJson) {
|
|
|
KuaishouDirectionalPackage entity = packageMapper.queryEntity(requestJson);
|
|
|
if (!Check.isNull(entity)) {
|
|
|
- return Result.error("该账户下人群包名已存在");
|
|
|
+ return Result.error("该账户下定向包名已存在");
|
|
|
}
|
|
|
KuaishouDirectionalPackage kuaishouDirectionalPackage = JSONObject.toJavaObject(requestJson, KuaishouDirectionalPackage.class);
|
|
|
+ kuaishouDirectionalPackage.setKeyword(JSONObject.toJSONString(requestJson.getJSONArray("keyword")));
|
|
|
kuaishouDirectionalPackage.setDataStatus(1);
|
|
|
boolean save = this.save(kuaishouDirectionalPackage);
|
|
|
if (save) {
|
|
@@ -248,132 +251,125 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result<Object> pushDirectionalPackage(String id, JSONArray accountIds) {
|
|
|
+ public Result<Object> pushDirectionalPackage(String id, JSONArray datas) {
|
|
|
KuaishouDirectionalPackage directionalPackage = packageMapper.selectById(id);
|
|
|
- if (Check.isNull(directionalPackage)) {
|
|
|
+ JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(directionalPackage)).toJavaObject(JSONObject.class);
|
|
|
+ if (Check.isNull(data)) {
|
|
|
return Result.error("未找到定向包");
|
|
|
}
|
|
|
- Thread thread = new Thread() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- try {
|
|
|
- executorService = Executors.newFixedThreadPool(3);
|
|
|
- for (int i = 0; i < accountIds.size(); i++) {
|
|
|
- Long accountId = accountIds.getLong(i);
|
|
|
- executorService.submit(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- createDirectionalPackage(directionalPackage, accountId);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- };
|
|
|
- thread.start();
|
|
|
- return Result.ok("推送成功");
|
|
|
+ for (int i = 0; i < datas.size(); i++) {
|
|
|
+ JSONObject request = datas.getJSONObject(i);
|
|
|
+ createDirectionalPackage(data, request);
|
|
|
+ }
|
|
|
+ return Result.ok("推送完成");
|
|
|
}
|
|
|
|
|
|
- private void createDirectionalPackage(KuaishouDirectionalPackage directionalPackage, Long accountId) {
|
|
|
+ private void createDirectionalPackage(JSONObject data, JSONObject request) {
|
|
|
+ Long accountId = request.getLong("accountId");
|
|
|
CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
String message = "";
|
|
|
+ KuaishouDirectionalTemplateRel rel = new KuaishouDirectionalTemplateRel();
|
|
|
+ rel.setDirId(data.getString("id"));
|
|
|
+ rel.setRelId(accountId);
|
|
|
+ rel.setRelType("account");
|
|
|
+ rel.setProjectId(data.getLong("projectId"));
|
|
|
+ rel.setTemplateName(data.getString("templateName"));
|
|
|
+ rel.setDataStatus(0);
|
|
|
try {
|
|
|
JSONObject param = new JSONObject();
|
|
|
param.put("advertiser_id", accountId);
|
|
|
- param.put("template_name", directionalPackage.getTemplateName());
|
|
|
+ param.put("template_name", data.getString("templateName"));
|
|
|
JSONObject targetJson = new JSONObject();
|
|
|
- if (!Check.isNull(directionalPackage.getRegion())) {
|
|
|
- targetJson.put("region", directionalPackage.getRegion());
|
|
|
+ if (!Check.isNull(data.getJSONArray("region"))) {
|
|
|
+ targetJson.put("region", data.getJSONArray("region"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getDistrictIds())) {
|
|
|
- targetJson.put("district_ids", directionalPackage.getDistrictIds());
|
|
|
+ if (!Check.isNull(data.getJSONArray("districtIds"))) {
|
|
|
+ targetJson.put("district_ids", data.getJSONArray("districtIds"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getUserType())) {
|
|
|
- targetJson.put("user_type", directionalPackage.getUserType());
|
|
|
+ if (!Check.isNull(data.getInteger("userType"))) {
|
|
|
+ targetJson.put("user_type", data.getInteger("userType"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getAgesRange())) {
|
|
|
- targetJson.put("ages_range", directionalPackage.getAgesRange());
|
|
|
+ if (!Check.isNull(data.getJSONArray("agesRange"))) {
|
|
|
+ targetJson.put("ages_range", data.getJSONArray("agesRange"));
|
|
|
}
|
|
|
|
|
|
- JSONObject ageJson = new JSONObject();
|
|
|
- if (!Check.isNull(directionalPackage.getMin())) {
|
|
|
- ageJson.put("min", directionalPackage.getMin());
|
|
|
- }
|
|
|
- if (!Check.isNull(directionalPackage.getMax())) {
|
|
|
- ageJson.put("max", directionalPackage.getMax());
|
|
|
- }
|
|
|
- if (!Check.isNull(ageJson)) {
|
|
|
+ if (!Check.isNull(data.getInteger("min")) && !Check.isNull(data.getInteger("max"))) {
|
|
|
+ JSONObject ageJson = new JSONObject();
|
|
|
+ ageJson.put("min", data.getInteger("min"));
|
|
|
+ ageJson.put("max", data.getInteger("max"));
|
|
|
targetJson.put("age", ageJson);
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getGender())) {
|
|
|
- targetJson.put("gender", directionalPackage.getGender());
|
|
|
+
|
|
|
+ if (!Check.isNull(data.getInteger("gender"))) {
|
|
|
+ targetJson.put("gender", data.getInteger("gender"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getPlatformOs())) {
|
|
|
- targetJson.put("platform_os", directionalPackage.getPlatformOs());
|
|
|
+ if (!Check.isNull(data.getInteger("platformOs"))) {
|
|
|
+ targetJson.put("platform_os", data.getInteger("platformOs"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getAndroidOsv())) {
|
|
|
- targetJson.put("android_osv", directionalPackage.getAndroidOsv());
|
|
|
+ if (!Check.isNull(data.getInteger("androidOsv"))) {
|
|
|
+ targetJson.put("android_osv", data.getInteger("androidOsv"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getIosOsv())) {
|
|
|
- targetJson.put("ios_osv", directionalPackage.getIosOsv());
|
|
|
+ if (!Check.isNull(data.getInteger("iosOsv"))) {
|
|
|
+ targetJson.put("ios_osv", data.getInteger("iosOsv"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getNetwork())) {
|
|
|
- targetJson.put("network", directionalPackage.getNetwork());
|
|
|
+ if (!Check.isNull(data.getInteger("network"))) {
|
|
|
+ targetJson.put("network", data.getInteger("network"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getFilterConvertedLevel())) {
|
|
|
- targetJson.put("filter_converted_level", directionalPackage.getFilterConvertedLevel());
|
|
|
+ if (!Check.isNull(data.getInteger("filterConvertedLevel"))) {
|
|
|
+ targetJson.put("filter_converted_level", data.getInteger("filterConvertedLevel"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getDeviceBrand())) {
|
|
|
- targetJson.put("device_brand", directionalPackage.getDeviceBrand());
|
|
|
+ if (!Check.isNull(data.getJSONArray("deviceBrand"))) {
|
|
|
+ targetJson.put("device_brand", data.getJSONArray("deviceBrand"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getDevicePrice())) {
|
|
|
- targetJson.put("device_price", directionalPackage.getDevicePrice());
|
|
|
+ if (!Check.isNull(data.getJSONArray("devicePrice"))) {
|
|
|
+ targetJson.put("device_price", data.getJSONArray("devicePrice"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getBusinessInterestType())) {
|
|
|
- targetJson.put("business_interest_type", directionalPackage.getBusinessInterestType());
|
|
|
+ if (!Check.isNull(data.getInteger("businessInterestType"))) {
|
|
|
+ targetJson.put("business_interest_type", data.getInteger("businessInterestType"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getBusinessInterest())) {
|
|
|
- targetJson.put("business_interest", directionalPackage.getBusinessInterest());
|
|
|
+ if (!Check.isNull(data.getJSONArray("businessInterest"))) {
|
|
|
+ targetJson.put("business_interest", data.getJSONArray("businessInterest"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getFansStar())) {
|
|
|
- targetJson.put("fans_star", directionalPackage.getFansStar());
|
|
|
+ if (!Check.isNull(data.getJSONArray("fansStar"))) {
|
|
|
+ targetJson.put("fans_star", data.getJSONArray("fansStar"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getInterestVideo())) {
|
|
|
- targetJson.put("interest_video", directionalPackage.getInterestVideo());
|
|
|
+ if (!Check.isNull(data.getJSONArray("interestVideo"))) {
|
|
|
+ targetJson.put("interest_video", data.getJSONArray("interestVideo"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getAppInterest())) {
|
|
|
- targetJson.put("app_interest", directionalPackage.getAppInterest());
|
|
|
+ if (!Check.isNull(data.getJSONArray("appInterest"))) {
|
|
|
+ targetJson.put("app_interest", data.getJSONArray("appInterest"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getAppIds())) {
|
|
|
- targetJson.put("app_ids", directionalPackage.getAppIds());
|
|
|
+ if (!Check.isNull(data.getJSONArray("appIds"))) {
|
|
|
+ targetJson.put("app_ids", data.getJSONArray("appIds"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getPopulation())) {
|
|
|
- targetJson.put("population", directionalPackage.getPopulation());
|
|
|
+ if (!Check.isNull(request.getJSONArray("population"))) {
|
|
|
+ targetJson.put("population", request.getJSONArray("population"));
|
|
|
+ rel.setPopulation(request.getString("population"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getPaidAudience())) {
|
|
|
- targetJson.put("paid_audience", directionalPackage.getPaidAudience());
|
|
|
+ if (!Check.isNull(request.getJSONArray("paidAudience"))) {
|
|
|
+ targetJson.put("paid_audience", request.getJSONArray("paidAudience"));
|
|
|
+ rel.setPaidAudience(request.getString("paidAudience"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getExcludePopulation())) {
|
|
|
- targetJson.put("exclude_population", directionalPackage.getExcludePopulation());
|
|
|
+ if (!Check.isNull(request.getJSONArray("excludePopulation"))) {
|
|
|
+ targetJson.put("exclude_population", request.getJSONArray("excludePopulation"));
|
|
|
+ rel.setExcludePopulation(request.getString("excludePopulation"));
|
|
|
}
|
|
|
- JSONObject intelliExtendJson = new JSONObject();
|
|
|
+ if (!Check.isNull(data.getInteger("isOpen"))) {
|
|
|
+ JSONObject intelliExtendJson = new JSONObject();
|
|
|
+ intelliExtendJson.put("is_open", data.getInteger("isOpen"));
|
|
|
|
|
|
- if (!Check.isNull(directionalPackage.getIsOpen())) {
|
|
|
- intelliExtendJson.put("is_open", directionalPackage.getIsOpen());
|
|
|
- }
|
|
|
- if (!Check.isNull(directionalPackage.getNoAgeBreak())) {
|
|
|
- intelliExtendJson.put("no_age_break", directionalPackage.getNoAgeBreak());
|
|
|
- }
|
|
|
- if (!Check.isNull(directionalPackage.getNoGenderBreak())) {
|
|
|
- intelliExtendJson.put("no_gender_break", directionalPackage.getNoGenderBreak());
|
|
|
- }
|
|
|
- if (!Check.isNull(directionalPackage.getNoAreaBreak())) {
|
|
|
- intelliExtendJson.put("no_area_break", directionalPackage.getNoAreaBreak());
|
|
|
- }
|
|
|
- if (!Check.isNull(intelliExtendJson)) {
|
|
|
- targetJson.put("intelli_extend", intelliExtendJson);
|
|
|
+ if (!Check.isNull(data.getInteger("noAgeBreak"))) {
|
|
|
+ intelliExtendJson.put("no_age_break", data.getInteger("noAgeBreak"));
|
|
|
+ }
|
|
|
+ if (!Check.isNull(data.getInteger("noGenderBreak"))) {
|
|
|
+ intelliExtendJson.put("no_gender_break", data.getInteger("noGenderBreak"));
|
|
|
+ }
|
|
|
+ if (!Check.isNull(data.getInteger("noAreaBreak"))) {
|
|
|
+ intelliExtendJson.put("no_area_break", data.getInteger("noAreaBreak"));
|
|
|
+ }
|
|
|
+ if (!Check.isNull(intelliExtendJson)) {
|
|
|
+ targetJson.put("intelli_extend", intelliExtendJson);
|
|
|
+ }
|
|
|
}
|
|
|
if (!Check.isNull(targetJson)) {
|
|
|
param.put("target", targetJson);
|
|
@@ -381,23 +377,23 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
|
|
|
JSONObject behaviorInterest = new JSONObject();
|
|
|
JSONObject behavior = new JSONObject();
|
|
|
JSONObject interest = new JSONObject();
|
|
|
- if (!Check.isNull(directionalPackage.getKeyword())) {
|
|
|
- behavior.put("keyword", directionalPackage.getKeyword());
|
|
|
+ if (!Check.isNull(data.getJSONArray("keyword"))) {
|
|
|
+ behavior.put("keyword", data.getJSONArray("keyword"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getLabel())) {
|
|
|
- behavior.put("label", directionalPackage.getLabel());
|
|
|
+ if (!Check.isNull(data.getJSONArray("label"))) {
|
|
|
+ behavior.put("label", data.getJSONArray("label"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getStrengthType())) {
|
|
|
- behavior.put("strength_type", directionalPackage.getStrengthType());
|
|
|
+ if (!Check.isNull(data.getInteger("strengthType"))) {
|
|
|
+ behavior.put("strength_type", data.getInteger("strengthType"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getTimeType())) {
|
|
|
- behavior.put("time_type", directionalPackage.getTimeType());
|
|
|
+ if (!Check.isNull(data.getInteger("timeType"))) {
|
|
|
+ behavior.put("time_type", data.getInteger("timeType"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getSceneType())) {
|
|
|
- behavior.put("scene_type", directionalPackage.getSceneType());
|
|
|
+ if (!Check.isNull(data.getJSONArray("sceneType"))) {
|
|
|
+ behavior.put("scene_type", data.getJSONArray("sceneType"));
|
|
|
}
|
|
|
- if (!Check.isNull(directionalPackage.getInterestLabel())) {
|
|
|
- interest.put("label", directionalPackage.getInterestLabel());
|
|
|
+ if (!Check.isNull(data.getJSONArray("interestLabel"))) {
|
|
|
+ interest.put("label", data.getJSONArray("interestLabel"));
|
|
|
}
|
|
|
if (!Check.isNull(behavior)) {
|
|
|
behaviorInterest.put("behavior", behavior);
|
|
@@ -419,43 +415,94 @@ public class KuaishouDirectionalPackageServiceImpl extends ServiceImpl<KuaishouD
|
|
|
message = resultJson.getString("message");
|
|
|
if (code == 0) {
|
|
|
kuaishouTemplateService.getTemplateByAccountId(accountId, oauthToken.getAccessToken(), 1);
|
|
|
- JSONObject data = resultJson.getJSONObject("data");
|
|
|
- KuaishouDirectionalTemplateRel rel = new KuaishouDirectionalTemplateRel();
|
|
|
- rel.setDirId(directionalPackage.getId());
|
|
|
- rel.setRelId(accountId);
|
|
|
- rel.setRelType("account");
|
|
|
- rel.setProjectId(directionalPackage.getProjectId());
|
|
|
- rel.setTemplateId(data.getLong("template_id"));
|
|
|
- rel.setTemplateName(directionalPackage.getTemplateName());
|
|
|
- rel.setMessage(message);
|
|
|
- relService.save(rel);
|
|
|
+ JSONObject results = resultJson.getJSONObject("data");
|
|
|
+ rel.setTemplateId(results.getLong("template_id"));
|
|
|
+ rel.setDataStatus(1);
|
|
|
} else {
|
|
|
- log.error("创建定向包失败," + message);
|
|
|
+ message = "推送定向包失败," + message;
|
|
|
+ log.error(message);
|
|
|
}
|
|
|
} else {
|
|
|
- message = "创建定向包失败,返回结果为空";
|
|
|
+ message = "推送定向包失败,返回结果为空";
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
- log.error("创建定向包出现异常", e);
|
|
|
+ message = "推送定向包出现异常";
|
|
|
+ log.error(message, e);
|
|
|
}
|
|
|
+ rel.setMessage(message);
|
|
|
+ relMapper.replace(rel);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result<Object> getHistory(Long projectId, Long templateId, Integer pageNo, Integer pageSize) {
|
|
|
- return null;
|
|
|
+ public Result<Object> queryPushResults(String id, JSONArray accountIds) {
|
|
|
+ List<JSONObject> list = relMapper.queryPushResults(id, accountIds);
|
|
|
+ return Result.ok(new PageInfo<>(list));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
- public Result<Object> getAccountByProjectId(Long projectId, Integer pageNo, Integer pageSize) {
|
|
|
- return null;
|
|
|
+ public Result<Object> updatePopulation(JSONObject requestJson) {
|
|
|
+ Long accountId = requestJson.getLong("accountId");
|
|
|
+ String message = "";
|
|
|
+ KuaishouDirectionalTemplateRel rel = new KuaishouDirectionalTemplateRel();
|
|
|
+ try {
|
|
|
+ CtopOauthToken oauthToken = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
+ QueryWrapper<KuaishouDirectionalTemplateRel> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("dir_id", requestJson.getString("id"));
|
|
|
+ queryWrapper.eq("rel_id", accountId);
|
|
|
+ queryWrapper.eq("rel_type", "account");
|
|
|
+ queryWrapper.eq("template_id", requestJson.getLong("templateId"));
|
|
|
+ JSONObject param = new JSONObject();
|
|
|
+ param.put("template_id", requestJson.getLong("templateId"));
|
|
|
+ param.put("advertiser_id", accountId);
|
|
|
+ param.put("template_name", requestJson.getString("templateName"));
|
|
|
+ JSONObject targetJson = new JSONObject();
|
|
|
+ if (!Check.isNull(requestJson.getJSONArray("population"))) {
|
|
|
+ targetJson.put("population", requestJson.getJSONArray("population"));
|
|
|
+ rel.setPopulation(requestJson.getString("population"));
|
|
|
+ }
|
|
|
+ if (!Check.isNull(requestJson.getJSONArray("paidAudience"))) {
|
|
|
+ targetJson.put("paid_audience", requestJson.getJSONArray("paidAudience"));
|
|
|
+ rel.setPaidAudience(requestJson.getString("paidAudience"));
|
|
|
+ }
|
|
|
+ if (!Check.isNull(requestJson.getJSONArray("excludePopulation"))) {
|
|
|
+ targetJson.put("exclude_population", requestJson.getJSONArray("excludePopulation"));
|
|
|
+ rel.setExcludePopulation(requestJson.getString("excludePopulation"));
|
|
|
+ }
|
|
|
+ if (!Check.isNull(targetJson)) {
|
|
|
+ param.put("target", targetJson);
|
|
|
+ }
|
|
|
+ Map<String, String> headers = new HashMap<String, String>();
|
|
|
+ headers.put("Access-Token", oauthToken.getAccessToken());
|
|
|
+ headers.put("Content-Type", " application/json");
|
|
|
+ String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.TEMPLATE_UPDATE;
|
|
|
+ String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
|
|
|
+ JSONObject resultJson = JSONObject.parseObject(result);
|
|
|
+ if (!Check.isNull(resultJson)) {
|
|
|
+ Integer code = resultJson.getInteger("code");
|
|
|
+ message = resultJson.getString("message");
|
|
|
+ if (code == 0) {
|
|
|
+ kuaishouTemplateService.getTemplateByAccountId(requestJson.getLong("accountId"), oauthToken.getAccessToken(), 1);
|
|
|
+ JSONObject data = resultJson.getJSONObject("data");
|
|
|
+ relService.update(rel, queryWrapper);
|
|
|
+ return Result.ok("修改成功");
|
|
|
+ } else {
|
|
|
+ return Result.error("修改失败," + message);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return Result.error("修改失败,返回结果为空");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("修改定向模板人群包信息异常,账户:{}", accountId, e.getMessage());
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return Result.error("修改失败");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Result<Object> delete(Long accountId, Long templateId) {
|
|
|
- int delete = packageMapper.delete(accountId, templateId);
|
|
|
- if (delete > 0) {
|
|
|
- return Result.ok("删除成功");
|
|
|
- }
|
|
|
- return Result.error("删除失败");
|
|
|
+ public Result<Object> getAccountByProjectId(Long projectId, String id) {
|
|
|
+ List<JSONObject> list = relMapper.getAccountByProjectId(projectId, id);
|
|
|
+ return Result.ok(new PageInfo<>(list));
|
|
|
}
|
|
|
+
|
|
|
}
|