27 lines
789 B
JavaScript
27 lines
789 B
JavaScript
let addstu = async (ctx,next)=>{
|
|
const msg = dbs.add("stu",{user: ctx.query.user,pwd: ctx.query.pwd})
|
|
ctx.body = JSON.stringify(msg)
|
|
}
|
|
let getstulist = async (ctx,next)=>{
|
|
const list = await dbs.find("stu")
|
|
ctx.body = JSON.stringify(list)
|
|
}
|
|
|
|
let delstu = async (ctx,next)=>{
|
|
const res = await dbs.remove("stu",{num_key: parseInt(ctx.query.id)})
|
|
ctx.body = JSON.stringify({...res,id:ctx.query.id})
|
|
|
|
}
|
|
let upstu = async (ctx,nex)=>{
|
|
console.log(ctx.request.body)
|
|
const res = await dbs.update("stu",{num_key: ctx.request.body.id},{user: ctx.request.body.user,pwd:ctx.request.body.pwd})
|
|
ctx.body = JSON.stringify(res)
|
|
|
|
}
|
|
|
|
module.exports = {
|
|
"GET /addstu": addstu,
|
|
"GET /getstulist": getstulist,
|
|
"GET /delstu": delstu ,
|
|
"POST /upstu": upstu
|
|
} |