|
@@ -6,6 +6,7 @@ const mysql = require('mysql2/promise');
|
|
const tools = require("../tools");
|
|
const tools = require("../tools");
|
|
const video_product_controllers = require('../src/data_manager/Controllers/video_product_controllers');
|
|
const video_product_controllers = require('../src/data_manager/Controllers/video_product_controllers');
|
|
const dbConfig = config.isDebug?config.debug_mysql:config.release_mysql
|
|
const dbConfig = config.isDebug?config.debug_mysql:config.release_mysql
|
|
|
|
+const taskdbConfig = config.isDebug?config.debug_task_mysql:config.release_task_mysql
|
|
const CMD = {}
|
|
const CMD = {}
|
|
let page_index = 1;
|
|
let page_index = 1;
|
|
|
|
|
|
@@ -72,9 +73,9 @@ async function processTask(){
|
|
|
|
|
|
}else{
|
|
}else{
|
|
let qm_iap_book_info = rows[0]
|
|
let qm_iap_book_info = rows[0]
|
|
- let iaa_book_id = await CMD.getQMMFVideoProduct(connection,qm_iap_book_info.iaa_book_id)
|
|
|
|
|
|
+ let iaa_book_id = await CMD.getQMMFVideoProduct(qm_iap_book_info.iaa_book_id)
|
|
if(iaa_book_id==null){
|
|
if(iaa_book_id==null){
|
|
- await CMD.addQMMFVideoProduct(connection,iaa_book_id,iaa_book_id.book_id)
|
|
|
|
|
|
+ await CMD.addQMMFVideoProduct(iaa_book_id,iaa_book_id.book_id)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -93,28 +94,37 @@ async function processTask(){
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
-//获取
|
|
|
|
-CMD.getQMMFVideoProduct = async function(connection,product_id){
|
|
|
|
|
|
+//插入
|
|
|
|
+CMD.addQMMFVideoProduct = async function(product_id,product_parent_id){
|
|
|
|
+ let connection = await mysql.createConnection({
|
|
|
|
+ ...taskdbConfig,
|
|
|
|
+ multipleStatements: true
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ let qm_book_data = await require('../src/api/qm_mf/qm_mf_search_book').search_id(product_id)
|
|
|
|
+ await connection.execute(
|
|
|
|
+ `INSERT INTO video_product (product_name,product_id,book_platform,genre,words,words,product_parent_id) VALUES (${qm_book_data.book_name},${product_id},${config.platform_qmmf},${qm_book_data.genre},${qm_book_data.words},${product_parent_id})`
|
|
|
|
+ );
|
|
|
|
+ await connection.end();
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+CMD.getQMMFVideoProduct = async function(product_id){
|
|
|
|
+ let connection = await mysql.createConnection({
|
|
|
|
+ ...taskdbConfig,
|
|
|
|
+ multipleStatements: true
|
|
|
|
+ });
|
|
|
|
+
|
|
const [rows] = await connection.execute(
|
|
const [rows] = await connection.execute(
|
|
`SELECT * FROM video_product WHERE product_id = ${product_id} AND book_platform = ${config.platform_qmmf} LIMIT 1`
|
|
`SELECT * FROM video_product WHERE product_id = ${product_id} AND book_platform = ${config.platform_qmmf} LIMIT 1`
|
|
);
|
|
);
|
|
-
|
|
|
|
|
|
+ await connection.end();
|
|
|
|
+
|
|
if(rows.length<=0){
|
|
if(rows.length<=0){
|
|
return null
|
|
return null
|
|
}
|
|
}
|
|
-
|
|
|
|
return rows[0]
|
|
return rows[0]
|
|
}
|
|
}
|
|
|
|
|
|
-//插入
|
|
|
|
-CMD.addQMMFVideoProduct = async function(connection,product_id,product_parent_id){
|
|
|
|
- let qm_book_data = await require('../src/api/qm_mf/qm_mf_search_book').search_id(product_id)
|
|
|
|
- await connection.execute(
|
|
|
|
- `INSERT INTO video_product (product_name,product_id,book_platform,genre,words,words,product_parent_id) VALUES (${qm_book_data.book_name},${product_id},${config.platform_qmmf},${qm_book_data.genre},${qm_book_data.words},${product_parent_id})`
|
|
|
|
- );
|
|
|
|
-
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
CMD.init = async function(){
|
|
CMD.init = async function(){
|
|
redis_help.connect((results)=>{
|
|
redis_help.connect((results)=>{
|
|
if(results){
|
|
if(results){
|