123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- const video_product_controllers = require('./src/data_manager/Controllers/video_product_controllers');
- const config = require("./etc/config.json")
- const redis_help = require('./src/use_redis');
- const CMD = {}
- async function processTask(){
- try{
- const result = await video_product_controllers.getDataByBookPlatform({book_platform:config.platform_heiyan})
- console.log("result:",result)
- if(result.success){
- for (let index = 0; index < result.data.length; index++) {
- const product_item = result.data[index];
- let hy_book_data = await require('./src/api/hy/hy_search_book').search_id(product_item.product_id)
- if(hy_book_data!=null){
- let genre = 1
- if(hy_book_data==undefined||hy_book_data==null){
- return null
- }
- if(hy_book_data.rows==null||hy_book_data.rows==undefined){
- return null
- }
-
- if(hy_book_data.rows.lenght<=0){
- return null
- }
- let typeDesc = hy_book_data.rows[0].typeDesc; //'中篇',
- if(typeDesc=="长篇"){
- genre = 1;
- }else{
- genre = 3;
- }
- await video_product_controllers.updateData({id:product_item.id},{
- genre:genre
- })
- }
- await new Promise(resolve => setTimeout(resolve,100));
- }
- }
- }catch(e){
- console.error("processTask error:",e)
- } finally{
- console.log("finish all!!!!!")
- }
- }
- CMD.init = async function(){
- redis_help.connect((results)=>{
- if(results){
- processTask();
- }
- })
- }
- CMD.init()
|