const axios = require('axios');
const tools = require('../../../tools');
const CMD = {}
// 根据书id搜索黑岩的书
CMD.search_id = function(bookId,call_back){
    CMD.just_do_it(bookId,call_back)
}


CMD.just_do_it = async function(bookId,call_back){
    // 设置请求的 URL
    const url = `https://ms.zhangwenpindu.cn/manage/book/list?name=&split=&bookId=${bookId}&bookType=&sing=&pageNum=1&pageSize=10&language=zh_TW`;

    // 设置请求头
    const headers =  {
        "accept": "application/json, text/plain, */*",
        "accept-language": "zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6",
        "authorization": "Bearer eyJhbGciOiJIUzUxMiJ9.eyJ1c2VyaWQiOiIxMDg5MyIsImxvZ2luX3VzZXJfa2V5IjoiNDI2YjAwMTEtZDEyZS00NWQ3LWFiZjUtOGVhY2JmZDZjMjc2In0.M0EuzMkk-bnELQHpQMjSgxAK9vDt-srTl0QgJvyMj6hrkMQDUKv_OH9CrQSXEx2WrOesjuhlHuTAyUfRNe_klw",
        // "content-type": "application/x-www-form-urlencoded",
        "sec-ch-ua": "\"Chromium\";v=\"130\", \"Microsoft Edge\";v=\"130\", \"Not?A_Brand\";v=\"99\"",
        "sec-ch-ua-mobile": "?0",
        "sec-ch-ua-platform": "\"Windows\"",
        "sec-fetch-dest": "empty",
        "sec-fetch-mode": "cors",
        "sec-fetch-site": "same-site",
        "cookie": "aliyungf_tc=afc38ef3f5360a9db8307dae3c1b7ef5fc7757297c3b5691f83fa49ae9b2898e; JSESSIONID=3D7EACF138C5B638AD7DF85C58C9B696",
        "Referer": "https://manage.zhangwenpindu.cn/",
        "Referrer-Policy": "strict-origin-when-cross-origin"
      };

    headers['Authorization'] = `Bearer ${await tools.getHyToken()}`

    // 执行请求
    axios.post(url, {} , {headers:headers})
    .then(response => {
        call_back(response.data.data)
        // console.log(response.data.data); // 输出结果
    })
    .catch(error => {
        console.error('Error:', error.message); // 输出错误信息
    });
}

module.exports = CMD;