From aabbd1616c2a0306f19972f67ec6c7eaad887897 Mon Sep 17 00:00:00 2001 From: pplokijuhyg <1162963624@qq.com> Date: Mon, 2 Dec 2019 17:10:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=86=E8=8A=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/article.js | 4 ++-- controllers/grouping.js | 8 +++++--- controllers/label.js | 36 ++++++++++++++++++++++++++++++++---- 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/controllers/article.js b/controllers/article.js index 416a3d7..615e7a3 100644 --- a/controllers/article.js +++ b/controllers/article.js @@ -36,8 +36,8 @@ var articleupdate=async (ctx,next)=>{ // console.log(new Date(Date.now()).getDate()) } module.exports = { - 'GET /articleadd': articleadd, + 'POST /articleadd': articleadd, 'GET /articlefind': articlefind, 'GET /articledel': articledel, - 'GET /articleupdate': articleupdate + 'POST /articleupdate': articleupdate }; \ No newline at end of file diff --git a/controllers/grouping.js b/controllers/grouping.js index 28019b4..90c0952 100644 --- a/controllers/grouping.js +++ b/controllers/grouping.js @@ -2,11 +2,13 @@ var groupadd = async (ctx, next) => { await dbs.add("group", { groupname: ctx.query.groupname, fuid: ctx.query.fuid == null ? '0' : ctx.query.fuid }) ctx.body = "添加成功" + next() } // 删除分组 var groupdel = async (ctx, next) => { await dbs.remove("group", { num_key: parseInt(ctx.query.key) }) ctx.body = "删除成功" + next() } // 获取分组 var groupfind = async (ctx, next) => { @@ -31,9 +33,9 @@ var groupfind = async (ctx, next) => { }) return val; } - if(res.data.length == 0 ){ - ctx.body="{code:0,data:[]}" - }else{ + if (res.data.length == 0) { + ctx.body = "{code:0,data:[]}" + } else { ctx.body = JSON.stringify(tree(res.data)) } diff --git a/controllers/label.js b/controllers/label.js index 59ae797..995c867 100644 --- a/controllers/label.js +++ b/controllers/label.js @@ -1,6 +1,34 @@ // 获取标签 -var getlabel = async (ctx,next)=>{ - await IDBOpenDBRequest.find('label').then((res)=>{ - +var getlabel = async (ctx, next) => { + await dbs.find('label').then((res) => { + ctx.body = JSON.stringify(res) }) -} \ No newline at end of file +} +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 +} +