Просмотр исходного кода

添加头条图片素材获取逻辑

syh 4 лет назад
Родитель
Сommit
f61324d3b8

+ 12 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/ActorController.java

@@ -63,6 +63,7 @@ public class ActorController {
                                               HttpServletRequest req) {
         Result<IPage<Actor>> result = new Result<>();
         QueryWrapper<Actor> queryWrapper = QueryGenerator.initQueryWrapper(actor, req.getParameterMap());
+        queryWrapper.orderByDesc("create_time");
         Page<Actor> page = new Page<>(pageNo, pageSize);
         IPage<Actor> pageList = actorService.page(page, queryWrapper);
         result.setSuccess(true);
@@ -274,4 +275,15 @@ public class ActorController {
         }
         return result;
     }
+
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            actorService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败",e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
 }

+ 23 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BytedanceMusicInfoController.java

@@ -1,5 +1,7 @@
 package org.jeecg.modules.ctop.controller;
 
+import cn.com.ctop.common.module.utils.ResultMapUtils;
+import cn.com.ctop.common.module.utils.StatusCode;
 import cn.com.ctop.crawler.modules.music.entity.BytedanceMusicInfo;
 import cn.com.ctop.crawler.modules.music.service.IBytedanceMusicInfoService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -15,8 +17,10 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
 
- /**
+/**
  * 音乐信息
  * @author jeecg-boot
  * @date   2020-10-28
@@ -30,6 +34,24 @@ public class BytedanceMusicInfoController {
 	@Autowired
 	private IBytedanceMusicInfoService bytedanceMusicInfoService;
 
+	 @GetMapping(value = "/downLoad")
+	 public Map<String,Object> downLoad(Long id) {
+		Map<String,Object>result = new HashMap<>();
+		if(null == id||id == 0){
+			ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
+			return result;
+		}
+		BytedanceMusicInfo musicInfo = bytedanceMusicInfoService.getById(id);
+		if(null == musicInfo){
+			ResultMapUtils.setResultMap(result, StatusCode.COMMON_PARAM_ERROR);
+			return result;
+		}
+		musicInfo.setDownloadNum(musicInfo.getDownloadNum()+1);
+		bytedanceMusicInfoService.updateById(musicInfo);
+		ResultMapUtils.setResultMap(result,StatusCode.COMMON_SUCCESS);
+		return result;
+	 }
+
 	/**
 	  * 分页列表查询
 	 * @param bytedanceMusicInfo

+ 3 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/BytedanceMusicTypeController.java

@@ -50,7 +50,9 @@ public class BytedanceMusicTypeController {
 		bytedanceMusicType.setTypeValue(null);
 		Result<IPage<BytedanceMusicType>> result = new Result<>();
 		QueryWrapper<BytedanceMusicType> queryWrapper = QueryGenerator.initQueryWrapper(bytedanceMusicType, req.getParameterMap());
-		queryWrapper.like("type_value",typeValue);
+		if(null!=typeValue&&!typeValue.trim().equals("")){
+			queryWrapper.like("type_value",typeValue);
+		}
 		Page<BytedanceMusicType> page = new Page<>(pageNo, pageSize);
 		IPage<BytedanceMusicType> pageList = bytedanceMusicTypeService.page(page, queryWrapper);
 		List<BytedanceMusicType> records = pageList.getRecords();

+ 12 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/PropController.java

@@ -37,6 +37,17 @@ public class PropController {
         return result;
     }
 
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            propService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败",e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
     /**
      * 分页列表查询
      *
@@ -53,6 +64,7 @@ public class PropController {
                                               HttpServletRequest req) {
         Result<IPage<Prop>> result = new Result<>();
         QueryWrapper<Prop> queryWrapper = QueryGenerator.initQueryWrapper(prop, req.getParameterMap());
+        queryWrapper.orderByDesc("create_time");
         Page<Prop> page = new Page<>(pageNo, pageSize);
         IPage<Prop> pageList = propService.page(page, queryWrapper);
 

+ 19 - 5
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/YardController.java

@@ -4,7 +4,10 @@ import cn.com.ctop.manage.modules.actor.entity.Yard;
 import cn.com.ctop.manage.modules.actor.entity.YardComment;
 import cn.com.ctop.manage.modules.actor.entity.YardPhoto;
 import cn.com.ctop.manage.modules.actor.entity.YardVideo;
-import cn.com.ctop.manage.modules.actor.service.*;
+import cn.com.ctop.manage.modules.actor.service.IYardCommentService;
+import cn.com.ctop.manage.modules.actor.service.IYardPhotoService;
+import cn.com.ctop.manage.modules.actor.service.IYardService;
+import cn.com.ctop.manage.modules.actor.service.IYardVideoService;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -15,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletRequest;
-import java.io.File;
 
 /**
  * @author yumeng
@@ -28,8 +30,6 @@ public class YardController {
     @Autowired
     private IYardPhotoService yardPhotoService;
     @Autowired
-    private IYardSchedulerService yardSchedulerService;
-    @Autowired
     private IYardService yardService;
     @Autowired
     private IYardVideoService yardVideoService;
@@ -79,8 +79,9 @@ public class YardController {
                                              @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                              @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                              HttpServletRequest req) {
-        Result<IPage<Yard>> result = new Result<IPage<Yard>>();
+        Result<IPage<Yard>> result = new Result<>();
         QueryWrapper<Yard> queryWrapper = QueryGenerator.initQueryWrapper(yard, req.getParameterMap());
+        queryWrapper.orderByDesc("create_time");
         Page<Yard> page = new Page<Yard>(pageNo, pageSize);
         IPage<Yard> pageList = yardService.page(page, queryWrapper);
 
@@ -217,4 +218,17 @@ public class YardController {
         result.setResult(pageList);
         return result;
     }
+
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            yardService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败",e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+
 }

+ 21 - 0
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -205,6 +205,27 @@ public class SampleTest {
         //  查询快手token
     }
 
+    @Test
+    public void testLoadBytedanceImageData(){
+        List<CtopOauthToken>tokens = tokenService.selectToutiaoToken();
+        countDownLatch = new CountDownLatch(tokens.size());
+        executorService = Executors.newFixedThreadPool(8);
+        tokens.forEach(token->executorService.submit(()->{
+            try {
+                advertiserDataService.getMaterialList(token);
+            }catch (Exception e){
+            }finally {
+                countDownLatch.countDown();
+            }
+        }));
+        try {
+            countDownLatch.await();
+        } catch (InterruptedException e) {
+            e.printStackTrace();
+        }
+        System.out.println("素材数据获取完成");
+
+    }
     @Autowired
     private KuaishouAgentAccountMapper kuaishouAgentAccountMapper;
     @Test

+ 4 - 38
module-crawler/src/main/java/cn/com/ctop/crawler/modules/music/entity/BytedanceMusicInfo.java

@@ -4,11 +4,9 @@ import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
-import org.jeecgframework.poi.excel.annotation.Excel;
 
 import java.util.Date;
 
@@ -25,50 +23,18 @@ import java.util.Date;
 @ApiModel(value="ctop_music_info对象", description="音乐信息")
 public class BytedanceMusicInfo {
 
-	/**id*/
-	@TableId(type = IdType.UUID)
-    @ApiModelProperty(value = "id")
-	private Integer id;
-	/**name*/
-	@Excel(name = "name", width = 15)
-    @ApiModelProperty(value = "name")
+	@TableId(type = IdType.AUTO)
+	private Long id;
 	private String name;
