This commit is contained in:
2020-01-02 10:24:33 +08:00
parent 77061d8417
commit c5207b7758
5 changed files with 46 additions and 46 deletions

View File

@@ -1,42 +1,29 @@
let getlist = async (ctx,next)=>{
await dbs.find('list').then((res)=>{
data = [];
for(let i in res.data){
data.push({
id:res.data[i].num_key,
type:res.data[i].type,
name:res.data[i].name
})
}
ctx.body = JSON.stringify({code:0,data})
})
// next()
}
//添加需要爬取的项目 name url type 0小说 1漫画
let addproject = async (ctx,next)=>{
if(ctx.query.name == undefined || ctx.query.url == undefined || ctx.query.type ==undefined){
ctx.body = "{code:1,msg:参数不能为空}"
}else{
await dbs.add('list',{name:ctx.query.name,url:ctx.query.url,type:ctx.query.type}).then((res)=>{
ctx.body = JSON.stringify(res)
})
}
// next()
}
let rmproject = async (ctx,next) =>{
if(ctx.query.id == undefined){
ctx.body = "{code:1,msg:参数不能为空}"
}else{
await dbs.remove('list',{'num_key':ctx.query.id}).then((res)=>{
ctx.body="{code:1,msg:删除成功}"
})
}
}
let findlist = async (ctx,next)=>{
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]})
}
ctx.body = JSON.stringify(list)
}
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)
}
}
}
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)
}
}
}
module.exports = {
'GET /getlist':getlist,
'GET /addproject':addproject,
'GET /rmproject':rmproject
'GET /find':findlist,
'GET /section':section,
'GET /picture':picture
}