zj #31

Manually merged
asd merged 2 commits from zj into master 2019-12-06 09:10:42 +08:00
Showing only changes of commit 998b86f8e3 - Show all commits

View File

@ -2,14 +2,40 @@
// 获取文章列表 // 获取文章列表
var articlefind = async (ctx, next) => { var articlefind = async (ctx, next) => {
let articlelist; let articlelist;
await dbs.find("articlelists").then((res) => { let tags=[]
await dbs.find("articlelists").then(async (res) => {
let num=0
articlelist = res.data articlelist = res.data
await dbs.find("articletag").then((res)=>{
for(let i in articlelist){
for(let m in res.data){
// console.log(res.data[m].articleid,articlelist[i].num_key,res.data[m].tagid)
if(res.data[m].articleid==articlelist[i].num_key){
console.log(res.data[m].articleid,articlelist[i].num_key,res.data[m].tagid)
// console.log(res.data[m].articleid)
// console.log(res.data[m].articleid,res.data[m].tagid)
// tags.push([res.data[m].articleid])
tags.push(res.data[m].tagid)
articlelist[i].tag=tags
}else{
tags=[]
}
}
console.log(tags)
}
})
ctx.body=articlelist ctx.body=articlelist
}) })
next() next()
} }
// 添加文章 // 添加文章
// 参数: title 文章标题, content 文章内容 tag 选择的标签id 形式: 1,2 // 参数: title 文章标题, content 文章内容 tags 选择的标签id 形式: 1,2
var articleadd = async (ctx, next) => { var articleadd = async (ctx, next) => {
let articleid=0 let articleid=0
let month=parseInt(new Date(Date.now()).getMonth())+1 let month=parseInt(new Date(Date.now()).getMonth())+1