|
@@ -6,6 +6,7 @@ import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.common.module.utils.QueryGenerator;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.entity.KuaishouDirectionalPackage;
|
|
|
import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouDirectionalPackageService;
|
|
|
+import cn.com.ctop.kuaishou.modules.ai.service.IKuaishouMaterialPoolOperationRecordService;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -14,6 +15,7 @@ import com.github.pagehelper.PageHelper;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.checkerframework.checker.units.qual.C;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
@@ -60,6 +62,9 @@ public class KuaishouDirectionalPackageController {
|
|
|
private IKuaishouDirectionalPackageService kuaishouDirectionalPackageService;
|
|
|
|
|
|
@Autowired
|
|
|
+ private IKuaishouMaterialPoolOperationRecordService kuaishouMaterialPoolOperationRecordService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
private ICtopOauthTokenService oauthTokenService;
|
|
|
|
|
|
/**
|
|
@@ -84,36 +89,33 @@ public class KuaishouDirectionalPackageController {
|
|
|
}
|
|
|
|
|
|
@GetMapping(value = "/getProjectTarget")
|
|
|
- public Result<Object> getProjectTarget(Long projectId,String templateName,
|
|
|
+ public Result<Object> getProjectTarget(Long projectId, String templateName,
|
|
|
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
|
|
try {
|
|
|
- if(Check.isNull(projectId)){
|
|
|
- return Result.error("缺少参数");
|
|
|
+ if (Check.isNull(projectId)) {
|
|
|
+ return Result.error("缺少参数");
|
|
|
}
|
|
|
- return kuaishouDirectionalPackageService.getProjectTarget(projectId,templateName, pageNo, pageSize);
|
|
|
+ return kuaishouDirectionalPackageService.getProjectTarget(projectId, templateName, pageNo, pageSize);
|
|
|
} catch (Exception e) {
|
|
|
log.error("查询异常,", e);
|
|
|
return Result.error("查询失败," + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
@PostMapping(value = "/getProjectTargetByIds")
|
|
|
public Result<Object> getProjectTargetByIds(@RequestBody JSONObject data) {
|
|
|
try {
|
|
|
JSONArray ids = data.getJSONArray("ids");
|
|
|
- if(Check.isNull(ids)){
|
|
|
- return Result.error("缺少参数");
|
|
|
+ if (Check.isNull(ids)) {
|
|
|
+ return Result.error("缺少参数");
|
|
|
}
|
|
|
List<String> list = JSONObject.parseObject(JSONObject.toJSONString(ids), List.class);
|
|
|
- if(Check.isNull(list)){
|
|
|
+ if (Check.isNull(list)) {
|
|
|
return Result.error("缺少参数");
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
List<KuaishouDirectionalPackage> targets = kuaishouDirectionalPackageService.getProjectTargetByIds(list);
|
|
|
return Result.ok(targets);
|
|
|
} catch (Exception e) {
|
|
@@ -171,7 +173,11 @@ public class KuaishouDirectionalPackageController {
|
|
|
if (Check.isNull(requestJson.getString("templateName"))) {
|
|
|
return Result.error("未获取到定向包名称");
|
|
|
}
|
|
|
- return kuaishouDirectionalPackageService.editPopulation(requestJson);
|
|
|
+ Result<Object> result = kuaishouDirectionalPackageService.editPopulation(requestJson);
|
|
|
+ if (result.getCode() == 200) {
|
|
|
+ kuaishouMaterialPoolOperationRecordService.addRecord(requestJson, "/editPopulation", 1, "update");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
} catch (Exception e) {
|
|
|
log.error("查询异常,", e.getMessage());
|
|
|
e.printStackTrace();
|
|
@@ -215,7 +221,6 @@ public class KuaishouDirectionalPackageController {
|
|
|
*/
|
|
|
@PostMapping(value = "/createDirectionalPackage")
|
|
|
public Result<Object> createDirectionalPackage(@RequestBody JSONObject requestJson) {
|
|
|
- Result<JSONObject> result = new Result<>();
|
|
|
try {
|
|
|
if (Check.isNull(requestJson.getString("templateName"))) {
|
|
|
return Result.error("定向模板名称为必传项");
|
|
@@ -224,7 +229,11 @@ public class KuaishouDirectionalPackageController {
|
|
|
if (Check.isNull(accountId)) {
|
|
|
return Result.error("请选择账户id");
|
|
|
}
|
|
|
- return kuaishouDirectionalPackageService.createDirectionalPackage(requestJson);
|
|
|
+ Result<Object> result = kuaishouDirectionalPackageService.createDirectionalPackage(requestJson);
|
|
|
+ if (result.getCode() == 200) {
|
|
|
+ kuaishouMaterialPoolOperationRecordService.addRecord(requestJson, "/createDirectionalPackage", 1, "add");
|
|
|
+ }
|
|
|
+ return result;
|
|
|
} catch (Exception e) {
|
|
|
log.error("创建定向包失败", e);
|
|
|
return Result.error("创建失败" + e.getMessage());
|
|
@@ -247,7 +256,11 @@ public class KuaishouDirectionalPackageController {
|
|
|
if (Check.isNull(requestJson.getString("projectId"))) {
|
|
|
return Result.error("请选择项目");
|
|
|
}
|
|
|
- return kuaishouDirectionalPackageService.updateDirectionalPackage(requestJson);
|
|
|
+ Result<Object> result1 = kuaishouDirectionalPackageService.updateDirectionalPackage(requestJson);
|
|
|
+ if (result1.getCode() == 200) {
|
|
|
+ kuaishouMaterialPoolOperationRecordService.addRecord(requestJson, "/updateDirectionalPackage", 1, "update");
|
|
|
+ }
|
|
|
+ return result1;
|
|
|
} catch (Exception e) {
|
|
|
result.setSuccess(false);
|
|
|
result.setMessage(e.getMessage());
|
|
@@ -272,7 +285,8 @@ public class KuaishouDirectionalPackageController {
|
|
|
if (Check.isNull(datas)) {
|
|
|
return Result.error("请选择推送账户");
|
|
|
}
|
|
|
- return kuaishouDirectionalPackageService.pushDirectionalPackage(id, datas);
|
|
|
+ Result<Object> result = kuaishouDirectionalPackageService.pushDirectionalPackage(id, datas, requestJson);
|
|
|
+ return result;
|
|
|
} catch (Exception e) {
|
|
|
log.error("推送定向包异常", e);
|
|
|
}
|
|
@@ -320,8 +334,17 @@ public class KuaishouDirectionalPackageController {
|
|
|
@GetMapping(value = "/delete")
|
|
|
public Result<Object> delete(String id) {
|
|
|
try {
|
|
|
+
|
|
|
+ KuaishouDirectionalPackage directionalPackage = kuaishouDirectionalPackageService.getById(id);
|
|
|
+ if (Check.isNull(directionalPackage)) {
|
|
|
+ return Result.error("未查到实体");
|
|
|
+ }
|
|
|
boolean b = kuaishouDirectionalPackageService.removeById(id);
|
|
|
if (b) {
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ data.put("id", id);
|
|
|
+ data.put("projectId", directionalPackage.getProjectId());
|
|
|
+ kuaishouMaterialPoolOperationRecordService.addRecord(data, "/kuaishouDirectionalPackage/delete", 1, "delete");
|
|
|
return Result.ok("删除成功");
|
|
|
}
|
|
|
} catch (Exception e) {
|