文章分组 #32

Manually merged
asd merged 1 commits from zj into master 2019-12-06 10:57:16 +08:00

View File

@ -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)=>{