Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions renderer/taosrestful_.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ const axios = require('axios')
module.exports = {
async sendRequest(sqlStr, payload){
// console.log(sqlStr)
try {
try {
let res = await axios.post(`http://${payload.ip}:${payload.port}/rest/sql`, sqlStr, {
auth: {
username: payload.user,
password: payload.password
},
timeout: payload.timeout
})
if (res.data.status == 'succ'){
// console.log(res.data.data)
// console.log(res.data.rows)
// console.log(res.data.head)
let head = res.data.head
if (res.statusText == 'OK'){
let head = res.data.column_meta.map(item => item[0])
let resData = res.data.data.map(item => Object.fromEntries(head.map((a,b)=>[a,item[b]])))
return {'res':true,'count':res.data.rows,'data':resData}
}else{
Expand All @@ -27,9 +24,7 @@ module.exports = {
}else{
return {'res':false,'msg':'连接错误','code':-1}
}

}

},
showDatabases(payload){
return this.sendRequest('SHOW DATABASES', payload)
Expand Down Expand Up @@ -206,9 +201,7 @@ module.exports = {
}else{
return this.sendRequest(sqlStr, payload)
}

})

},
countDataIn(tableName, dbName,primaryKey, payload, where='',startTime=null,endTime=null){
where = this.timeWhere(primaryKey,where,startTime,endTime)
Expand All @@ -226,7 +219,7 @@ module.exports = {
return new Promise((resolve, reject)=>{resolve(0)})
}
})
},
},
rawSql(sqlStr,payload){
return this.sendRequest(sqlStr,payload)
},
Expand Down