From 8147ce6a9adc135a8537d60ad2db7dd6bb7909f2 Mon Sep 17 00:00:00 2001 From: asd Date: Tue, 19 Nov 2019 15:12:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=A2=9E=E5=88=A0=E6=94=B9?= =?UTF-8?q?=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/article.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/controllers/article.js b/controllers/article.js index b45a0be..e74beeb 100644 --- a/controllers/article.js +++ b/controllers/article.js @@ -8,12 +8,12 @@ var articlefind = async (ctx, next) => { } var articleadd = async (ctx, next) => { let month=parseInt(new Date(Date.now()).getMonth())+1 - await dbs.add("articlelists", { articletitle:ctx.query.title, date: new Date(Date.now()).getFullYear ()+ '/' + month+ '/' + new Date(Date.now()).getDay() + ' ' + new Date(Date.now()).getHours() + ':' + new Date(Date.now()).getMinutes() + ':' + new Date(Date.now()).getSeconds(), type: ctx.query.type, tags:ctx.query.tags}) + await dbs.add("articlelists", { articletitle:ctx.query.title, date: new Date(Date.now()).getFullYear ()+ '/' + month+ '/' + new Date(Date.now()).getDate() + ' ' + new Date(Date.now()).getHours() + ':' + new Date(Date.now()).getMinutes() + ':' + new Date(Date.now()).getSeconds(), type: ctx.query.type, tags:ctx.query.tags.split(",")}) console.log(ctx.query) ctx.body = "添加成功" } var articledel=async(ctx,next)=>{ - await dbs.remove("articlelists",{_id:ObjectID(ctx.query.id)}).then((res)=>{ + await dbs.remove("articlelists",{num_key:parseInt(ctx.query.key)}).then((res)=>{ console.log(res) console.log(ctx.query) }) @@ -22,7 +22,10 @@ var articledel=async(ctx,next)=>{ var articleupdate=async (ctx,next)=>{ let month=parseInt(new Date(Date.now()).getMonth())+1 - await dbs.update("articlelists",ctx.query.old,ctx.query.new) + await dbs.update("articlelists",{num_key:parseInt(ctx.query.key)},{articletitle:ctx.query.title, udate: new Date(Date.now()).getFullYear ()+ '/' + month+ '/' + new Date(Date.now()).getDate() + ' ' + new Date(Date.now()).getHours() + ':' + new Date(Date.now()).getMinutes() + ':' + new Date(Date.now()).getSeconds() , type: ctx.query.type, tags:ctx.query.tags.split(",")}) + ctx.body="修改成功" + // console.log(new Date(Date.now()).getFullYear ()+ '/' + month+ '/' + new Date(Date.now()).getDate() + ' ' + new Date(Date.now()).getHours() + ':' + new Date(Date.now()).getMinutes()) + // console.log(new Date(Date.now()).getDate()) } module.exports = { 'GET /articleadd': articleadd,