blog-server/controllers/label.js

35 lines
848 B
JavaScript
Raw Permalink Normal View History

2019-12-02 16:08:44 +08:00
// 获取标签
2019-12-02 17:10:38 +08:00
var getlabel = async (ctx, next) => {
await dbs.find('label').then((res) => {
ctx.body = JSON.stringify(res)
2019-12-02 16:08:44 +08:00
})
2019-12-02 17:10:38 +08:00
}
var addlabel = async (ctx, next) => {
//lablename 标签名
if(ctx.query.lablename != null){
await dbs.add("label",{lablename:ctx.query.lablename}).then((res)=>{
if(res.code == 0){
ctx.body="{code:0,msg:'添加成功'}"
}else{
ctx.body="{code:1,msg:'添加失败'}"
}
})
}else{
ctx.body="{code:1,msg:'添加失败'}"
}
next()
}
var dellabel = async (ctx, next) => {
await dbs.remove("group", { num_key: parseInt(ctx.query.key) })
ctx.body = "删除成功"
next()
}
module.exports = {
'GET /getlabel':getlabel,
'GET /addlabel':addlabel,
'GET /dellabel':dellabel
}