Browse Source

完善快手报表数据实体类字段属性

syh 5 năm trước cách đây
mục cha
commit
e749f2739b

+ 0 - 2
jeecg-boot-module-system/src/main/java/org/jeecg/config/ShiroConfig.java

@@ -103,8 +103,6 @@ public class ShiroConfig {
         //模板测试
         filterChainDefinitionMap.put("/test/**", "anon");
         //报表测试
-        filterChainDefinitionMap.put("/report/**", "anon");
-
 		//oauth接口
         filterChainDefinitionMap.put("/auth/**", "anon");
 		filterChainDefinitionMap.put("/ctop/syncdata/**", "anon");

+ 4 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/fileupload/controller/FileController.java

@@ -1,6 +1,8 @@
 package org.jeecg.modules.fileupload.controller;
 
 import cn.com.ctop.manage.modules.material.service.IMaterialInfoService;
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.system.vo.LoginUser;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -24,6 +26,7 @@ public class FileController {
 
     @PostMapping("file/insert")
     public Map<String, Object> insertFile(String code, String url) {
-        return materialInfoService.insert(code, url);
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        return materialInfoService.insert(code, url, user.getId());
     }
 }

+ 4 - 0
module-common/src/main/java/cn/com/ctop/common/module/utils/KuaishouInterfaceConstant.java

@@ -12,6 +12,10 @@ public class KuaishouInterfaceConstant {
      */
     public static final String ACCOUNT_REPORT = "/rest/openapi/v1/report/account_report";
     /**
+     * 广告主报表数据
+     */
+    public static final String VIDEO_LIST = "rest/openapi/v1/file/ad/video/list";
+    /**
      * 广告计划报表数据
      */
     public static final String CAMPAIGN_REPORT = "/rest/openapi/v1/report/campaign_report";

+ 8 - 2
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/controller/MaterialInfoController.java

@@ -9,9 +9,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
@@ -64,9 +66,13 @@ public class MaterialInfoController {
                                                      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                      HttpServletRequest req) {
-        Result<IPage<MaterialInfo>> result = new Result<IPage<MaterialInfo>>();
+        Result<IPage<MaterialInfo>> result = new Result<>();
         QueryWrapper<MaterialInfo> queryWrapper = QueryGenerator.initQueryWrapper(materialInfo, req.getParameterMap());
-        Page<MaterialInfo> page = new Page<MaterialInfo>(pageNo, pageSize);
+        LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+        if (null != user.getUsername() && !user.getUsername().contains("admin")) {
+            queryWrapper.eq("user_id", user.getId());
+        }
+        Page<MaterialInfo> page = new Page<>(pageNo, pageSize);
         IPage<MaterialInfo> pageList = materialInfoService.page(page, queryWrapper);
         result.setSuccess(true);
         result.setResult(pageList);

+ 15 - 9
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/entity/MaterialInfo.java

@@ -1,6 +1,5 @@
 package cn.com.ctop.manage.modules.material.entity;
 
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
@@ -29,9 +28,9 @@ public class MaterialInfo {
     /**
      * id
      */
-    @TableId(type = IdType.UUID)
+    @TableId
     @ApiModelProperty(value = "id")
-    private Integer id;
+    private String id;
     /**
      * code
      */
@@ -45,6 +44,19 @@ public class MaterialInfo {
     @ApiModelProperty(value = "url")
     private String url;
     /**
+     * status
+     */
+    @Excel(name = "status", width = 15)
+    @ApiModelProperty(value = "status")
+    private Integer status;
+    /**
+     * userId
+     */
+    @Excel(name = "status", width = 15)
+    @ApiModelProperty(value = "status")
+    private String userId;
+
+    /**
      * createTime
      */
     @ApiModelProperty(value = "createTime")
@@ -54,10 +66,4 @@ public class MaterialInfo {
      */
     @ApiModelProperty(value = "updateTime")
     private Date updateTime;
-    /**
-     * status
-     */
-    @Excel(name = "status", width = 15)
-    @ApiModelProperty(value = "status")
-    private Integer status;
 }

+ 1 - 1
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/IMaterialInfoService.java

@@ -17,5 +17,5 @@ public interface IMaterialInfoService extends IService<MaterialInfo> {
 
     Map<String, Object> checkMaterialInfo(String code);
 
-    Map<String, Object> insert(String code, String url);
+    Map<String, Object> insert(String userId, String code, String url);
 }

+ 2 - 1
module-ctop/src/main/java/cn/com/ctop/manage/modules/material/service/impl/MaterialInfoServiceImpl.java

@@ -47,12 +47,13 @@ public class MaterialInfoServiceImpl extends ServiceImpl<MaterialInfoMapper, Mat
     }
 
     @Override
-    public Map<String, Object> insert(String code, String url) {
+    public Map<String, Object> insert(String userId, String code, String url) {
         Map<String, Object> resultMap = new HashMap<>();
         MaterialInfo info = new MaterialInfo();
         info.setCode(code);
         info.setUrl(url);
         info.setStatus(1);
+        info.setUserId(userId);
         info.setCreateTime(new Date());
         info.setUpdateTime(new Date());
         this.save(info);

+ 2 - 3
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouImageGet.java

@@ -1,6 +1,5 @@
 package cn.com.ctop.kuaishou.modules.batch.entity;
 
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -30,9 +29,9 @@ public class KuaiShouImageGet {
     /**
      * id
      */
-    @TableId(type = IdType.AUTO)
+    @TableId
     @ApiModelProperty(value = "id")
-    private Long id;
+    private String id;
     /**
      * 账户ID
      */

+ 13 - 10
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/entity/KuaiShouVideoGet.java

@@ -1,20 +1,17 @@
 package cn.com.ctop.kuaishou.modules.batch.entity;
 
-import java.io.Serializable;
-import java.util.Date;
-
-import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
-import com.baomidou.mybatisplus.annotation.TableField;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
 
 /**
  * @Description: 快手-获取视频接口
@@ -32,9 +29,9 @@ public class KuaiShouVideoGet {
     /**
      * id
      */
-    @TableId(type = IdType.AUTO)
+    @TableId
     @ApiModelProperty(value = "id")
-    private Long id;
+    private String id;
     /**
      * 账户ID
      */
@@ -70,7 +67,13 @@ public class KuaiShouVideoGet {
      */
     @Excel(name = "视频首帧图片链接", width = 15)
     @ApiModelProperty(value = "视频首帧图片链接")
-    private Object coverUrl;
+    private String coverUrl;
+    /**
+     * 视频首帧图片链接
+     */
+    @Excel(name = "视频MD5值", width = 15)
+    @ApiModelProperty(value = "视频MD5值")
+    private String signature;
     /**
      * 创建时间
      */

+ 4 - 0
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/IKuaishouInterfaceService.java

@@ -92,6 +92,8 @@ public interface IKuaishouInterfaceService {
     void getGroup(String accessToken, Long advertiserId, Long unitId);
 
 
+    void getVideoInfo(String accessToken, Long advertiserId, String photoId);
+
     /**
      * 获取创意信息
      *
@@ -231,6 +233,8 @@ public interface IKuaishouInterfaceService {
      */
     Map<String, Object> advertiserInfo(Long accountId, String accessToken);
 
+    void getVideoList(CtopOauthToken token);
+
     void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate);
 
     void getAdvertiserCampaignReportDaily(CtopOauthToken token, Date startDate, Date endDate);

+ 96 - 1
module-kuaishou/src/main/java/cn/com/ctop/kuaishou/modules/batch/service/impl/KuaishouInterfaceServiceImpl.java

@@ -5,6 +5,7 @@ import cn.com.ctop.common.module.utils.*;
 import cn.com.ctop.kuaishou.modules.batch.entity.*;
 import cn.com.ctop.kuaishou.modules.batch.mapper.*;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouCreativeService;
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
 import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResult;
 import cn.com.ctop.kuaishou.modules.material.entity.KuaishouResultToken;
@@ -202,6 +203,47 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
     }
 
     @Override
+    public void getVideoList(CtopOauthToken token) {
+        getVideoListByPage(token, 1);
+    }
+
+    private void getVideoListByPage(CtopOauthToken token, int page) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_LIST;
+        Map<String, String> headers = new HashMap<>();
+        headers.put("Content-Type", "application/json");
+        headers.put("Access-Token", token.getAccessToken());
+        Map<String, Object> param = new HashMap<>();
+        param.put("advertiser_id", token.getAccountId());
+        param.put("page_size", 500);
+        param.put("page", page);
+        String result = HttpUtils.httpPostRequest(url, param, headers);
+        JSONObject resultJson = JSONObject.parseObject(result);
+        Integer code = resultJson.getInteger("code");
+        String message = resultJson.getString("message");
+        if (null == code || code != 0) {
+            log.error("获取快手视频列表数据异常:{},accountId:{}", message, token.getAccountId());
+            return;
+        }
+        JSONArray details = resultJson.getJSONObject("data").getJSONArray("details");
+        if (null == details || details.size() <= 0) {
+            log.info("快手视频列表信息为空=》accountId:{}", token.getAccountId());
+            return;
+        }
+
+        for (int i = 0; i < details.size(); i++) {
+            var detailJson = details.getJSONObject(i);
+            var kuaiShouVideoGet = JSONObject.toJavaObject(detailJson, KuaiShouVideoGet.class);
+            kuaiShouVideoGet.setAccountId(token.getAccountId());
+            kuaiShouVideoGet.setId("" + token.getAccountId() + kuaiShouVideoGet.getPhotoId());
+            kuaiShouVideoGetService.saveOrUpdate(kuaiShouVideoGet);
+        }
+        getVideoListByPage(token, page + 1);
+    }
+
+    @Autowired
+    private IKuaiShouVideoGetService kuaiShouVideoGetService;
+
+    @Override
     public void getAdvertiserReportDaily(CtopOauthToken token, Date startDate, Date endDate) {
         getAccountDailyReportByPage(token, startDate, endDate, 1);
     }
@@ -1242,12 +1284,65 @@ public class KuaishouInterfaceServiceImpl implements IKuaishouInterfaceService {
                 }
                 creativeService.saveOrUpdate(creative);
             }
-
         }
         getCreativeList(accessToken, advertiserId, page + 1);
     }
 
     /**
+     * 获取视频信息数据
+     *
+     * @param accessToken
+     * @param advertiserId
+     * @param photoId
+     */
+    @Override
+    public void getVideoInfo(String accessToken, Long advertiserId, String photoId) {
+        String url = PropertiesUtils.getConfig("kuaishou_api_url") + KuaishouInterfaceConstant.VIDEO_GET;
+        Map<String, String> headers = new HashMap<String, String>();
+        headers.put("Content-Type", " application/json");
+        headers.put("Access-Token", accessToken);
+        JSONObject param = new JSONObject();
+        param.put("advertiser_id", advertiserId);
+        JSONArray photosArray = new JSONArray();
+        photosArray.add(photoId);
+        param.put("photo_ids", photosArray);
+        try {
+            String result = HttpUtils.kuaiShouhttpPostRequest(url, param.toJSONString(), headers);
+            JSONObject resultJson = JSONObject.parseObject(result);
+            if (!Check.isNull(resultJson)) {
+                Integer code = resultJson.getInteger("code");
+                if (code == 0) {
+                    JSONArray dataArray = resultJson.getJSONArray("data");
+                    if (!Check.isNull(dataArray)) {
+                        for (int i = 0; i < dataArray.size(); i++) {
+                            JSONObject detailJson = dataArray.getJSONObject(i);
+                            if (!Check.isNull(detailJson)) {
+                                KuaiShouVideoGet videoGet = new KuaiShouVideoGet();
+                                videoGet.setId(detailJson.getString("photo_id"));
+                                videoGet.setAccountId(advertiserId);
+                                videoGet.setWidth(detailJson.getInteger("width"));
+                                videoGet.setHeight(detailJson.getInteger("height"));
+                                videoGet.setUrl(detailJson.getLong("unit_id"));
+                                videoGet.setCoverUrl(detailJson.getString("creative_name"));
+                                videoGet.setPhotoId(detailJson.getString("photo_id"));
+                                //videoGet.setSignature(UUID.randomUUID().toString());
+                                kuaiShouVideoGetService.saveOrUpdate(videoGet);
+                            }
+                        }
+                    }
+                } else {
+                    log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
+                }
+
+            } else {
+                log.error("获取广告视频信息返回结果异常,advertiserId:{},异常信息:{}", advertiserId, resultJson);
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
      * 获取 创意信息
      *
      * @param accessToken