2020-01-02 10:24:33 +08:00
|
|
|
|
2020-01-03 23:57:08 +08:00
|
|
|
let findlist = async (ctx, next) => {
|
|
|
|
// for(let i in reptilelist){
|
|
|
|
// let a = await reptilelist[i].find(ctx.query.name)
|
|
|
|
// // list.push({name:reptilelist[i].name,list: [...a]})
|
|
|
|
// for(let j in a){
|
|
|
|
// let has = true
|
|
|
|
// for(let k in list){
|
|
|
|
// if(list[k].name == a[j].name){
|
|
|
|
// if(list[k].list == undefined){
|
|
|
|
// list[k].list = []
|
|
|
|
// }
|
|
|
|
// has = false
|
|
|
|
// list[k].list.push({name:reptilelist[i].name,url:a[j].url,date:a[j].date,update:a[j].update})
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
// if(has){
|
|
|
|
// list.push({name:a[j].name,list:[{name:reptilelist[i].name,url:a[j].url,date:a[j].date,update:a[j].update}]})
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
2020-12-25 15:15:08 +08:00
|
|
|
console.log("/find111")
|
2020-01-03 23:57:08 +08:00
|
|
|
let pro = []
|
2020-01-02 10:24:33 +08:00
|
|
|
let list = []
|
2020-01-03 23:57:08 +08:00
|
|
|
for (let i in reptilelist) {
|
|
|
|
pro.push(reptilelist[i].find(ctx.query.name))
|
|
|
|
}
|
|
|
|
|
2020-01-17 15:33:56 +08:00
|
|
|
await Promise.allSettled(pro).then((res) => {
|
2020-01-17 15:38:19 +08:00
|
|
|
|
2020-01-03 23:57:08 +08:00
|
|
|
for (let i in res) {
|
2020-01-17 15:39:22 +08:00
|
|
|
if(res[i].status == "fulfilled"){
|
2020-01-17 15:38:19 +08:00
|
|
|
console.log(res[i].value.list)
|
2020-01-17 15:33:56 +08:00
|
|
|
for (let j in res[i].value.list) {
|
|
|
|
let has = true
|
|
|
|
for (let k in list) {
|
|
|
|
if (list[k].name == res[i].value.list[j].name) {
|
|
|
|
if (list[k].list == undefined) {
|
|
|
|
list[k].list = []
|
|
|
|
}
|
|
|
|
has = false
|
|
|
|
list[k].list.push({ name: res[i].value.name, url: res[i].value.list[j].url, date: res[i].value.list[j].date, update: res[i].value.list[j].update })
|
2020-01-03 23:57:08 +08:00
|
|
|
}
|
2020-01-17 15:33:56 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
if (has) {
|
|
|
|
list.push({ name: res[i].value.list[j].name, list: [{ name: res[i].value.name, url: res[i].value.list[j].url, date: res[i].value.list[j].date, update: res[i].value.list[j].update }] })
|
2020-01-03 14:29:01 +08:00
|
|
|
}
|
2020-01-03 23:57:08 +08:00
|
|
|
}
|
2020-01-03 14:29:01 +08:00
|
|
|
}
|
2020-01-17 15:33:56 +08:00
|
|
|
|
2020-01-03 14:29:01 +08:00
|
|
|
}
|
2020-01-03 23:57:08 +08:00
|
|
|
})
|
|
|
|
|
2020-12-25 15:15:08 +08:00
|
|
|
console.log(1111)
|
2020-01-02 10:24:33 +08:00
|
|
|
ctx.body = JSON.stringify(list)
|
2019-12-26 17:37:51 +08:00
|
|
|
}
|
2020-01-03 23:57:08 +08:00
|
|
|
let section = async (ctx, next) => {
|
|
|
|
for (let i in reptilelist) {
|
|
|
|
if (ctx.query.name == reptilelist[i].name) {
|
2020-12-18 15:41:25 +08:00
|
|
|
console.log(reptilelist[i].name)
|
2020-01-03 23:57:08 +08:00
|
|
|
ctx.body = await reptilelist[i].section(ctx.query.url)
|
2020-01-02 10:24:33 +08:00
|
|
|
}
|
2019-12-26 17:37:51 +08:00
|
|
|
}
|
|
|
|
}
|
2020-01-03 23:57:08 +08:00
|
|
|
let picture = async (ctx, next) => {
|
|
|
|
for (let i in reptilelist) {
|
|
|
|
if (ctx.query.name == reptilelist[i].name) {
|
2020-01-18 17:12:47 +08:00
|
|
|
console.log(await reptilelist[i].imglist(ctx.query.url))
|
2020-01-03 23:57:08 +08:00
|
|
|
ctx.body = await reptilelist[i].imglist(ctx.query.url)
|
2020-01-02 10:24:33 +08:00
|
|
|
}
|
|
|
|
}
|
2019-12-26 17:37:51 +08:00
|
|
|
}
|
|
|
|
module.exports = {
|
2020-01-03 23:57:08 +08:00
|
|
|
'GET /find': findlist,
|
|
|
|
'GET /section': section,
|
|
|
|
'GET /picture': picture
|
2019-12-17 20:55:50 +08:00
|
|
|
}
|