Преглед изворни кода

修改创意批量代码接口

syh пре 4 година
родитељ
комит
aac4630dbe

+ 140 - 0
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/batch/controller/ByteDanceBatchController.java

@@ -0,0 +1,140 @@
+package cn.com.ctop.toutiao.modules.batch.controller;
+
+import cn.com.ctop.common.module.service.IFileInfoService;
+import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.toutiao.modules.batch.service.IBytedanceIndustryInfoService;
+import cn.com.ctop.toutiao.modules.material.entity.ByteDanceVideoInfo;
+import cn.com.ctop.toutiao.modules.material.entity.BytedanceImageInfo;
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
+import cn.com.ctop.toutiao.modules.material.service.IByteDanceVideoInfoService;
+import cn.com.ctop.toutiao.modules.material.service.IBytedanceImageInfoService;
+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 org.jeecg.common.api.vo.Result;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Map;
+
+
+@Slf4j
+@RestController
+@RequestMapping("/bytedance/batch")
+public class ByteDanceBatchController {
+    @Autowired
+    IByteDanceAdvertisePlanService byteDanceAdvertisePlanService;
+    @Autowired
+    private IBytedanceIndustryInfoService bytedanceIndustryInfoService;
+    @Autowired
+    private IFileInfoService fileInfoService;
+    @Autowired
+    private IByteDanceCreativeService creativeService;
+    @Autowired
+    private IByteDanceVideoInfoService videoInfoService;
+
+    /**
+     * 获取动态词包信息
+     *
+     * @param accountId
+     * @return
+     */
+    @GetMapping("creative/words/get")
+    public Map<String, Object> getCreativeWords(Long accountId) {
+        return fileInfoService.getCreativeWords(accountId);
+    }
+
+    @GetMapping("action/text")
+    public Map<String,Object>getActionText(Long accountId,String landType){
+        return fileInfoService.getActionText(accountId,landType);
+    }
+
+    @GetMapping("industry/list")
+    public Map<String,Object>getIndustryList(){
+        return bytedanceIndustryInfoService.getIndustryList();
+    }
+    @GetMapping("load/industry")
+    public Map<String,Object>loadIndustryList(Long accountId,Integer level){
+        return bytedanceIndustryInfoService.getBytedanceIndustryList(accountId,level);
+    }
+
+    @GetMapping(value = "/getVideoList")
+    public Result<IPage<ByteDanceVideoInfo>> getBytedqanceVideoList(
+            @RequestParam(name = "type") Integer type,
+            @RequestParam(name = "accountId") Long accountId,
+            @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+            @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+            @RequestParam(name = "startDate", defaultValue = "") String startDate,
+            @RequestParam(name = "endDate", defaultValue = "") String endDate) {
+        Result<IPage<ByteDanceVideoInfo>> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("账户id不能为空");
+            }
+
+            QueryWrapper<ByteDanceVideoInfo> queryWrapper = new QueryWrapper<>();
+            if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
+                queryWrapper.between("create_time", startDate+" 00:00:00", endDate+" 23:59:59");
+            }
+            if(null!=type&&type!=0){
+                queryWrapper.eq("type",type);
+            }
+            queryWrapper.eq("account_id",accountId);
+            queryWrapper.orderByDesc("material_upload_time");
+            queryWrapper.groupBy("signature");
+            Page<ByteDanceVideoInfo> page = new Page<>(pageNo, pageSize);
+            IPage<ByteDanceVideoInfo> pageList = videoInfoService.page(page, queryWrapper);
+            result.setSuccess(true);
+            result.setResult(pageList);
+            return result;
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
+    @Autowired
+    private IBytedanceImageInfoService imageInfoService;
+
+    @GetMapping(value = "/getImageList")
+    public Result<IPage<BytedanceImageInfo>> getBytedqanceVideoList(@RequestParam(name = "accountId")Long accountId, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                                    @RequestParam(name = "startDate", defaultValue = "") String startDate,
+                                                                    @RequestParam(name = "endDate", defaultValue = "") String endDate, HttpServletRequest req) {
+        Result<IPage<BytedanceImageInfo>> result = new Result<>();
+        try {
+            if (Check.isNull(accountId)) {
+                throw new Exception("账户id不能为空");
+            }
+            QueryWrapper<BytedanceImageInfo> queryWrapper = new QueryWrapper<>();
+            if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
+                queryWrapper.between("image_create_time", startDate+" 00:00:00", endDate+" 23:59:59");
+            }
+            queryWrapper.eq("account_id",accountId);
+            queryWrapper.orderByDesc("image_create_time");
+            queryWrapper.groupBy("signature");
+            Page<BytedanceImageInfo> page = new Page<>(pageNo, pageSize);
+            IPage<BytedanceImageInfo> pageList = imageInfoService.page(page, queryWrapper);
+            result.setSuccess(true);
+            result.setResult(pageList);
+            return result;
+        } catch (Exception e) {
+            e.printStackTrace();
+            result.setSuccess(false);
+        }
+        return result;
+    }
+
+    /**
+     *  批量创建创意
+     */
+    @PostMapping("/create/creative")
+    public Map<String,Object>addCreative(@RequestBody JSONObject data){
+        return creativeService.batchCreate(data);
+    }
+}
+

