|
@@ -4,6 +4,8 @@ const helper = require('../../helper');
|
|
|
const mysql = require('mysql2/promise');
|
|
|
const config = require("../../../etc/config.json");
|
|
|
const dbConfig = config.isDebug?config.debug_mysql:config.release_mysql
|
|
|
+const crypto = require('crypto')
|
|
|
+const { format } = require('date-fns');
|
|
|
const CMD = {}
|
|
|
CMD.search_id = async function (bookId) {
|
|
|
let connection = null
|
|
@@ -200,4 +202,57 @@ CMD.search_350_name = async function (book_name) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+CMD.search_id_new = async function(book_id) {
|
|
|
+ let client = tools.getOneNewClinet()
|
|
|
+ let uuid = tools.generateCryptoNumericUUID()
|
|
|
+ let timestamp = helper.getCurrentUnixTimestamp()
|
|
|
+ const baseUrl = "https://new-media-iaa-mapi.qimao.com/mapi/v1/book-info";
|
|
|
+ const params = {
|
|
|
+ access_key: config.qimao_mf_config.access_key,
|
|
|
+ admin_account_name:"zhuoyue",
|
|
|
+ book_id:book_id,
|
|
|
+ random: uuid,
|
|
|
+ timestamp: timestamp,
|
|
|
+ };
|
|
|
+
|
|
|
+
|
|
|
+ const sortedParams = Object.keys(params)
|
|
|
+ .sort()
|
|
|
+ .map(key => `${key}=${params[key]}`)
|
|
|
+ .join('&');
|
|
|
+
|
|
|
+ const secretKey = config.qimao_mf_config.secret_key;
|
|
|
+
|
|
|
+ const sign = crypto.createHash('md5')
|
|
|
+ .update(sortedParams + secretKey)
|
|
|
+ .digest('hex');
|
|
|
+ const finalUrl = `${baseUrl}?${sortedParams}&sign=${sign}`;
|
|
|
+
|
|
|
+ console.log("finalUrl:",finalUrl)
|
|
|
+ try{
|
|
|
+ let response = await client.get(finalUrl)
|
|
|
+ // console.log("response:",response.data)
|
|
|
+ if(response.data.code!=0){
|
|
|
+ throw response.data
|
|
|
+ }
|
|
|
+ let book_info = response.data.data.book
|
|
|
+ let info = {}
|
|
|
+ info.words = book_info.word_count
|
|
|
+ info.book_name = book_info.name
|
|
|
+ info.book_id = book_info.id
|
|
|
+ info.genre = 999;
|
|
|
+ info.author = book_info.author
|
|
|
+ info.publish_time = format(new Date(book_info.create_time*1000), 'yyyy-MM-dd HH:mm:ss')
|
|
|
+ if(book_info.type==2){ //七猫只有长或者短
|
|
|
+ info.genre = 3;
|
|
|
+ }else{
|
|
|
+ info.genre = 1;
|
|
|
+ }
|
|
|
+ return info;
|
|
|
+ }catch(e){
|
|
|
+ console.log(e)
|
|
|
+ return null
|
|
|
+ }
|
|
|
+}
|
|
|
module.exports = CMD;
|