文章增删改查
This commit is contained in:
parent
79c03c694b
commit
8147ce6a9a
@ -8,12 +8,12 @@ var articlefind = async (ctx, next) => {
|
|||||||
}
|
}
|
||||||
var articleadd = async (ctx, next) => {
|
var articleadd = async (ctx, next) => {
|
||||||
let month=parseInt(new Date(Date.now()).getMonth())+1
|
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)
|
console.log(ctx.query)
|
||||||
ctx.body = "添加成功"
|
ctx.body = "添加成功"
|
||||||
}
|
}
|
||||||
var articledel=async(ctx,next)=>{
|
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(res)
|
||||||
console.log(ctx.query)
|
console.log(ctx.query)
|
||||||
})
|
})
|
||||||
@ -22,7 +22,10 @@ var articledel=async(ctx,next)=>{
|
|||||||
var articleupdate=async (ctx,next)=>{
|
var articleupdate=async (ctx,next)=>{
|
||||||
let month=parseInt(new Date(Date.now()).getMonth())+1
|
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 = {
|
module.exports = {
|
||||||
'GET /articleadd': articleadd,
|
'GET /articleadd': articleadd,
|
||||||
|
Loading…
Reference in New Issue
Block a user