From 59a60ce214970b3deaf0182e66853fbc69753283 Mon Sep 17 00:00:00 2001 From: asd Date: Wed, 13 Nov 2019 12:47:16 +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 | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/controllers/article.js b/controllers/article.js index e69de29..b45a0be 100644 --- a/controllers/article.js +++ b/controllers/article.js @@ -0,0 +1,32 @@ +var ObjectID = require('mongodb').ObjectID; +var articlefind = async (ctx, next) => { + let articlelist; + await dbs.find("articlelists").then((res) => { + articlelist = res.data + ctx.body=articlelist + }) +} +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}) + console.log(ctx.query) + ctx.body = "添加成功" +} +var articledel=async(ctx,next)=>{ + await dbs.remove("articlelists",{_id:ObjectID(ctx.query.id)}).then((res)=>{ + console.log(res) + console.log(ctx.query) + }) + ctx.body="删除成功" +} +var articleupdate=async (ctx,next)=>{ + let month=parseInt(new Date(Date.now()).getMonth())+1 + + await dbs.update("articlelists",ctx.query.old,ctx.query.new) +} +module.exports = { + 'GET /articleadd': articleadd, + 'GET /articlefind': articlefind, + 'GET /articledel': articledel, + 'GET /articleupdate': articleupdate +}; \ No newline at end of file