|
@@ -1,13 +1,20 @@
|
|
|
package cn.com.ctop.kuaishou.modules.batch.controller;
|
|
|
|
|
|
import cn.com.ctop.common.module.annotation.AutoLog;
|
|
|
+import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.common.module.utils.StringUtils;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouVideoGet;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.vo.KuaiShouVideoGetVo;
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouReportDailyMaterialService;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouVideoGetService;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+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 com.github.pagehelper.PageHelper;
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -30,9 +37,7 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.net.URLDecoder;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @Description: 快手-获取视频接口
|
|
@@ -47,6 +52,8 @@ import java.util.Map;
|
|
|
public class KuaiShouVideoGetController {
|
|
|
@Autowired
|
|
|
private IKuaiShouVideoGetService kuaiShouVideoGetService;
|
|
|
+ @Autowired
|
|
|
+ private IKuaiShouReportDailyMaterialService kuaiShouReportDailyMaterialService;
|
|
|
|
|
|
/**
|
|
|
* 分页列表查询
|
|
@@ -73,6 +80,89 @@ public class KuaiShouVideoGetController {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @GetMapping(value = "/getVideoList")
|
|
|
+ public Result<PageInfo<KuaiShouVideoGetVo>> getVideoList(Long accountId,
|
|
|
+ String startDate,
|
|
|
+ String endDate,
|
|
|
+ String materialType,
|
|
|
+ String channelType,
|
|
|
+ String orderBy,
|
|
|
+ @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
|
|
+ @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
|
|
+ HttpServletRequest req) {
|
|
|
+
|
|
|
+
|
|
|
+ Result<PageInfo<KuaiShouVideoGetVo>> result = new Result<>();
|
|
|
+ try {
|
|
|
+ if (Check.isNull(accountId)) {
|
|
|
+ throw new Exception("请传入账户id");
|
|
|
+ }
|
|
|
+ if (Check.isNull(materialType)) {
|
|
|
+ throw new Exception("请传入素材类型");
|
|
|
+ }
|
|
|
+ if (Check.isNull(channelType)) {
|
|
|
+ throw new Exception("请传入素材渠道");
|
|
|
+ }
|
|
|
+ if (Check.isNull(orderBy)) {
|
|
|
+ throw new Exception("请传入排序方式");
|
|
|
+ }
|
|
|
+ List<KuaiShouVideoGetVo> list = new ArrayList<>();
|
|
|
+ PageHelper.startPage(pageNo, pageSize);
|
|
|
+ Map<String, Object> requestMap = new HashMap<>();
|
|
|
+ requestMap.put("accountId", accountId);
|
|
|
+ requestMap.put("orderBy", orderBy);
|
|
|
+ requestMap.put("materialType", materialType);
|
|
|
+ requestMap.put("channelType", channelType);
|
|
|
+ if (orderBy.equals("time")) {
|
|
|
+ if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
|
|
|
+ requestMap.put("startDate", startDate + " 00:00:00");
|
|
|
+ requestMap.put("endDate", endDate + " 59:59:59");
|
|
|
+ }
|
|
|
+ list = kuaiShouVideoGetService.getVideoList(requestMap);
|
|
|
+ } else if (orderBy.equals("cost")) {
|
|
|
+ if (!Check.isNull(startDate) && !Check.isNull(endDate)) {
|
|
|
+ requestMap.put("startDate", startDate);
|
|
|
+ requestMap.put("endDate", endDate);
|
|
|
+ }
|
|
|
+ list = kuaiShouReportDailyMaterialService.getVideoList(requestMap);
|
|
|
+ }
|
|
|
+ PageInfo<KuaiShouVideoGetVo> pageInfo = new PageInfo<>(list);
|
|
|
+ result.setSuccess(true);
|
|
|
+ result.setResult(pageInfo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ result.setSuccess(false);
|
|
|
+ result.setMessage(e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return result;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public static Map<String, Object> parseJSON2Map(String jsonStr) {
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ JSONObject json = JSONObject.parseObject(jsonStr);
|
|
|
+ for (Object k : json.keySet()) {
|
|
|
+ Object v = json.get(k);
|
|
|
+ if (v instanceof JSONArray) {
|
|
|
+ List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
|
|
|
+ Iterator<Object> it = ((JSONArray) v).iterator();
|
|
|
+ while (it.hasNext()) {
|
|
|
+ JSONObject json2 = (JSONObject) it.next();
|
|
|
+ list.add(parseJSON2Map(json2.toString()));
|
|
|
+ }
|
|
|
+ map.put(k.toString(), list);
|
|
|
+ } else {
|
|
|
+ map.put(k.toString(), v);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 添加
|
|
|
*
|