Files
bettergi-scripts-list/repo/js/AutoPlanDomain/utils/bgi_tools.js
yan f5297ed756 chore(logging): 将bgi_tools配置日志级别从info调整为debug
- 修改config.js中的日志级别设置
- 将bgi_tools配置信息的日志输出从info级别降级为debug级别
- 减少生产环境中的冗余日志输出
2026-02-10 14:26:07 +08:00

53 lines
1.5 KiB
JavaScript

/**
* 拉取对应uid的Json数据
* @param uid
* @param http_api
* @returns {Promise<HttpResponse>}
*/
async function pullJsonConfig(uid, http_api) {
http_api += "?uid=" + uid
const res = await http.request("GET", http_api
// , JSON.stringify({"Content-Type": "application/json"})
)
log.debug(`[{0}]res=>{1}`, 'next', JSON.stringify(res))
if (res.status_code === 200 && res.body) {
let result_json = JSON.parse(res.body);
if (result_json?.code === 200) {
return result_json?.data
}
throw new Error("请求失败,error:" + result_json?.message)
}
return undefined
}
/**
* 推送全部Json数据
* @param Json
* @param http_api
* @returns {Promise<HttpResponse>}
*/
async function pushAllJsonConfig(list = [], http_api,token={name: "Authorization", value: ''}) {
log.info(`list:{1},http:{2}`, list, http_api)
let value = {
"Content-Type": "application/json",
[token.name]: token.value
};
const res = await http.request("POST", http_api, JSON.stringify({json: JSON.stringify(list)}), JSON.stringify(value))
log.debug(`[{0}]res=>{1}`, 'next', JSON.stringify(res))
if (res.status_code === 200 && res.body) {
let result_json = JSON.parse(res.body);
if (result_json?.code === 200) {
return result_json?.data
}
throw new Error("请求失败,error:" + result_json?.message)
}
return undefined
}
export {
pullJsonConfig,
pushAllJsonConfig
}