UNPKG

flexbiz-server

Version:

Flexible Server

5 lines (4 loc) 1.73 kB
'use strict';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$$={})=>"view"==($options$$.action||"").toLowerCase()?!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$$=>"events"==$r$$.model_name).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$$=>"news"==$r$$.model_name).joinModel2($id_app$$,news,{where:{id:"_id"},fields:["title","picture","content"]},function($rs$$){$callback$$(null,$rs$$)})},function($callback$$){$items$$.filter($r$$=>"dmchietkhau"==$r$$.model_name).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$$=>"dmkhuyenmai"==$r$$.model_name).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()};