This commit is contained in:
luyuan 2021-03-05 10:36:00 +08:00
parent 5afd0edb0e
commit 344f88b192
Signed by: theluyuan
GPG Key ID: A7972FD973317FF3
2 changed files with 28 additions and 0 deletions

View File

@ -42,6 +42,7 @@ let update = async (ctx,nex)=>{
} }
module.exports = { module.exports = {
"GET /":index, "GET /":index,
"GET /login": login, "GET /login": login,

27
controllers/stu.js Normal file
View File

@ -0,0 +1,27 @@
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
}