Ver Fonte

批量创建--预览数据格式更改

zhaoxian há 4 anos atrás
pai
commit
a674a24016

+ 1 - 2
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/controller/KuaishouBatchCampaignPreviewController.java

@@ -24,7 +24,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.DeleteMapping;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -140,7 +139,7 @@ public class KuaishouBatchCampaignPreviewController {
             return Result.ok(obj);
         } catch (Exception e) {
             log.error("queryByBatchId is error", e);
-            return Result.error(e.getMessage());
+            return Result.error("查询异常");
         }
     }
 

+ 16 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaishouBatchGroupPreview.java

@@ -1,5 +1,6 @@
 package cn.com.ctop.kuaishou.modules.batch.entity;
 
+import com.alibaba.fastjson.JSONArray;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
@@ -239,4 +240,19 @@ public class KuaishouBatchGroupPreview {
      */
     private Long unitId;
 
+    @TableField(exist = false)
+    private JSONArray materialArr;
+
+    @TableField(exist = false)
+    private JSONArray descriptionArr;
+
+    @TableField(exist = false)
+    private String clickTrackUrl;
+
+    @TableField(exist = false)
+    private String actionbarClickUrl;
+
+    @TableField(exist = false)
+    private String siteId;
+
 }

+ 16 - 4
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouBatchCampaignPreviewServiceImpl.java

@@ -70,18 +70,30 @@ public class KuaishouBatchCampaignPreviewServiceImpl extends ServiceImpl<Kuaisho
 
     private List<KuaishouBatchCampaignPreview> getCampaignList(List<KuaishouBatchCampaignPreview> campaignPreviewList, List<KuaishouBatchGroupPreview> kuaishouBatchGroupPreviews, List<KuaishouBatchCreativePreview> kuaishouBatchCreativePreviews) {
         List<KuaishouBatchGroupPreview> groups = new ArrayList<>();
+
         for (KuaishouBatchGroupPreview groupPreview : kuaishouBatchGroupPreviews) {
-            List<KuaishouBatchCreativePreview> creatives = new ArrayList<>();
+            JSONArray materialArr = new JSONArray();
+            JSONArray descriptionArr = new JSONArray();
             for (KuaishouBatchCreativePreview creativePreview : kuaishouBatchCreativePreviews) {
                 if (groupPreview.getPlanId().equals(creativePreview.getPlanId()) && creativePreview.getGroupId().equals(groupPreview.getId())) {
-                    creatives.add(creativePreview);
+                    JSONObject obj = new JSONObject();
+                    obj.put("photoId", creativePreview.getPhotoId());
+                    obj.put("imageUrl", creativePreview.getImageUrl());
+                    materialArr.add(obj);
+                    descriptionArr.add(creativePreview.getDescription());
+                    groupPreview.setSiteId(creativePreview.getSiteId() + "");
+                    groupPreview.setClickTrackUrl(creativePreview.getClickTrackUrl());
+                    groupPreview.setActionbarClickUrl(creativePreview.getActionbarClickUrl());
                 }
             }
-            groupPreview.setKuaishouBatchCreativePreviews(creatives);
             QueryWrapper<KuaishouTemplate> queryWrapper = new QueryWrapper();
             queryWrapper.eq("template_id", groupPreview.getTemplateId());
             KuaishouTemplate template = kuaishouTemplateService.getOne(queryWrapper);
-            groupPreview.setTemplateName(template.getTemplateName());
+            if (!Check.isNull(template)) {
+                groupPreview.setTemplateName(template.getTemplateName());
+            }
+            groupPreview.setMaterialArr(materialArr);
+            groupPreview.setDescriptionArr(descriptionArr);
             groups.add(groupPreview);
         }
         List<KuaishouBatchCampaignPreview> campaigns = new ArrayList<>();