FaaS - 实战观摩 - 脚本执行器
脚本函数,可以直接执行,也可以被调用 callX(path)
。
var act = ctx.paramAsInt('act',0);
var id = ctx.paramAsInt('id',0);
if(act === 2){
db.table('a_menu')
.where("menu_id=?",id)
.delete();
return {code:1,msg:""};
}
var label = ctx.param('label','');
var qr = db.table('a_menu')
.set('pid',ctx.paramAsInt('pid',0))
.set('level',ctx.paramAsInt('level',0))
.set('txt',ctx.param('txt',''))
.set('url',ctx.param('url',''))
.set('tag',ctx.param('tag',''))
.set('target',ctx.param('target',''))
.set('is_disabled',ctx.paramAsInt('is_disabled',0))
.set('is_exclude',ctx.paramAsInt('is_exclude',0))
.set('order_number',ctx.paramAsInt('order_number',0))
.set('icon',ctx.param('icon',''))
.set('label',label)
.set('update_fulltime',"$NOW()");
if(id>0){
qr.where('`menu_id` = ?',id).update();
}else{
id = qr.set("create_fulltime","$NOW()").insert();
}
if(label){
cache.clear('menu_'+label);
}
return {code:1,msg:""};