+ 1 - 17
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/entity/ByteDanceVideoInfo.java

@@ -59,48 +59,32 @@ public class ByteDanceVideoInfo {
     /**
      * 视频高度
      */
-    @Excel(name = "视频高度", width = 15)
-    @ApiModelProperty(value = "视频高度")
     private Integer height;
     /**
      * 视频时长
      */
-    @Excel(name = "视频时长", width = 15)
-    @ApiModelProperty(value = "视频时长")
     private Double duration;
     /**
      * 视频大小
      */
-    @Excel(name = "视频大小", width = 15)
-    @ApiModelProperty(value = "视频大小")
     private Long size;
     /**
      * 视频地址
      */
-    @ApiModelProperty(value = "视频地址")
     private String videoUrl;
-    @ApiModelProperty(value = "md5码")
     private String signature;
     private Integer status;
     private Date createTime;
-
     private Date updateTime;
-
     private String url;
-
     private String format;
-
     private String posterUrl;
-
     private Long bitRate;
-
     private Long materialId;
-
     private String source;
-
     private Date materialUploadTime;
-
     private String filename;
+    private Integer type;
 
     public ByteDanceVideoInfo(JSONObject data, CtopOauthToken token) {
         this.id = data.getString("id");

+ 10 - 4
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceCreativeServiceImpl.java

@@ -300,14 +300,17 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
         String creativeWay = data.getString("creativeWay");
         params.put("advertiser_id",data.getLong("accountId"));
         //###############公共参数开始################################
-        JSONArray inventoryType = data.getJSONArray("inventoryType");
-        if(null!=inventoryType){
-            params.put("inventory_type",inventoryType);
-        }
+        //优选广告位
         Integer smartInventory = data.getInteger("smartInventory");
         if(null!=smartInventory){
             params.put("smart_inventory",smartInventory);
         }
+        //媒体指定位置
+        JSONArray inventoryType = data.getJSONArray("inventoryType");
+        if(null!=inventoryType){
+            params.put("inventory_type",inventoryType);
+        }
+        //场景指定位置
         String sceneInventory = data.getString("sceneInventory");
         if(null!=sceneInventory&&!sceneInventory.trim().equals("")){
             params.put("scene_inventory",sceneInventory);
@@ -321,6 +324,9 @@ public class ByteDanceCreativeServiceImpl extends ServiceImpl<ByteDanceCreativeM
             params.put("third_industry_id",thirdIndustryId);
         }
 
+        /**
+         * 创意展现方式
+         */
         String creativeDisplayMode = data.getString("creativeDisplayMode");
         if(null!=creativeDisplayMode&&creativeDisplayMode.trim().equals("")){
             params.put("creative_display_mode",creativeDisplayMode);