Commit f10a1c64 by 胡悦

修改设备登录接口

1 parent 86508d32
......@@ -2,7 +2,7 @@
* @Author: chenwq
* @Date: 2020-06-16 10:40:02
* @Last Modified by: huyue
* @Last Modified time: 2020-11-24 17:59:15
* @Last Modified time: 2020-11-25 14:23:16
*/
"use strict";
......@@ -45,8 +45,8 @@
* @Request searcher
* @Response 200 response ok
*/
async searchlogin({ request: { body: { pager, searcher } } }) {
const result = await this.devicesService.searchlogin({ pager, searcher });
async searchlogin({ request: { body: searcher } }) {
const result = await this.devicesService.searchlogin({ searcher });
this.ctx.body = this.ServerResponse.Success(result);
}
}
......
......@@ -2,7 +2,7 @@
* @Author: chenwq
* @Date: 2020-06-16 10:02:39
* @Last Modified by: huyue
* @Last Modified time: 2020-11-24 18:14:52
* @Last Modified time: 2020-11-25 14:23:10
* 设备信息
*/
......@@ -131,21 +131,33 @@ class DevicesService extends Service {
* 调用后台接口
*/
async searchlogin({
pager = {},
searcher = {}
}) {
const ctx = this.ctx
const result = await ctx.curl('https://oss-config.test.glsx.com.cn/mock/5e87f9bda9495b066dc5010b/glsx-staging/user.loginTem', {
dataType: 'json',
method: 'POST',
data: {
pager: pager,
searcher: searcher
},
let req = ''
for (let i in searcher) {
req = req + `${i}=${searcher[i]}&`
}
req = req.substr(0, req.length - 1)
const result = await ctx.curl(`http://192.168.3.20:8099/?${req}`, {
dataType: 'text',
method: 'GET',
timeout: 3000,
})
// ctx.body = result.data
return result.data
let data = result.data.split('\n')
console.log('---------')
console.log(result.data, data)
let datalist = []
if (data[1]) {
// 有数据,去掉头尾
for (let i = 1; i < data.length - 1; i++) {
let [deviceno,ip,login,logoff,iccid]= data[i].split(',')
datalist.push({deviceno,ip,login,logoff,iccid})
}
} else {
datalist = []
}
return datalist
}
}
module.exports = DevicesService;
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!