const CMD = {}
const HttpClient = require('../../../src/HttpClient')
const config = require('../../../etc/config.json')
const helper = require('../../helper')

// 获取点众回传模板
CMD.search_id = async function(book_id){
    try{
        let clinet = new HttpClient()
        let timestamp = helper.getCurrentUnixTimestamp()
        let signKey = helper.md5(config.dianzhong_config.clientId+config.dianzhong_config.token+timestamp)
        let response = await clinet.post(config.dianzhong_config.bookInfo_host,{
            channelId:config.dianzhong_config.channelId,
            clientId:config.dianzhong_config.clientId,
            timestamp:timestamp,
            type:config.dianzhong_config.type,
            signKey:signKey,
            book_id:book_id
        })
        let info = {}
        if(response.code!=1){
            throw response
        }else{
            info.words = 0
            info.book_name =  response.data[0].bookName
            info.book_id =  response.data[0].bookId
            info.genre = 3;
        }
        return info;
    }catch(e){
        return null;
    }

}
module.exports = CMD;