|
@@ -1,33 +1,18 @@
|
|
package cn.com.ctop.toutiao.modules.adlab.controller;
|
|
package cn.com.ctop.toutiao.modules.adlab.controller;
|
|
|
|
|
|
-import cn.com.ctop.common.module.constant.CtopRoleCodeConstant;
|
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
-import cn.com.ctop.common.module.entity.MaterialImageInfo;
|
|
|
|
-import cn.com.ctop.common.module.entity.MaterialInfo;
|
|
|
|
-import cn.com.ctop.common.module.entity.Project;
|
|
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
-import cn.com.ctop.common.module.service.IMaterialInfoService;
|
|
|
|
-import cn.com.ctop.common.module.utils.Check;
|
|
|
|
-import cn.com.ctop.common.module.utils.JsonUtil;
|
|
|
|
-import cn.com.ctop.toutiao.modules.adlab.entity.CtopAdlabProjectDetail;
|
|
|
|
import cn.com.ctop.toutiao.modules.adlab.service.ICreateProjectService;
|
|
import cn.com.ctop.toutiao.modules.adlab.service.ICreateProjectService;
|
|
import cn.com.ctop.toutiao.modules.adlab.service.ICtopAdlabProjectDetailService;
|
|
import cn.com.ctop.toutiao.modules.adlab.service.ICtopAdlabProjectDetailService;
|
|
-import cn.com.ctop.toutiao.modules.adlab.service.IGetProjectService;
|
|
|
|
-import cn.com.ctop.toutiao.modules.report.entity.ByteDanceCleanMaterialReport;
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
|
+
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
-import org.jeecg.common.system.query.QueryGenerator;
|
|
|
|
-import org.jeecg.common.util.DateUtils;
|
|
|
|
|
|
+
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
-import java.text.ParseException;
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -43,8 +28,8 @@ public class CreateAdlabController {
|
|
ICtopOauthTokenService ctopOauthTokenService;
|
|
ICtopOauthTokenService ctopOauthTokenService;
|
|
@Autowired
|
|
@Autowired
|
|
ICtopAdlabProjectDetailService adlabProjectDetailService;
|
|
ICtopAdlabProjectDetailService adlabProjectDetailService;
|
|
- @Autowired
|
|
|
|
- IGetProjectService getProjectService;
|
|
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 投放管家创建项目第一步
|
|
* 投放管家创建项目第一步
|
|
*/
|
|
*/
|
|
@@ -164,14 +149,13 @@ public class CreateAdlabController {
|
|
public Result<List<JSONObject>> setCreative(@RequestBody JSONArray requestBody){
|
|
public Result<List<JSONObject>> setCreative(@RequestBody JSONArray requestBody){
|
|
Result<List<JSONObject>> result =new Result<>();
|
|
Result<List<JSONObject>> result =new Result<>();
|
|
List<JSONObject> resultList=new ArrayList<>();
|
|
List<JSONObject> resultList=new ArrayList<>();
|
|
- log.info(requestBody.toJSONString());
|
|
|
|
if(requestBody.size()>0){
|
|
if(requestBody.size()>0){
|
|
requestBody.forEach(convert->{
|
|
requestBody.forEach(convert->{
|
|
Map<String,Object> convert2Map= (Map<String,Object>)convert;
|
|
Map<String,Object> convert2Map= (Map<String,Object>)convert;
|
|
JSONObject repoTemp=new JSONObject();
|
|
JSONObject repoTemp=new JSONObject();
|
|
CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId((Long) convert2Map.get("accountId"));
|
|
CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId((Long) convert2Map.get("accountId"));
|
|
JSONObject repo = createProjectService.updateGroupCreative(token, convert2Map);
|
|
JSONObject repo = createProjectService.updateGroupCreative(token, convert2Map);
|
|
- log.info(repo.toJSONString());
|
|
|
|
|
|
+
|
|
if(repo.getInteger("code")==0){
|
|
if(repo.getInteger("code")==0){
|
|
repoTemp.put("code",0);
|
|
repoTemp.put("code",0);
|
|
repoTemp.put("accountId",convert2Map.get("accountId"));
|
|
repoTemp.put("accountId",convert2Map.get("accountId"));
|
|
@@ -200,49 +184,37 @@ public class CreateAdlabController {
|
|
* 投放管家创建项目第五步,设置项目预算信息
|
|
* 投放管家创建项目第五步,设置项目预算信息
|
|
*/
|
|
*/
|
|
@PostMapping(value = "/setBudget")
|
|
@PostMapping(value = "/setBudget")
|
|
- public Result<List<JSONObject>> setBudget(@RequestBody JSONObject requestBody){
|
|
|
|
|
|
+ public Result<List<JSONObject>> setBudget(@RequestBody JSONArray requestBody ){
|
|
|
|
|
|
Result<List<JSONObject>> result =new Result<>();
|
|
Result<List<JSONObject>> result =new Result<>();
|
|
- JSONArray accountIds=requestBody.getJSONArray("accountIds");
|
|
|
|
- if(accountIds.isEmpty()){
|
|
|
|
- result.error500("请选择账户再继续操作");
|
|
|
|
- }else{
|
|
|
|
- List<JSONObject> resultList=new ArrayList<>();
|
|
|
|
- accountIds.forEach(accountId->{
|
|
|
|
- //临时存每一个账户创建后的数据
|
|
|
|
|
|
+ List<JSONObject> resultList=new ArrayList<>();
|
|
|
|
+ if(requestBody.size()>0){
|
|
|
|
+ requestBody.forEach(convert->{
|
|
|
|
+ Map<String,Object> convert2Map= (Map<String,Object>)convert;
|
|
JSONObject repoTemp=new JSONObject();
|
|
JSONObject repoTemp=new JSONObject();
|
|
- requestBody.put("accountId",accountId);
|
|
|
|
- //查询该账户的token
|
|
|
|
- CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId((Long) accountId);
|
|
|
|
- JSONObject repo = createProjectService.updateGroupBudget(token, requestBody);
|
|
|
|
|
|
+ CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId((Long) convert2Map.get("accountId"));
|
|
|
|
+ JSONObject repo = createProjectService.updateGroupBudget(token, convert2Map);
|
|
|
|
+ log.info(repo.toJSONString());
|
|
if(repo.getInteger("code")==0){
|
|
if(repo.getInteger("code")==0){
|
|
repoTemp.put("code",0);
|
|
repoTemp.put("code",0);
|
|
- repoTemp.put("accountId",accountId);
|
|
|
|
|
|
+ repoTemp.put("accountId",convert2Map.get("accountId"));
|
|
repoTemp.put("groupId",repo.getJSONObject("data").getLong("group_id"));
|
|
repoTemp.put("groupId",repo.getJSONObject("data").getLong("group_id"));
|
|
|
|
+ repoTemp.put("userId",repo.getString("userId"));
|
|
}else{
|
|
}else{
|
|
repoTemp.put("code",500);
|
|
repoTemp.put("code",500);
|
|
repoTemp.put("message",repo.getString("message"));
|
|
repoTemp.put("message",repo.getString("message"));
|
|
- repoTemp.put("accountId",accountId);
|
|
|
|
|
|
+ repoTemp.put("accountId",convert2Map.get("accountId"));
|
|
}
|
|
}
|
|
resultList.add(repoTemp);
|
|
resultList.add(repoTemp);
|
|
});
|
|
});
|
|
- //设置预算信息完成后,回写数据到数据库
|
|
|
|
- putStorage(resultList);
|
|
|
|
|
|
+ //入库
|
|
|
|
+ adlabProjectDetailService.putStorage(resultList);
|
|
result.setResult(resultList);
|
|
result.setResult(resultList);
|
|
result.setSuccess(true);
|
|
result.setSuccess(true);
|
|
|
|
+ }else {
|
|
|
|
+ result.error500("请选择需要设置定向信息的项目");
|
|
}
|
|
}
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 新建投放管家项目入库
|
|
|
|
- */
|
|
|
|
- private void putStorage(List<JSONObject> params){
|
|
|
|
- params.forEach(it->{
|
|
|
|
- JSONObject group = getProjectService.getGroup(ctopOauthTokenService.getTokenByAccountId(it.getLong("accountId")), it.getLong("accountId"), it.getLong("groupId"));
|
|
|
|
- if(group.getInteger("code")==0){
|
|
|
|
- adlabProjectDetailService.save((CtopAdlabProjectDetail) group.getJSONObject("data").get("group_info"));
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
}
|
|
}
|