Built motion from commit cb845558.|2.6.34
[motion2.git] / server / api / cmCompany / cmCompany.controller.js
index f0e49f2..1f8401c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x274f=['pick','getContacts','hasOwnProperty','eml-format','rimraf','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','undefined','count','Content-Range','reject','update','then','destroy','get','Companies','UserProfileResource','CmCompany','describe','model','keys','query','intersection','attributes','fields','length','nolimit','limit','order','sort','where','filters','filter','merge','map','options','includeAll','include','findAll','rows','params','rawAttributes','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','autoAssociation','name','catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','addContacts','CmContact','ids','findOne'];(function(_0x584da3,_0x388a44){var _0x37aeb9=function(_0x1f5b77){while(--_0x1f5b77){_0x584da3['push'](_0x584da3['shift']());}};_0x37aeb9(++_0x388a44);}(_0x274f,0x102));var _0xf274=function(_0x745c75,_0x3ddc96){_0x745c75=_0x745c75-0x0;var _0x15d6c2=_0x274f[_0x745c75];return _0x15d6c2;};'use strict';var emlformat=require(_0xf274('0x0'));var rimraf=require(_0xf274('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xf274('0x2'));var rp=require(_0xf274('0x3'));var moment=require(_0xf274('0x4'));var BPromise=require(_0xf274('0x5'));var Mustache=require(_0xf274('0x6'));var util=require(_0xf274('0x7'));var path=require('path');var sox=require(_0xf274('0x8'));var csv=require(_0xf274('0x9'));var ejs=require(_0xf274('0xa'));var fs=require('fs');var fs_extra=require(_0xf274('0xb'));var _=require(_0xf274('0xc'));var squel=require(_0xf274('0xd'));var crypto=require(_0xf274('0xe'));var jsforce=require(_0xf274('0xf'));var deskjs=require(_0xf274('0x10'));var toCsv=require(_0xf274('0x9'));var querystring=require(_0xf274('0x11'));var Papa=require('papaparse');var Redis=require(_0xf274('0x12'));var authService=require(_0xf274('0x13'));var qs=require(_0xf274('0x14'));var as=require(_0xf274('0x15'));var hardwareService=require(_0xf274('0x16'));var logger=require(_0xf274('0x17'))(_0xf274('0x18'));var utils=require(_0xf274('0x19'));var config=require(_0xf274('0x1a'));var licenseUtil=require(_0xf274('0x1b'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x2f773b,_0x2e9fd7){_0x2e9fd7=_0x2e9fd7||0xcc;return function(_0x515974){if(_0x515974){return _0x2f773b[_0xf274('0x1c')](_0x2e9fd7);}return _0x2f773b[_0xf274('0x1d')](_0x2e9fd7)[_0xf274('0x1e')]();};}function respondWithResult(_0x3ff324,_0x3d8dfb){_0x3d8dfb=_0x3d8dfb||0xc8;return function(_0x1c2178){if(_0x1c2178){return _0x3ff324['status'](_0x3d8dfb)[_0xf274('0x1f')](_0x1c2178);}};}function respondWithFilteredResult(_0x5248cb,_0x3cabeb){return function(_0x30cb68){if(_0x30cb68){var _0x556594=typeof _0x3cabeb[_0xf274('0x20')]===_0xf274('0x21')&&typeof _0x3cabeb['limit']===_0xf274('0x21');var _0x34de73=_0x30cb68[_0xf274('0x22')];var _0xf246ed=_0x556594?0x0:_0x3cabeb[_0xf274('0x20')];var _0x3522fd=_0x556594?_0x30cb68[_0xf274('0x22')]:_0x3cabeb[_0xf274('0x20')]+_0x3cabeb['limit'];var _0x3f48a5;if(_0x3522fd>=_0x34de73){_0x3522fd=_0x34de73;_0x3f48a5=0xc8;}else{_0x3f48a5=0xce;}_0x5248cb[_0xf274('0x1d')](_0x3f48a5);return _0x5248cb['set'](_0xf274('0x23'),_0xf246ed+'-'+_0x3522fd+'/'+_0x34de73)['json'](_0x30cb68);}return null;};}function patchUpdates(_0x3fdbd5){return function(_0x554b4e){try{jsonpatch['apply'](_0x554b4e,_0x3fdbd5,!![]);}catch(_0x147dbe){return BPromise[_0xf274('0x24')](_0x147dbe);}return _0x554b4e['save']();};}function saveUpdates(_0x85c31a,_0x14087e){return function(_0x1b62f9){if(_0x1b62f9){return _0x1b62f9[_0xf274('0x25')](_0x85c31a)[_0xf274('0x26')](function(_0x35cec0){return _0x35cec0;});}return null;};}function removeEntity(_0x3b0ae4,_0x22cc8b){return function(_0x1e8b12){if(_0x1e8b12){return _0x1e8b12[_0xf274('0x27')]()[_0xf274('0x26')](function(){var _0x137cbc=_0x1e8b12[_0xf274('0x28')]({'plain':!![]});var _0x3f93f4=_0xf274('0x29');return db[_0xf274('0x2a')]['destroy']({'where':{'type':_0x3f93f4,'resourceId':_0x137cbc['id']}})['then'](function(){return _0x1e8b12;});})[_0xf274('0x26')](function(){_0x3b0ae4[_0xf274('0x1d')](0xcc)[_0xf274('0x1e')]();});}};}function handleEntityNotFound(_0x5ead3d,_0x423d89){return function(_0x6f3fe0){if(!_0x6f3fe0){_0x5ead3d[_0xf274('0x1c')](0x194);}return _0x6f3fe0;};}function handleError(_0x39898a,_0x4fd345){_0x4fd345=_0x4fd345||0x1f4;return function(_0x6f706d){logger['error'](_0x6f706d['stack']);if(_0x6f706d['name']){delete _0x6f706d['name'];}_0x39898a[_0xf274('0x1d')](_0x4fd345)['send'](_0x6f706d);};}exports['index']=function(_0x44ecaf,_0x263d00){var _0x5809f1={},_0x31a470={},_0x455637={'count':0x0,'rows':[]};return db[_0xf274('0x2b')][_0xf274('0x2c')]()[_0xf274('0x26')](function(_0xfc6bf5){_0x31a470[_0xf274('0x2d')]=_[_0xf274('0x2e')](_0xfc6bf5);_0x31a470[_0xf274('0x2f')]=_[_0xf274('0x2e')](_0x44ecaf[_0xf274('0x2f')]);_0x31a470['filters']=_[_0xf274('0x30')](_0x31a470[_0xf274('0x2d')],_0x31a470[_0xf274('0x2f')]);_0x5809f1[_0xf274('0x31')]=_[_0xf274('0x30')](_0x31a470[_0xf274('0x2d')],qs[_0xf274('0x32')](_0x44ecaf['query'][_0xf274('0x32')]));_0x5809f1['attributes']=_0x5809f1[_0xf274('0x31')][_0xf274('0x33')]?_0x5809f1[_0xf274('0x31')]:_0x31a470[_0xf274('0x2d')];if(!_0x44ecaf[_0xf274('0x2f')]['hasOwnProperty'](_0xf274('0x34'))){_0x5809f1[_0xf274('0x35')]=qs[_0xf274('0x35')](_0x44ecaf[_0xf274('0x2f')]['limit']);_0x5809f1[_0xf274('0x20')]=qs[_0xf274('0x20')](_0x44ecaf['query'][_0xf274('0x20')]);}_0x5809f1[_0xf274('0x36')]=qs[_0xf274('0x37')](_0x44ecaf[_0xf274('0x2f')][_0xf274('0x37')]);_0x5809f1[_0xf274('0x38')]=qs[_0xf274('0x39')](_['pick'](_0x44ecaf[_0xf274('0x2f')],_0x31a470[_0xf274('0x39')]),_0xfc6bf5);if(_0x44ecaf[_0xf274('0x2f')][_0xf274('0x3a')]){_0x5809f1[_0xf274('0x38')]=_[_0xf274('0x3b')](_0x5809f1[_0xf274('0x38')],{'$or':_[_0xf274('0x3c')](_0x5809f1['attributes'],function(_0xfe6ab8){var _0x1ad012={};_0x1ad012[_0xfe6ab8]={'$like':'%'+_0x44ecaf[_0xf274('0x2f')][_0xf274('0x3a')]+'%'};return _0x1ad012;})});}_0x5809f1=_[_0xf274('0x3b')]({},_0x5809f1,_0x44ecaf[_0xf274('0x3d')]);var _0x13496c={'where':_0x5809f1[_0xf274('0x38')]};return db[_0xf274('0x2b')][_0xf274('0x22')](_0x13496c)['then'](function(_0xe8e622){_0x455637[_0xf274('0x22')]=_0xe8e622;if(_0x44ecaf[_0xf274('0x2f')][_0xf274('0x3e')]){_0x5809f1[_0xf274('0x3f')]=[{'all':!![]}];}return db[_0xf274('0x2b')][_0xf274('0x40')](_0x5809f1);})[_0xf274('0x26')](function(_0x3b6faa){_0x455637[_0xf274('0x41')]=_0x3b6faa;return _0x455637;})[_0xf274('0x26')](respondWithFilteredResult(_0x263d00,_0x5809f1))['catch'](handleError(_0x263d00,null));})['catch'](handleError(_0x263d00,null));};exports['show']=function(_0x2c26fd,_0x1f3416){var _0x420219={'raw':![],'where':{'id':_0x2c26fd[_0xf274('0x42')]['id']}},_0x43b17f={};_0x43b17f[_0xf274('0x2d')]=_[_0xf274('0x2e')](db[_0xf274('0x2b')][_0xf274('0x43')]);_0x43b17f[_0xf274('0x2f')]=_['keys'](_0x2c26fd[_0xf274('0x2f')]);_0x43b17f['filters']=_[_0xf274('0x30')](_0x43b17f[_0xf274('0x2d')],_0x43b17f[_0xf274('0x2f')]);_0x420219['attributes']=_[_0xf274('0x30')](_0x43b17f['model'],qs[_0xf274('0x32')](_0x2c26fd[_0xf274('0x2f')]['fields']));_0x420219[_0xf274('0x31')]=_0x420219[_0xf274('0x31')][_0xf274('0x33')]?_0x420219[_0xf274('0x31')]:_0x43b17f[_0xf274('0x2d')];if(_0x2c26fd['query']['includeAll']){_0x420219[_0xf274('0x3f')]=[{'all':!![]}];}_0x420219=_['merge']({},_0x420219,_0x2c26fd[_0xf274('0x3d')]);return db['CmCompany'][_0xf274('0x44')](_0x420219)[_0xf274('0x26')](handleEntityNotFound(_0x1f3416,null))['then'](respondWithResult(_0x1f3416,null))['catch'](handleError(_0x1f3416,null));};exports[_0xf274('0x45')]=function(_0x181594,_0x1904a7){return db['CmCompany']['create'](_0x181594[_0xf274('0x46')],{})[_0xf274('0x26')](function(_0x2b230a){var _0x1616c8=_0x181594['user'][_0xf274('0x28')]({'plain':!![]});if(!_0x1616c8)throw new Error(_0xf274('0x47'));if(_0x1616c8['role']===_0xf274('0x48')){var _0x34e0c8=_0x2b230a[_0xf274('0x28')]({'plain':!![]});var _0x4b68ae=_0xf274('0x29');return db[_0xf274('0x49')][_0xf274('0x44')]({'where':{'name':_0x4b68ae,'userProfileId':_0x1616c8['userProfileId']},'raw':!![]})[_0xf274('0x26')](function(_0x24f4bf){if(_0x24f4bf&&_0x24f4bf[_0xf274('0x4a')]===0x0){return db['UserProfileResource'][_0xf274('0x45')]({'name':_0x34e0c8[_0xf274('0x4b')],'resourceId':_0x34e0c8['id'],'type':_0x24f4bf[_0xf274('0x4b')],'sectionId':_0x24f4bf['id']},{})[_0xf274('0x26')](function(){return _0x2b230a;});}else{return _0x2b230a;}})[_0xf274('0x4c')](function(_0x2711a5){logger['error'](_0xf274('0x4d'),_0x2711a5);throw _0x2711a5;});}return _0x2b230a;})[_0xf274('0x26')](respondWithResult(_0x1904a7,0xc9))[_0xf274('0x4c')](handleError(_0x1904a7,null));};exports[_0xf274('0x25')]=function(_0xad1e2f,_0x31b06a){if(_0xad1e2f[_0xf274('0x46')]['id']){delete _0xad1e2f[_0xf274('0x46')]['id'];}return db[_0xf274('0x2b')][_0xf274('0x44')]({'where':{'id':_0xad1e2f[_0xf274('0x42')]['id']}})[_0xf274('0x26')](handleEntityNotFound(_0x31b06a,null))[_0xf274('0x26')](saveUpdates(_0xad1e2f[_0xf274('0x46')],null))[_0xf274('0x26')](respondWithResult(_0x31b06a,null))[_0xf274('0x4c')](handleError(_0x31b06a,null));};exports['destroy']=function(_0x53a4ae,_0x343ff7){return db[_0xf274('0x2b')][_0xf274('0x44')]({'where':{'id':_0x53a4ae['params']['id']}})[_0xf274('0x26')](handleEntityNotFound(_0x343ff7,null))['then'](removeEntity(_0x343ff7,null))[_0xf274('0x4c')](handleError(_0x343ff7,null));};exports[_0xf274('0x2c')]=function(_0x4f6f8b,_0xd9b1a7){return db[_0xf274('0x2b')]['describe']()[_0xf274('0x26')](respondWithResult(_0xd9b1a7,null))[_0xf274('0x4c')](handleError(_0xd9b1a7,null));};exports[_0xf274('0x4e')]=function(_0x57c003,_0x5bf5ce,_0x4e4cf6){return db[_0xf274('0x4f')][_0xf274('0x44')]({'where':{'id':_0x57c003[_0xf274('0x42')]['id']}})[_0xf274('0x26')](handleEntityNotFound(_0x5bf5ce,null))[_0xf274('0x26')](function(_0x590764){if(_0x590764){return _0x590764[_0xf274('0x4e')](_0x57c003[_0xf274('0x46')]['ids'],_['omit'](_0x57c003[_0xf274('0x46')],[_0xf274('0x50'),'id'])||{});}})[_0xf274('0x26')](respondWithResult(_0x5bf5ce,null))[_0xf274('0x4c')](handleError(_0x5bf5ce,null));};exports['getContacts']=function(_0x45e3a5,_0x2b8626,_0x6ef802){var _0x4fe88f={};var _0x4473e5={};var _0x4a9d1e;var _0x1e86a5;return db[_0xf274('0x2b')][_0xf274('0x51')]({'where':{'id':_0x45e3a5[_0xf274('0x42')]['id']}})[_0xf274('0x26')](handleEntityNotFound(_0x2b8626,null))[_0xf274('0x26')](function(_0x1c423b){if(_0x1c423b){_0x4a9d1e=_0x1c423b;_0x4473e5[_0xf274('0x2d')]=_[_0xf274('0x2e')](db['CmContact'][_0xf274('0x43')]);_0x4473e5[_0xf274('0x2f')]=_[_0xf274('0x2e')](_0x45e3a5['query']);_0x4473e5[_0xf274('0x39')]=_[_0xf274('0x30')](_0x4473e5['model'],_0x4473e5[_0xf274('0x2f')]);_0x4fe88f[_0xf274('0x31')]=_[_0xf274('0x30')](_0x4473e5[_0xf274('0x2d')],qs[_0xf274('0x32')](_0x45e3a5[_0xf274('0x2f')][_0xf274('0x32')]));_0x4fe88f[_0xf274('0x31')]=_0x4fe88f[_0xf274('0x31')]['length']?_0x4fe88f[_0xf274('0x31')]:_0x4473e5['model'];_0x4fe88f['order']=qs[_0xf274('0x37')](_0x45e3a5[_0xf274('0x2f')][_0xf274('0x37')]);_0x4fe88f[_0xf274('0x38')]=qs[_0xf274('0x39')](_[_0xf274('0x52')](_0x45e3a5[_0xf274('0x2f')],_0x4473e5['filters']));if(_0x45e3a5[_0xf274('0x2f')]['filter']){_0x4fe88f[_0xf274('0x38')]=_[_0xf274('0x3b')](_0x4fe88f['where'],{'$or':_['map'](_0x4fe88f['attributes'],function(_0x25ed71){var _0x4f4a00={};_0x4f4a00[_0x25ed71]={'$like':'%'+_0x45e3a5[_0xf274('0x2f')]['filter']+'%'};return _0x4f4a00;})});}_0x4fe88f=_[_0xf274('0x3b')]({},_0x4fe88f,_0x45e3a5[_0xf274('0x3d')]);return _0x4a9d1e[_0xf274('0x53')](_0x4fe88f);}})[_0xf274('0x26')](function(_0x5976bc){if(_0x5976bc){_0x1e86a5=_0x5976bc[_0xf274('0x33')];if(!_0x45e3a5['query'][_0xf274('0x54')](_0xf274('0x34'))){_0x4fe88f[_0xf274('0x35')]=qs[_0xf274('0x35')](_0x45e3a5[_0xf274('0x2f')]['limit']);_0x4fe88f[_0xf274('0x20')]=qs[_0xf274('0x20')](_0x45e3a5[_0xf274('0x2f')][_0xf274('0x20')]);}return _0x4a9d1e[_0xf274('0x53')](_0x4fe88f);}})[_0xf274('0x26')](function(_0x383f37){if(_0x383f37){return _0x383f37?{'count':_0x1e86a5,'rows':_0x383f37}:null;}})[_0xf274('0x26')](respondWithResult(_0x2b8626,null))[_0xf274('0x4c')](handleError(_0x2b8626,null));};
\ No newline at end of file
+var _0xb9ff=['show','params','rawAttributes','find','create','body','user','UserProfileSection','userProfileId','autoAssociation','CmContact','addContacts','ids','omit','getContacts','findOne','eml-format','rimraf','zip-dir','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','crypto','jsforce','querystring','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','status','json','offset','undefined','limit','Content-Range','apply','save','update','then','destroy','get','Companies','UserProfileResource','error','stack','name','send','index','describe','model','keys','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','map','options','CmCompany','count','includeAll','include','rows','catch'];(function(_0x355515,_0x52573e){var _0x1d829c=function(_0x4a1ad2){while(--_0x4a1ad2){_0x355515['push'](_0x355515['shift']());}};_0x1d829c(++_0x52573e);}(_0xb9ff,0x1be));var _0xfb9f=function(_0x8743ad,_0x2f11a2){_0x8743ad=_0x8743ad-0x0;var _0x247c94=_0xb9ff[_0x8743ad];return _0x247c94;};'use strict';var emlformat=require(_0xfb9f('0x0'));var rimraf=require(_0xfb9f('0x1'));var zipdir=require(_0xfb9f('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xfb9f('0x3'));var Mustache=require(_0xfb9f('0x4'));var util=require(_0xfb9f('0x5'));var path=require(_0xfb9f('0x6'));var sox=require(_0xfb9f('0x7'));var csv=require(_0xfb9f('0x8'));var ejs=require(_0xfb9f('0x9'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xfb9f('0xa'));var squel=require(_0xfb9f('0xb'));var crypto=require(_0xfb9f('0xc'));var jsforce=require(_0xfb9f('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xfb9f('0x8'));var querystring=require(_0xfb9f('0xe'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xfb9f('0xf'));var qs=require(_0xfb9f('0x10'));var as=require(_0xfb9f('0x11'));var hardwareService=require(_0xfb9f('0x12'));var logger=require(_0xfb9f('0x13'))(_0xfb9f('0x14'));var utils=require(_0xfb9f('0x15'));var config=require(_0xfb9f('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xfb9f('0x17'))['db'];function respondWithStatusCode(_0x1cae06,_0x4c8013){_0x4c8013=_0x4c8013||0xcc;return function(_0x29010d){if(_0x29010d){return _0x1cae06[_0xfb9f('0x18')](_0x4c8013);}return _0x1cae06['status'](_0x4c8013)[_0xfb9f('0x19')]();};}function respondWithResult(_0x3c5da9,_0x218d08){_0x218d08=_0x218d08||0xc8;return function(_0x4e2dc9){if(_0x4e2dc9){return _0x3c5da9[_0xfb9f('0x1a')](_0x218d08)[_0xfb9f('0x1b')](_0x4e2dc9);}};}function respondWithFilteredResult(_0x3b4599,_0xbca2a8){return function(_0x346208){if(_0x346208){var _0x55895a=typeof _0xbca2a8[_0xfb9f('0x1c')]===_0xfb9f('0x1d')&&typeof _0xbca2a8[_0xfb9f('0x1e')]===_0xfb9f('0x1d');var _0x879422=_0x346208['count'];var _0x280b16=_0x55895a?0x0:_0xbca2a8['offset'];var _0x55ae32=_0x55895a?_0x346208['count']:_0xbca2a8[_0xfb9f('0x1c')]+_0xbca2a8[_0xfb9f('0x1e')];var _0x457ef5;if(_0x55ae32>=_0x879422){_0x55ae32=_0x879422;_0x457ef5=0xc8;}else{_0x457ef5=0xce;}_0x3b4599[_0xfb9f('0x1a')](_0x457ef5);return _0x3b4599['set'](_0xfb9f('0x1f'),_0x280b16+'-'+_0x55ae32+'/'+_0x879422)[_0xfb9f('0x1b')](_0x346208);}return null;};}function patchUpdates(_0x53b19c){return function(_0x13c50b){try{jsonpatch[_0xfb9f('0x20')](_0x13c50b,_0x53b19c,!![]);}catch(_0x3ceb08){return BPromise['reject'](_0x3ceb08);}return _0x13c50b[_0xfb9f('0x21')]();};}function saveUpdates(_0xc6e325,_0x495630){return function(_0x5332e0){if(_0x5332e0){return _0x5332e0[_0xfb9f('0x22')](_0xc6e325)[_0xfb9f('0x23')](function(_0x1ce5e3){return _0x1ce5e3;});}return null;};}function removeEntity(_0x113767,_0x310420){return function(_0x5c1465){if(_0x5c1465){return _0x5c1465[_0xfb9f('0x24')]()[_0xfb9f('0x23')](function(){var _0x202443=_0x5c1465[_0xfb9f('0x25')]({'plain':!![]});var _0x2ae1ad=_0xfb9f('0x26');return db[_0xfb9f('0x27')][_0xfb9f('0x24')]({'where':{'type':_0x2ae1ad,'resourceId':_0x202443['id']}})[_0xfb9f('0x23')](function(){return _0x5c1465;});})['then'](function(){_0x113767['status'](0xcc)[_0xfb9f('0x19')]();});}};}function handleEntityNotFound(_0x5d0812,_0x37178b){return function(_0x2a6ffa){if(!_0x2a6ffa){_0x5d0812[_0xfb9f('0x18')](0x194);}return _0x2a6ffa;};}function handleError(_0x41b8ac,_0x1835c9){_0x1835c9=_0x1835c9||0x1f4;return function(_0x11a69f){logger[_0xfb9f('0x28')](_0x11a69f[_0xfb9f('0x29')]);if(_0x11a69f[_0xfb9f('0x2a')]){delete _0x11a69f[_0xfb9f('0x2a')];}_0x41b8ac[_0xfb9f('0x1a')](_0x1835c9)[_0xfb9f('0x2b')](_0x11a69f);};}exports[_0xfb9f('0x2c')]=function(_0x15e3b8,_0x4a5a59){var _0x38227c={},_0x2caccc={},_0x125fa9={'count':0x0,'rows':[]};return db['CmCompany'][_0xfb9f('0x2d')]()[_0xfb9f('0x23')](function(_0x4caffc){_0x2caccc[_0xfb9f('0x2e')]=_[_0xfb9f('0x2f')](_0x4caffc);_0x2caccc[_0xfb9f('0x30')]=_[_0xfb9f('0x2f')](_0x15e3b8[_0xfb9f('0x30')]);_0x2caccc[_0xfb9f('0x31')]=_[_0xfb9f('0x32')](_0x2caccc[_0xfb9f('0x2e')],_0x2caccc[_0xfb9f('0x30')]);_0x38227c['attributes']=_['intersection'](_0x2caccc['model'],qs[_0xfb9f('0x33')](_0x15e3b8['query'][_0xfb9f('0x33')]));_0x38227c[_0xfb9f('0x34')]=_0x38227c[_0xfb9f('0x34')][_0xfb9f('0x35')]?_0x38227c[_0xfb9f('0x34')]:_0x2caccc[_0xfb9f('0x2e')];if(!_0x15e3b8['query'][_0xfb9f('0x36')](_0xfb9f('0x37'))){_0x38227c[_0xfb9f('0x1e')]=qs['limit'](_0x15e3b8['query']['limit']);_0x38227c[_0xfb9f('0x1c')]=qs[_0xfb9f('0x1c')](_0x15e3b8['query'][_0xfb9f('0x1c')]);}_0x38227c[_0xfb9f('0x38')]=qs[_0xfb9f('0x39')](_0x15e3b8[_0xfb9f('0x30')][_0xfb9f('0x39')]);_0x38227c[_0xfb9f('0x3a')]=qs['filters'](_[_0xfb9f('0x3b')](_0x15e3b8['query'],_0x2caccc['filters']),_0x4caffc);if(_0x15e3b8[_0xfb9f('0x30')][_0xfb9f('0x3c')]){_0x38227c[_0xfb9f('0x3a')]=_[_0xfb9f('0x3d')](_0x38227c[_0xfb9f('0x3a')],{'$or':_[_0xfb9f('0x3e')](_0x38227c[_0xfb9f('0x34')],function(_0x3dd83e){var _0x340916={};_0x340916[_0x3dd83e]={'$like':'%'+_0x15e3b8['query'][_0xfb9f('0x3c')]+'%'};return _0x340916;})});}_0x38227c=_['merge']({},_0x38227c,_0x15e3b8[_0xfb9f('0x3f')]);var _0x39ce9f={'where':_0x38227c['where']};return db[_0xfb9f('0x40')][_0xfb9f('0x41')](_0x39ce9f)[_0xfb9f('0x23')](function(_0x4b2c9e){_0x125fa9[_0xfb9f('0x41')]=_0x4b2c9e;if(_0x15e3b8[_0xfb9f('0x30')][_0xfb9f('0x42')]){_0x38227c[_0xfb9f('0x43')]=[{'all':!![]}];}return db[_0xfb9f('0x40')]['findAll'](_0x38227c);})[_0xfb9f('0x23')](function(_0x9fa60a){_0x125fa9[_0xfb9f('0x44')]=_0x9fa60a;return _0x125fa9;})['then'](respondWithFilteredResult(_0x4a5a59,_0x38227c))[_0xfb9f('0x45')](handleError(_0x4a5a59,null));})[_0xfb9f('0x45')](handleError(_0x4a5a59,null));};exports[_0xfb9f('0x46')]=function(_0x255e2f,_0x286713){var _0x42e094={'raw':![],'where':{'id':_0x255e2f[_0xfb9f('0x47')]['id']}},_0x243940={};_0x243940['model']=_[_0xfb9f('0x2f')](db[_0xfb9f('0x40')][_0xfb9f('0x48')]);_0x243940[_0xfb9f('0x30')]=_[_0xfb9f('0x2f')](_0x255e2f['query']);_0x243940[_0xfb9f('0x31')]=_[_0xfb9f('0x32')](_0x243940[_0xfb9f('0x2e')],_0x243940[_0xfb9f('0x30')]);_0x42e094[_0xfb9f('0x34')]=_[_0xfb9f('0x32')](_0x243940[_0xfb9f('0x2e')],qs[_0xfb9f('0x33')](_0x255e2f[_0xfb9f('0x30')][_0xfb9f('0x33')]));_0x42e094[_0xfb9f('0x34')]=_0x42e094[_0xfb9f('0x34')][_0xfb9f('0x35')]?_0x42e094[_0xfb9f('0x34')]:_0x243940[_0xfb9f('0x2e')];if(_0x255e2f[_0xfb9f('0x30')][_0xfb9f('0x42')]){_0x42e094[_0xfb9f('0x43')]=[{'all':!![]}];}_0x42e094=_[_0xfb9f('0x3d')]({},_0x42e094,_0x255e2f[_0xfb9f('0x3f')]);return db[_0xfb9f('0x40')][_0xfb9f('0x49')](_0x42e094)['then'](handleEntityNotFound(_0x286713,null))[_0xfb9f('0x23')](respondWithResult(_0x286713,null))[_0xfb9f('0x45')](handleError(_0x286713,null));};exports[_0xfb9f('0x4a')]=function(_0x41cd3d,_0x36e522){return db['CmCompany'][_0xfb9f('0x4a')](_0x41cd3d[_0xfb9f('0x4b')],{})[_0xfb9f('0x23')](function(_0x3b2719){var _0x456422=_0x41cd3d[_0xfb9f('0x4c')]['get']({'plain':!![]});if(!_0x456422)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x456422['role']===_0xfb9f('0x4c')){var _0x311ee1=_0x3b2719[_0xfb9f('0x25')]({'plain':!![]});var _0x1bfcd0=_0xfb9f('0x26');return db[_0xfb9f('0x4d')]['find']({'where':{'name':_0x1bfcd0,'userProfileId':_0x456422[_0xfb9f('0x4e')]},'raw':!![]})['then'](function(_0x30fefe){if(_0x30fefe&&_0x30fefe[_0xfb9f('0x4f')]===0x0){return db[_0xfb9f('0x27')][_0xfb9f('0x4a')]({'name':_0x311ee1[_0xfb9f('0x2a')],'resourceId':_0x311ee1['id'],'type':_0x30fefe[_0xfb9f('0x2a')],'sectionId':_0x30fefe['id']},{})['then'](function(){return _0x3b2719;});}else{return _0x3b2719;}})[_0xfb9f('0x45')](function(_0xa61db0){logger[_0xfb9f('0x28')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0xa61db0);throw _0xa61db0;});}return _0x3b2719;})['then'](respondWithResult(_0x36e522,0xc9))[_0xfb9f('0x45')](handleError(_0x36e522,null));};exports[_0xfb9f('0x22')]=function(_0x280c0b,_0x171c24){if(_0x280c0b[_0xfb9f('0x4b')]['id']){delete _0x280c0b[_0xfb9f('0x4b')]['id'];}return db[_0xfb9f('0x40')][_0xfb9f('0x49')]({'where':{'id':_0x280c0b[_0xfb9f('0x47')]['id']}})['then'](handleEntityNotFound(_0x171c24,null))[_0xfb9f('0x23')](saveUpdates(_0x280c0b[_0xfb9f('0x4b')],null))['then'](respondWithResult(_0x171c24,null))[_0xfb9f('0x45')](handleError(_0x171c24,null));};exports[_0xfb9f('0x24')]=function(_0x3096dc,_0x36371a){return db['CmCompany'][_0xfb9f('0x49')]({'where':{'id':_0x3096dc[_0xfb9f('0x47')]['id']}})[_0xfb9f('0x23')](handleEntityNotFound(_0x36371a,null))[_0xfb9f('0x23')](removeEntity(_0x36371a,null))[_0xfb9f('0x45')](handleError(_0x36371a,null));};exports[_0xfb9f('0x2d')]=function(_0x240a89,_0x4a920f){return db[_0xfb9f('0x40')][_0xfb9f('0x2d')]()[_0xfb9f('0x23')](respondWithResult(_0x4a920f,null))['catch'](handleError(_0x4a920f,null));};exports['addContacts']=function(_0x80f03b,_0x58b562,_0x31eaf9){return db[_0xfb9f('0x50')][_0xfb9f('0x49')]({'where':{'id':_0x80f03b['params']['id']}})['then'](handleEntityNotFound(_0x58b562,null))[_0xfb9f('0x23')](function(_0x4db8f3){if(_0x4db8f3){return _0x4db8f3[_0xfb9f('0x51')](_0x80f03b[_0xfb9f('0x4b')][_0xfb9f('0x52')],_[_0xfb9f('0x53')](_0x80f03b['body'],[_0xfb9f('0x52'),'id'])||{});}})[_0xfb9f('0x23')](respondWithResult(_0x58b562,null))[_0xfb9f('0x45')](handleError(_0x58b562,null));};exports[_0xfb9f('0x54')]=function(_0x38cdf9,_0x25e4af,_0xfd353b){var _0x2e3176={};var _0x3505e6={};var _0x11225b;var _0x1c5c2e;return db[_0xfb9f('0x40')][_0xfb9f('0x55')]({'where':{'id':_0x38cdf9[_0xfb9f('0x47')]['id']}})[_0xfb9f('0x23')](handleEntityNotFound(_0x25e4af,null))['then'](function(_0x25e291){if(_0x25e291){_0x11225b=_0x25e291;_0x3505e6[_0xfb9f('0x2e')]=_['keys'](db['CmContact'][_0xfb9f('0x48')]);_0x3505e6[_0xfb9f('0x30')]=_[_0xfb9f('0x2f')](_0x38cdf9['query']);_0x3505e6[_0xfb9f('0x31')]=_[_0xfb9f('0x32')](_0x3505e6[_0xfb9f('0x2e')],_0x3505e6['query']);_0x2e3176[_0xfb9f('0x34')]=_[_0xfb9f('0x32')](_0x3505e6[_0xfb9f('0x2e')],qs[_0xfb9f('0x33')](_0x38cdf9[_0xfb9f('0x30')]['fields']));_0x2e3176[_0xfb9f('0x34')]=_0x2e3176[_0xfb9f('0x34')][_0xfb9f('0x35')]?_0x2e3176['attributes']:_0x3505e6[_0xfb9f('0x2e')];_0x2e3176[_0xfb9f('0x38')]=qs[_0xfb9f('0x39')](_0x38cdf9[_0xfb9f('0x30')][_0xfb9f('0x39')]);_0x2e3176['where']=qs[_0xfb9f('0x31')](_[_0xfb9f('0x3b')](_0x38cdf9['query'],_0x3505e6['filters']));if(_0x38cdf9['query']['filter']){_0x2e3176['where']=_['merge'](_0x2e3176[_0xfb9f('0x3a')],{'$or':_[_0xfb9f('0x3e')](_0x2e3176[_0xfb9f('0x34')],function(_0x24860a){var _0x153af9={};_0x153af9[_0x24860a]={'$like':'%'+_0x38cdf9[_0xfb9f('0x30')][_0xfb9f('0x3c')]+'%'};return _0x153af9;})});}_0x2e3176=_[_0xfb9f('0x3d')]({},_0x2e3176,_0x38cdf9[_0xfb9f('0x3f')]);return _0x11225b[_0xfb9f('0x54')](_0x2e3176);}})[_0xfb9f('0x23')](function(_0x1cf92f){if(_0x1cf92f){_0x1c5c2e=_0x1cf92f[_0xfb9f('0x35')];if(!_0x38cdf9['query']['hasOwnProperty'](_0xfb9f('0x37'))){_0x2e3176[_0xfb9f('0x1e')]=qs[_0xfb9f('0x1e')](_0x38cdf9['query'][_0xfb9f('0x1e')]);_0x2e3176[_0xfb9f('0x1c')]=qs[_0xfb9f('0x1c')](_0x38cdf9[_0xfb9f('0x30')][_0xfb9f('0x1c')]);}return _0x11225b[_0xfb9f('0x54')](_0x2e3176);}})[_0xfb9f('0x23')](function(_0x3ca102){if(_0x3ca102){return _0x3ca102?{'count':_0x1c5c2e,'rows':_0x3ca102}:null;}})[_0xfb9f('0x23')](respondWithResult(_0x25e4af,null))[_0xfb9f('0x45')](handleError(_0x25e4af,null));};
\ No newline at end of file