文章增删改查 #22

Manually merged
asd merged 1 commits from zj into master 2019-11-19 15:12:38 +08:00
Showing only changes of commit 8147ce6a9a - Show all commits

View File

@ -8,12 +8,12 @@ var articlefind = async (ctx, next) => {
}
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})
await dbs.add("articlelists", { articletitle:ctx.query.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(), type: ctx.query.type, tags:ctx.query.tags.split(",")})
console.log(ctx.query)
ctx.body = "添加成功"
}
var articledel=async(ctx,next)=>{
await dbs.remove("articlelists",{_id:ObjectID(ctx.query.id)}).then((res)=>{
await dbs.remove("articlelists",{num_key:parseInt(ctx.query.key)}).then((res)=>{
console.log(res)
console.log(ctx.query)
})
@ -22,7 +22,10 @@ var articledel=async(ctx,next)=>{
var articleupdate=async (ctx,next)=>{
let month=parseInt(new Date(Date.now()).getMonth())+1
await dbs.update("articlelists",ctx.query.old,ctx.query.new)
await dbs.update("articlelists",{num_key:parseInt(ctx.query.key)},{articletitle:ctx.query.title, udate: 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() , type: ctx.query.type, tags:ctx.query.tags.split(",")})
ctx.body="修改成功"
// console.log(new Date(Date.now()).getFullYear ()+ '/' + month+ '/' + new Date(Date.now()).getDate() + ' ' + new Date(Date.now()).getHours() + ':' + new Date(Date.now()).getMinutes())
// console.log(new Date(Date.now()).getDate())
}
module.exports = {
'GET /articleadd': articleadd,