-	/**author*/
-	@Excel(name = "author", width = 15)
-    @ApiModelProperty(value = "author")
 	private String author;
-	/**usedCount*/
-	@Excel(name = "usedCount", width = 15)
-    @ApiModelProperty(value = "usedCount")
-	private Integer usedCount;
-	/**musicUrl*/
-	@Excel(name = "musicUrl", width = 15)
-    @ApiModelProperty(value = "musicUrl")
+	private Long usedCount;
 	private String musicUrl;
-	/**coverUrl*/
-	@Excel(name = "coverUrl", width = 15)
-    @ApiModelProperty(value = "coverUrl")
 	private String coverUrl;
-	/**duration*/
-	@Excel(name = "duration", width = 15)
-    @ApiModelProperty(value = "duration")
 	private Integer duration;
-	/**source*/
-	@Excel(name = "source", width = 15)
-    @ApiModelProperty(value = "source")
 	private String source;
-	/**extId*/
-	@Excel(name = "extId", width = 15)
-    @ApiModelProperty(value = "extId")
 	private String extId;
-	/**extInfo*/
-	@Excel(name = "extInfo", width = 15)
-    @ApiModelProperty(value = "extInfo")
 	private Object extInfo;
-	/**createTime*/
-    @ApiModelProperty(value = "createTime")
 	private Date createTime;
-	/**updateTime*/
-    @ApiModelProperty(value = "updateTime")
 	private Date updateTime;
+	private Long downloadNum;
 }

+ 1 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/music/mapper/xml/DictMusicTypeMapper.xml

@@ -7,7 +7,7 @@
     </select>
 
     <select id="getAllExtInfoByExtTypeZh" resultType="cn.com.ctop.crawler.modules.music.entity.DictMusicType">
-        select distinct ext_type_value,ext_type_zh from ctop_dict_music_type_zh
+        select distinct ext_type_value_zh,ext_type_zh from ctop_dict_music_type_zh
         where ext_type_zh = #{extTypeZh}
     </select>
 </mapper>

+ 2 - 1
module-crawler/src/main/java/cn/com/ctop/crawler/modules/music/service/impl/DictMusicTypeServiceImpl.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -25,7 +26,7 @@ public class DictMusicTypeServiceImpl extends ServiceImpl<DictMusicTypeMapper, D
         JSONObject data = new JSONObject();
         List<DictMusicType> musicTypeList = musicTypeMapper.getAllExtTypeZh();
         if(null!=musicTypeList&&!musicTypeList.isEmpty()){
-            List<DictMusicType> setList = musicTypeMapper.getAllExtTypeZh();
+            List<DictMusicType> setList = new ArrayList<>();
             for (DictMusicType type:musicTypeList) {
                 List<DictMusicType>children = musicTypeMapper.getAllExtInfoByExtTypeZh(type.getExtTypeZh());
                 type.setDetail(children);

+ 1 - 1
module-toutiao/src/main/java/cn/com/ctop/toutiao/modules/material/service/impl/ByteDanceAdvertiserDataServiceImpl.java

@@ -608,7 +608,7 @@ public class ByteDanceAdvertiserDataServiceImpl implements IByteDanceAdvertiserD
     @Override
     public void getMaterialList(CtopOauthToken token) {
         getVideoByPage(token, "", 1);
-//        getImageByPage(token, "", 1);
+        getImageByPage(token, "", 1);
         videoInfoService.updateMaterialType();
         imageInfoService.updateType();
     }