core/controllers/main.js

29 lines
852 B
JavaScript
Raw Normal View History

2020-01-02 10:24:33 +08:00
let findlist = async (ctx,next)=>{
let list = []
for(let i in reptilelist){
let a = await reptilelist[i].find(ctx.query.name)
list.push({name:reptilelist[i].name,list: [...a]})
2019-12-26 17:37:51 +08:00
}
2020-01-02 10:24:33 +08:00
ctx.body = JSON.stringify(list)
2019-12-26 17:37:51 +08:00
}
2020-01-02 10:24:33 +08:00
let section = async(ctx,next)=>{
for(let i in reptilelist){
if(ctx.query.name == reptilelist[i].name){
ctx.body = await reptilelist[i].section(ctx.query.url)
}
2019-12-26 17:37:51 +08:00
}
}
2020-01-02 10:24:33 +08:00
let picture = async(ctx,next)=>{
for(let i in reptilelist){
if(ctx.query.name == reptilelist[i].name){
// console.log(await reptilelist[i].imglist(ctx.query.url))
ctx.body = await reptilelist[i].imglist(ctx.query.url)
}
}
2019-12-26 17:37:51 +08:00
}
module.exports = {
2020-01-02 10:24:33 +08:00
'GET /find':findlist,
'GET /section':section,
'GET /picture':picture
2019-12-17 20:55:50 +08:00
}