Merge branch 'zj' of pplokijuhyg/blog-server into master

This commit is contained in:
asd 2019-12-06 10:57:16 +08:00
commit 737bcf281e

View File

@ -1,11 +1,33 @@
// title 文章标题 contern 文章内容 // title 文章标题 contern 文章内容
// 获取文章列表 // 获取所有文章列表
var articlefind = async (ctx, next) => { var articlefind = async (ctx, next) => {
let articlelist; let articlelist=[];
let tags=[] let tags=[]
await dbs.find("articlelists").then(async (res) => { await dbs.find("articlelists").then(async (res) => {
let num=0 let articlelists=res.data
articlelist = 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)=>{ await dbs.find("articletag").then( async (res)=>{
for(let i in articlelist){ for(let i in articlelist){
@ -53,7 +75,7 @@ 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
// await dbs.add("articletag",{articleid:ctx.query.articleid,tagid:ctx.query.tagid}) // 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)=>{ await dbs.find("label").then(async (res)=>{
// console.log(res.data) // console.log(res.data)
await dbs.find("idadd").then((res)=>{ await dbs.find("idadd").then((res)=>{