UNPKG

flexbiz-server

Version:

Flexible Server

7 lines (6 loc) 2.62 kB
'use strict';var model=global.getModel("dmnhnv"),dmbp=global.getModel("dmbp"),dmdoi=global.getModel("dmdoi"),dmto=global.getModel("dmto"),Participant=global.getModel("participant");const async=require("async"),controller=require("../../controllers/controller"); module.exports=function($router$$){(new controller($router$$,model,"dmnhnv",{sort:{ma_bp:1,ma_doi:1,ma_to:1,ma_nh_nv:1},notNeedRight:($user$$,$options$$={})=>"view"==($options$$.action||"").toLowerCase()?!0:!1,unique:["ma_nh_nv"],onView:function($user$$,$items$$,$next$$){async.series({dp:function($callback$$){$items$$.joinModel2($user$$.current_id_app,dmbp,[{where:{ma_bp:"ma_bp"},fields:["ten_bp"]}],function(){$callback$$(null,$items$$)})},doi:function($callback$$){$items$$.joinModel2($user$$.current_id_app, dmdoi,[{where:{ma_doi:"ma_doi",ma_bp:"ma_bp"},fields:["ten_doi"]}],function(){$callback$$(null,$items$$)})},to:function($callback$$){$items$$.joinModel2($user$$.current_id_app,dmto,[{where:{ma_doi:"ma_doi",ma_bp:"ma_bp",ma_to:"ma_to"},fields:["ten_to"]}],function(){$callback$$(null,$items$$)})},pt:function($callback$$){$items$$.joinModel2($user$$.current_id_app,Participant,[{where:{phu_trach:"email"},fields:[{ten_phu_trach:"name"}]}],function(){$callback$$(null,$items$$)})},ph:function($callback$$){$items$$.joinModel2($user$$.current_id_app, Participant,[{where:{phoi_hop:"email"},fields:[{ten_phoi_hop:"name"}]}],function(){$callback$$(null,$items$$)})}},()=>{$next$$(null,$items$$)})},onRightByItem:($user$$,$condition$$,$next$$)=>{async.series({phu_trach_bp:$callback$$=>{dmbp.find({id_app:$user$$.current_id_app,phu_trach:$user$$.email}).lean().exec(($e$$,$bps$$)=>{$callback$$(null,$bps$$)})},phu_trach_doi:$callback$$=>{dmdoi.find({id_app:$user$$.current_id_app,phu_trach:$user$$.email}).lean().exec(($e$$,$bps$$)=>{$callback$$(null,$bps$$)})}, phu_trach_to:$callback$$=>{dmto.find({id_app:$user$$.current_id_app,phu_trach:$user$$.email}).lean().exec(($e$$,$bps$$)=>{$callback$$(null,$bps$$)})}},($_condition_bps$jscomp$3_e$$,$$or_rs_tos$$)=>{$_condition_bps$jscomp$3_e$$=$$or_rs_tos$$.phu_trach_bp.map($bp$$=>$bp$$.ma_bp);var $_c_dois$$=$$or_rs_tos$$.phu_trach_doi.map($doi$$=>$doi$$.ma_doi);$$or_rs_tos$$=$$or_rs_tos$$.phu_trach_to.map($to$$=>$to$$.ma_to);$$or_rs_tos$$=[{ma_bp:{$in:$_condition_bps$jscomp$3_e$$}},{ma_doi:{$in:$_c_dois$$}},{ma_to:{$in:$$or_rs_tos$$}}]; $_condition_bps$jscomp$3_e$$=[];for(let $k$$ in $condition$$)$_c_dois$$={},$_c_dois$$[$k$$]=$condition$$[$k$$],$_condition_bps$jscomp$3_e$$.push($_c_dois$$);$$or_rs_tos$$.push({$and:$_condition_bps$jscomp$3_e$$});$next$$(null,{$or:$$or_rs_tos$$})})}})).route()};