UNPKG

flexbiz-server

Version:

Flexible Server

5 lines (4 loc) 1.72 kB
var model=global.getModel("newsfeed"),events=global.getModel("events"),news=global.getModel("news"),dmchietkhau=global.getModel("dmchietkhau"),dmkhuyenmai=global.getModel("dmkhuyenmai");const controller=require("../../controllers/controller"),async=require("async"); module.exports=function($router$$){(new controller($router$$,model,"newsfeed",{sort:{date_created:-1},notNeedRight:($user$$,$options$$={})=>($options$$.action||"").toLowerCase()=="view"?!0:!1,onFinding:($user$$,$condition$$,$next$$)=>{$condition$$.status=!0;$next$$(null,$condition$$)},onView:($user$$,$items$$,$next$$)=>{let $id_app$$=$user$$.current_id_app;async.series([function($callback$$){$items$$.filter($r$$=>$r$$.model_name=="events").joinModel2($id_app$$,events,{where:{id:"_id"},fields:"title picture content date_from date_to address location".split(" ")}, function($rs$$){$callback$$(null,$rs$$)})},function($callback$$){$items$$.filter($r$$=>$r$$.model_name=="news").joinModel2($id_app$$,news,{where:{id:"_id"},fields:["title","picture","content"]},function($rs$$){$callback$$(null,$rs$$)})},function($callback$$){$items$$.filter($r$$=>$r$$.model_name=="dmchietkhau").joinModel2($id_app$$,dmchietkhau,{where:{id:"_id"},fields:[{title:"ten_chietkhau"},{content:"mieu_ta"},{picture:"picture"},{date_from:"hieu_luc_tu"},{date_to:"hieu_luc_den"}]},function($rs$$){$callback$$(null, $rs$$)})},function($callback$$){$items$$.filter($r$$=>$r$$.model_name=="dmkhuyenmai").joinModel2($id_app$$,dmkhuyenmai,{where:{id:"_id"},fields:[{title:"ten_khuyenmai"},{content:"mieu_ta"},{picture:"picture"},{date_from:"hieu_luc_tu"},{date_to:"hieu_luc_den"}]},function($rs$$){$callback$$(null,$rs$$)})}],function(){$next$$(null,$items$$)})}})).route()};