From a292148a79df3d2e7cbfe86de8f0a7e99697e4e1 Mon Sep 17 00:00:00 2001 From: asd <374367073@qq.com> Date: Fri, 6 Dec 2019 10:56:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E7=AB=A0=E5=88=86=E7=BB=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controllers/article.js | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/controllers/article.js b/controllers/article.js index 9b6b235..407095c 100644 --- a/controllers/article.js +++ b/controllers/article.js @@ -1,11 +1,33 @@ // title 文章标题 contern 文章内容 -// 获取文章列表 +// 获取所有文章列表 var articlefind = async (ctx, next) => { - let articlelist; + let articlelist=[]; let tags=[] + await dbs.find("articlelists").then(async (res) => { - let num=0 - articlelist = res.data + let articlelists=res.data + await dbs.find("group").then((res)=>{ + let groups=res.data + for(let i in groups){ + if(parseInt(ctx.query.groupid)==groups[i].num_key){ + // console.log(groups[i]) + if(groups[i].fuid!=0){ + for(let m in articlelists){ + if(articlelists[m].groupid==parseInt(ctx.query.groupid)){ + articlelist.push(articlelists[m]) + } + // articlelist.push() + } + } + + } + } + if(articlelist.length==0){ + articlelist=articlelists + } + }) + + // articlelist = res.data await dbs.find("articletag").then( async (res)=>{ for(let i in articlelist){ @@ -53,7 +75,7 @@ var articleadd = async (ctx, next) => { let articleid=0 let month=parseInt(new Date(Date.now()).getMonth())+1 // await dbs.add("articletag",{articleid:ctx.query.articleid,tagid:ctx.query.tagid}) - await dbs.add("articlelists", { articletitle:ctx.request.body.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(),content:ctx.request.body.content,uid:1}) + await dbs.add("articlelists", { articletitle:ctx.request.body.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(),content:ctx.request.body.content,uid:1,groupid:ctx.request.body.groupid}) await dbs.find("label").then(async (res)=>{ // console.log(res.data) await dbs.find("idadd").then((res)=>{