Built motion from commit (unavailable).|2.6.0
[motion2.git] / server / api / cmCompany / cmCompany.controller.js
index ddbbe56..446764f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x757a=['../../config/license/hardware','../../config/logger','api','status','json','offset','undefined','count','limit','Content-Range','apply','update','then','get','Companies','UserProfileResource','destroy','end','error','name','send','CmCompany','describe','model','keys','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','map','merge','options','includeAll','findAll','rows','catch','params','rawAttributes','find','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','create','addContacts','CmContact','omit','ids','getContacts','findOne','rimraf','zip-dir','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch'];(function(_0x1118c3,_0x3d90ac){var _0x4a651a=function(_0x2d6164){while(--_0x2d6164){_0x1118c3['push'](_0x1118c3['shift']());}};_0x4a651a(++_0x3d90ac);}(_0x757a,0xde));var _0xa757=function(_0x288ead,_0x1fd214){_0x288ead=_0x288ead-0x0;var _0x4d6b59=_0x757a[_0x288ead];return _0x4d6b59;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xa757('0x0'));var zipdir=require(_0xa757('0x1'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xa757('0x2'));var Mustache=require(_0xa757('0x3'));var util=require(_0xa757('0x4'));var path=require(_0xa757('0x5'));var sox=require(_0xa757('0x6'));var csv=require(_0xa757('0x7'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0xa757('0x8'));var _=require(_0xa757('0x9'));var squel=require('squel');var crypto=require(_0xa757('0xa'));var jsforce=require(_0xa757('0xb'));var deskjs=require(_0xa757('0xc'));var toCsv=require(_0xa757('0x7'));var querystring=require(_0xa757('0xd'));var Papa=require('papaparse');var Redis=require(_0xa757('0xe'));var authService=require(_0xa757('0xf'));var qs=require(_0xa757('0x10'));var as=require(_0xa757('0x11'));var hardwareService=require(_0xa757('0x12'));var logger=require(_0xa757('0x13'))(_0xa757('0x14'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x4db68e,_0x421040){_0x421040=_0x421040||0xcc;return function(_0x544b45){if(_0x544b45){return _0x4db68e['sendStatus'](_0x421040);}return _0x4db68e[_0xa757('0x15')](_0x421040)['end']();};}function respondWithResult(_0x481508,_0x32112b){_0x32112b=_0x32112b||0xc8;return function(_0x1b670e){if(_0x1b670e){return _0x481508[_0xa757('0x15')](_0x32112b)[_0xa757('0x16')](_0x1b670e);}};}function respondWithFilteredResult(_0x86abd,_0x31cfd2){return function(_0xf12b68){if(_0xf12b68){var _0x2f7947=typeof _0x31cfd2[_0xa757('0x17')]===_0xa757('0x18')&&typeof _0x31cfd2['limit']===_0xa757('0x18');var _0x44eab8=_0xf12b68[_0xa757('0x19')];var _0x4d9f58=_0x2f7947?0x0:_0x31cfd2['offset'];var _0x151c04=_0x2f7947?_0xf12b68[_0xa757('0x19')]:_0x31cfd2[_0xa757('0x17')]+_0x31cfd2[_0xa757('0x1a')];var _0x27f4ba;if(_0x151c04>=_0x44eab8){_0x151c04=_0x44eab8;_0x27f4ba=0xc8;}else{_0x27f4ba=0xce;}_0x86abd[_0xa757('0x15')](_0x27f4ba);return _0x86abd['set'](_0xa757('0x1b'),_0x4d9f58+'-'+_0x151c04+'/'+_0x44eab8)['json'](_0xf12b68);}return null;};}function patchUpdates(_0x32c2a1){return function(_0x167640){try{jsonpatch[_0xa757('0x1c')](_0x167640,_0x32c2a1,!![]);}catch(_0x2c9ec6){return BPromise['reject'](_0x2c9ec6);}return _0x167640['save']();};}function saveUpdates(_0x40ec48,_0x2159cf){return function(_0x2ba923){if(_0x2ba923){return _0x2ba923[_0xa757('0x1d')](_0x40ec48)[_0xa757('0x1e')](function(_0x40562f){return _0x40562f;});}return null;};}function removeEntity(_0x2ca10d,_0x21f1af){return function(_0x2bf276){if(_0x2bf276){return _0x2bf276['destroy']()[_0xa757('0x1e')](function(){var _0x59e9d4=_0x2bf276[_0xa757('0x1f')]({'plain':!![]});var _0x47903b=_0xa757('0x20');return db[_0xa757('0x21')][_0xa757('0x22')]({'where':{'type':_0x47903b,'resourceId':_0x59e9d4['id']}})['then'](function(){return _0x2bf276;});})[_0xa757('0x1e')](function(){_0x2ca10d[_0xa757('0x15')](0xcc)[_0xa757('0x23')]();});}};}function handleEntityNotFound(_0x3bf7f3,_0x5b4779){return function(_0x449a7d){if(!_0x449a7d){_0x3bf7f3['sendStatus'](0x194);}return _0x449a7d;};}function handleError(_0x5a5664,_0x54b75e){_0x54b75e=_0x54b75e||0x1f4;return function(_0x4f8de2){logger[_0xa757('0x24')](_0x4f8de2['stack']);if(_0x4f8de2[_0xa757('0x25')]){delete _0x4f8de2[_0xa757('0x25')];}_0x5a5664['status'](_0x54b75e)[_0xa757('0x26')](_0x4f8de2);};}exports['index']=function(_0x2c4823,_0xa6d0f6){var _0x5307c3={},_0x235e54={},_0x5ade7b={'count':0x0,'rows':[]};return db[_0xa757('0x27')][_0xa757('0x28')]()[_0xa757('0x1e')](function(_0x300dc4){_0x235e54[_0xa757('0x29')]=_[_0xa757('0x2a')](_0x300dc4);_0x235e54[_0xa757('0x2b')]=_[_0xa757('0x2a')](_0x2c4823[_0xa757('0x2b')]);_0x235e54[_0xa757('0x2c')]=_[_0xa757('0x2d')](_0x235e54[_0xa757('0x29')],_0x235e54[_0xa757('0x2b')]);_0x5307c3[_0xa757('0x2e')]=_[_0xa757('0x2d')](_0x235e54[_0xa757('0x29')],qs[_0xa757('0x2f')](_0x2c4823[_0xa757('0x2b')][_0xa757('0x2f')]));_0x5307c3[_0xa757('0x2e')]=_0x5307c3[_0xa757('0x2e')][_0xa757('0x30')]?_0x5307c3[_0xa757('0x2e')]:_0x235e54[_0xa757('0x29')];if(!_0x2c4823['query'][_0xa757('0x31')](_0xa757('0x32'))){_0x5307c3[_0xa757('0x1a')]=qs[_0xa757('0x1a')](_0x2c4823[_0xa757('0x2b')]['limit']);_0x5307c3[_0xa757('0x17')]=qs[_0xa757('0x17')](_0x2c4823[_0xa757('0x2b')][_0xa757('0x17')]);}_0x5307c3[_0xa757('0x33')]=qs[_0xa757('0x34')](_0x2c4823['query'][_0xa757('0x34')]);_0x5307c3[_0xa757('0x35')]=qs[_0xa757('0x2c')](_[_0xa757('0x36')](_0x2c4823[_0xa757('0x2b')],_0x235e54[_0xa757('0x2c')]),_0x300dc4);if(_0x2c4823[_0xa757('0x2b')][_0xa757('0x37')]){_0x5307c3[_0xa757('0x35')]=_['merge'](_0x5307c3[_0xa757('0x35')],{'$or':_[_0xa757('0x38')](_0x5307c3[_0xa757('0x2e')],function(_0x35c15a){var _0x2531be={};_0x2531be[_0x35c15a]={'$like':'%'+_0x2c4823[_0xa757('0x2b')]['filter']+'%'};return _0x2531be;})});}_0x5307c3=_[_0xa757('0x39')]({},_0x5307c3,_0x2c4823[_0xa757('0x3a')]);var _0x48cde9={'where':_0x5307c3['where']};return db[_0xa757('0x27')][_0xa757('0x19')](_0x48cde9)['then'](function(_0x51c3d1){_0x5ade7b[_0xa757('0x19')]=_0x51c3d1;if(_0x2c4823[_0xa757('0x2b')][_0xa757('0x3b')]){_0x5307c3['include']=[{'all':!![]}];}return db[_0xa757('0x27')][_0xa757('0x3c')](_0x5307c3);})[_0xa757('0x1e')](function(_0x1ba399){_0x5ade7b[_0xa757('0x3d')]=_0x1ba399;return _0x5ade7b;})['then'](respondWithFilteredResult(_0xa6d0f6,_0x5307c3))[_0xa757('0x3e')](handleError(_0xa6d0f6,null));})['catch'](handleError(_0xa6d0f6,null));};exports['show']=function(_0x43329c,_0x57298b){var _0x373747={'raw':![],'where':{'id':_0x43329c[_0xa757('0x3f')]['id']}},_0x626b1f={};_0x626b1f['model']=_['keys'](db[_0xa757('0x27')][_0xa757('0x40')]);_0x626b1f[_0xa757('0x2b')]=_[_0xa757('0x2a')](_0x43329c[_0xa757('0x2b')]);_0x626b1f[_0xa757('0x2c')]=_['intersection'](_0x626b1f[_0xa757('0x29')],_0x626b1f[_0xa757('0x2b')]);_0x373747['attributes']=_[_0xa757('0x2d')](_0x626b1f['model'],qs[_0xa757('0x2f')](_0x43329c[_0xa757('0x2b')]['fields']));_0x373747[_0xa757('0x2e')]=_0x373747[_0xa757('0x2e')]['length']?_0x373747[_0xa757('0x2e')]:_0x626b1f[_0xa757('0x29')];if(_0x43329c[_0xa757('0x2b')][_0xa757('0x3b')]){_0x373747['include']=[{'all':!![]}];}_0x373747=_[_0xa757('0x39')]({},_0x373747,_0x43329c[_0xa757('0x3a')]);return db[_0xa757('0x27')][_0xa757('0x41')](_0x373747)['then'](handleEntityNotFound(_0x57298b,null))[_0xa757('0x1e')](respondWithResult(_0x57298b,null))['catch'](handleError(_0x57298b,null));};exports['create']=function(_0x2acf88,_0x3c039d){return db[_0xa757('0x27')]['create'](_0x2acf88[_0xa757('0x42')],{})['then'](function(_0x2ed63f){var _0x151cc3=_0x2acf88[_0xa757('0x43')][_0xa757('0x1f')]({'plain':!![]});if(!_0x151cc3)throw new Error(_0xa757('0x44'));if(_0x151cc3[_0xa757('0x45')]===_0xa757('0x43')){var _0x505cd=_0x2ed63f['get']({'plain':!![]});var _0x2de226=_0xa757('0x20');return db[_0xa757('0x46')][_0xa757('0x41')]({'where':{'name':_0x2de226,'userProfileId':_0x151cc3[_0xa757('0x47')]},'raw':!![]})[_0xa757('0x1e')](function(_0x15bad7){if(_0x15bad7&&_0x15bad7[_0xa757('0x48')]===0x0){return db[_0xa757('0x21')][_0xa757('0x49')]({'name':_0x505cd[_0xa757('0x25')],'resourceId':_0x505cd['id'],'type':_0x15bad7[_0xa757('0x25')],'sectionId':_0x15bad7['id']},{})[_0xa757('0x1e')](function(){return _0x2ed63f;});}else{return _0x2ed63f;}})[_0xa757('0x3e')](function(_0x388573){logger[_0xa757('0x24')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x388573);throw _0x388573;});}return _0x2ed63f;})[_0xa757('0x1e')](respondWithResult(_0x3c039d,0xc9))['catch'](handleError(_0x3c039d,null));};exports[_0xa757('0x1d')]=function(_0x311c25,_0xa89d24){if(_0x311c25[_0xa757('0x42')]['id']){delete _0x311c25['body']['id'];}return db[_0xa757('0x27')][_0xa757('0x41')]({'where':{'id':_0x311c25[_0xa757('0x3f')]['id']}})[_0xa757('0x1e')](handleEntityNotFound(_0xa89d24,null))['then'](saveUpdates(_0x311c25[_0xa757('0x42')],null))[_0xa757('0x1e')](respondWithResult(_0xa89d24,null))[_0xa757('0x3e')](handleError(_0xa89d24,null));};exports[_0xa757('0x22')]=function(_0x33666d,_0x291b26){return db['CmCompany']['find']({'where':{'id':_0x33666d['params']['id']}})['then'](handleEntityNotFound(_0x291b26,null))[_0xa757('0x1e')](removeEntity(_0x291b26,null))[_0xa757('0x3e')](handleError(_0x291b26,null));};exports[_0xa757('0x28')]=function(_0x32313b,_0x1e31ef){return db[_0xa757('0x27')]['describe']()[_0xa757('0x1e')](respondWithResult(_0x1e31ef,null))[_0xa757('0x3e')](handleError(_0x1e31ef,null));};exports[_0xa757('0x4a')]=function(_0x29b2f5,_0x48b578,_0x26c74e){return db[_0xa757('0x4b')]['find']({'where':{'id':_0x29b2f5[_0xa757('0x3f')]['id']}})['then'](handleEntityNotFound(_0x48b578,null))[_0xa757('0x1e')](function(_0x5d375c){if(_0x5d375c){return _0x5d375c[_0xa757('0x4a')](_0x29b2f5['body']['ids'],_[_0xa757('0x4c')](_0x29b2f5[_0xa757('0x42')],[_0xa757('0x4d'),'id'])||{});}})[_0xa757('0x1e')](respondWithResult(_0x48b578,null))[_0xa757('0x3e')](handleError(_0x48b578,null));};exports[_0xa757('0x4e')]=function(_0x4c19a6,_0x4f0d7b,_0x201557){var _0x3afa56={};var _0x3ca1ef={};var _0x4a5ad5;var _0x55a7d2;return db[_0xa757('0x27')][_0xa757('0x4f')]({'where':{'id':_0x4c19a6[_0xa757('0x3f')]['id']}})[_0xa757('0x1e')](handleEntityNotFound(_0x4f0d7b,null))[_0xa757('0x1e')](function(_0x3e6d40){if(_0x3e6d40){_0x4a5ad5=_0x3e6d40;_0x3ca1ef['model']=_[_0xa757('0x2a')](db[_0xa757('0x4b')][_0xa757('0x40')]);_0x3ca1ef[_0xa757('0x2b')]=_[_0xa757('0x2a')](_0x4c19a6[_0xa757('0x2b')]);_0x3ca1ef[_0xa757('0x2c')]=_[_0xa757('0x2d')](_0x3ca1ef[_0xa757('0x29')],_0x3ca1ef[_0xa757('0x2b')]);_0x3afa56['attributes']=_[_0xa757('0x2d')](_0x3ca1ef['model'],qs['fields'](_0x4c19a6[_0xa757('0x2b')][_0xa757('0x2f')]));_0x3afa56[_0xa757('0x2e')]=_0x3afa56[_0xa757('0x2e')][_0xa757('0x30')]?_0x3afa56[_0xa757('0x2e')]:_0x3ca1ef[_0xa757('0x29')];_0x3afa56[_0xa757('0x33')]=qs[_0xa757('0x34')](_0x4c19a6[_0xa757('0x2b')][_0xa757('0x34')]);_0x3afa56['where']=qs[_0xa757('0x2c')](_[_0xa757('0x36')](_0x4c19a6['query'],_0x3ca1ef[_0xa757('0x2c')]));if(_0x4c19a6[_0xa757('0x2b')][_0xa757('0x37')]){_0x3afa56[_0xa757('0x35')]=_[_0xa757('0x39')](_0x3afa56[_0xa757('0x35')],{'$or':_['map'](_0x3afa56[_0xa757('0x2e')],function(_0x4ab31d){var _0xee5b78={};_0xee5b78[_0x4ab31d]={'$like':'%'+_0x4c19a6[_0xa757('0x2b')][_0xa757('0x37')]+'%'};return _0xee5b78;})});}_0x3afa56=_[_0xa757('0x39')]({},_0x3afa56,_0x4c19a6[_0xa757('0x3a')]);return _0x4a5ad5['getContacts'](_0x3afa56);}})['then'](function(_0x1c8807){if(_0x1c8807){_0x55a7d2=_0x1c8807[_0xa757('0x30')];if(!_0x4c19a6[_0xa757('0x2b')]['hasOwnProperty'](_0xa757('0x32'))){_0x3afa56['limit']=qs[_0xa757('0x1a')](_0x4c19a6[_0xa757('0x2b')][_0xa757('0x1a')]);_0x3afa56[_0xa757('0x17')]=qs[_0xa757('0x17')](_0x4c19a6[_0xa757('0x2b')]['offset']);}return _0x4a5ad5[_0xa757('0x4e')](_0x3afa56);}})[_0xa757('0x1e')](function(_0x1e15ee){if(_0x1e15ee){return _0x1e15ee?{'count':_0x55a7d2,'rows':_0x1e15ee}:null;}})[_0xa757('0x1e')](respondWithResult(_0x4f0d7b,null))[_0xa757('0x3e')](handleError(_0x4f0d7b,null));};
\ No newline at end of file
+var _0x0b0e=['fields','length','hasOwnProperty','nolimit','order','pick','filter','where','merge','map','options','CmCompany','count','include','findAll','rows','catch','show','params','rawAttributes','includeAll','create','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','Companies','UserProfileSection','find','userProfileId','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','body','addContacts','CmContact','ids','omit','getContacts','findOne','sort','eml-format','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','end','status','undefined','offset','limit','set','json','apply','reject','save','then','destroy','UserProfileResource','stack','name','send','index','describe','model','keys','query','filters','intersection','attributes'];(function(_0x4825ce,_0x3cdc1b){var _0x264411=function(_0x3ece82){while(--_0x3ece82){_0x4825ce['push'](_0x4825ce['shift']());}};_0x264411(++_0x3cdc1b);}(_0x0b0e,0x187));var _0xe0b0=function(_0x319fc1,_0x29179b){_0x319fc1=_0x319fc1-0x0;var _0xb768af=_0x0b0e[_0x319fc1];return _0xb768af;};'use strict';var emlformat=require(_0xe0b0('0x0'));var rimraf=require('rimraf');var zipdir=require(_0xe0b0('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xe0b0('0x2'));var moment=require(_0xe0b0('0x3'));var BPromise=require(_0xe0b0('0x4'));var Mustache=require(_0xe0b0('0x5'));var util=require(_0xe0b0('0x6'));var path=require(_0xe0b0('0x7'));var sox=require(_0xe0b0('0x8'));var csv=require(_0xe0b0('0x9'));var ejs=require(_0xe0b0('0xa'));var fs=require('fs');var fs_extra=require(_0xe0b0('0xb'));var _=require(_0xe0b0('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0xe0b0('0xd'));var deskjs=require(_0xe0b0('0xe'));var toCsv=require(_0xe0b0('0x9'));var querystring=require(_0xe0b0('0xf'));var Papa=require('papaparse');var Redis=require(_0xe0b0('0x10'));var authService=require(_0xe0b0('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0xe0b0('0x12'));var hardwareService=require(_0xe0b0('0x13'));var logger=require('../../config/logger')(_0xe0b0('0x14'));var utils=require(_0xe0b0('0x15'));var config=require(_0xe0b0('0x16'));var licenseUtil=require('../../config/license/util');var db=require(_0xe0b0('0x17'))['db'];function respondWithStatusCode(_0x1c358a,_0x3cc19a){_0x3cc19a=_0x3cc19a||0xcc;return function(_0x45f914){if(_0x45f914){return _0x1c358a[_0xe0b0('0x18')](_0x3cc19a);}return _0x1c358a['status'](_0x3cc19a)[_0xe0b0('0x19')]();};}function respondWithResult(_0x154de6,_0x743318){_0x743318=_0x743318||0xc8;return function(_0x24babd){if(_0x24babd){return _0x154de6[_0xe0b0('0x1a')](_0x743318)['json'](_0x24babd);}};}function respondWithFilteredResult(_0x41a7e2,_0x5adb01){return function(_0x35cb40){if(_0x35cb40){var _0xadee6e=typeof _0x5adb01['offset']===_0xe0b0('0x1b')&&typeof _0x5adb01['limit']===_0xe0b0('0x1b');var _0x100204=_0x35cb40['count'];var _0x54a3eb=_0xadee6e?0x0:_0x5adb01[_0xe0b0('0x1c')];var _0x50a441=_0xadee6e?_0x35cb40['count']:_0x5adb01['offset']+_0x5adb01[_0xe0b0('0x1d')];var _0x50fa4a;if(_0x50a441>=_0x100204){_0x50a441=_0x100204;_0x50fa4a=0xc8;}else{_0x50fa4a=0xce;}_0x41a7e2['status'](_0x50fa4a);return _0x41a7e2[_0xe0b0('0x1e')]('Content-Range',_0x54a3eb+'-'+_0x50a441+'/'+_0x100204)[_0xe0b0('0x1f')](_0x35cb40);}return null;};}function patchUpdates(_0x5dba2f){return function(_0x2c84cc){try{jsonpatch[_0xe0b0('0x20')](_0x2c84cc,_0x5dba2f,!![]);}catch(_0x3e10b3){return BPromise[_0xe0b0('0x21')](_0x3e10b3);}return _0x2c84cc[_0xe0b0('0x22')]();};}function saveUpdates(_0x58b804,_0x4cae54){return function(_0x2fa820){if(_0x2fa820){return _0x2fa820['update'](_0x58b804)[_0xe0b0('0x23')](function(_0x31b5f8){return _0x31b5f8;});}return null;};}function removeEntity(_0x513e63,_0x170ad8){return function(_0x503883){if(_0x503883){return _0x503883[_0xe0b0('0x24')]()['then'](function(){var _0x28586d=_0x503883['get']({'plain':!![]});var _0x3e5c88='Companies';return db[_0xe0b0('0x25')]['destroy']({'where':{'type':_0x3e5c88,'resourceId':_0x28586d['id']}})[_0xe0b0('0x23')](function(){return _0x503883;});})['then'](function(){_0x513e63[_0xe0b0('0x1a')](0xcc)[_0xe0b0('0x19')]();});}};}function handleEntityNotFound(_0x1f1ebd,_0x1d91ad){return function(_0x3ec2){if(!_0x3ec2){_0x1f1ebd[_0xe0b0('0x18')](0x194);}return _0x3ec2;};}function handleError(_0x5200a6,_0x1444b9){_0x1444b9=_0x1444b9||0x1f4;return function(_0x1b8aa8){logger['error'](_0x1b8aa8[_0xe0b0('0x26')]);if(_0x1b8aa8[_0xe0b0('0x27')]){delete _0x1b8aa8[_0xe0b0('0x27')];}_0x5200a6[_0xe0b0('0x1a')](_0x1444b9)[_0xe0b0('0x28')](_0x1b8aa8);};}exports[_0xe0b0('0x29')]=function(_0x136bd4,_0x4fb3b7){var _0x1854b8={},_0x3c0109={},_0x48a9b5={'count':0x0,'rows':[]};return db['CmCompany'][_0xe0b0('0x2a')]()[_0xe0b0('0x23')](function(_0x422575){_0x3c0109[_0xe0b0('0x2b')]=_[_0xe0b0('0x2c')](_0x422575);_0x3c0109['query']=_[_0xe0b0('0x2c')](_0x136bd4[_0xe0b0('0x2d')]);_0x3c0109[_0xe0b0('0x2e')]=_[_0xe0b0('0x2f')](_0x3c0109[_0xe0b0('0x2b')],_0x3c0109['query']);_0x1854b8[_0xe0b0('0x30')]=_[_0xe0b0('0x2f')](_0x3c0109[_0xe0b0('0x2b')],qs[_0xe0b0('0x31')](_0x136bd4[_0xe0b0('0x2d')][_0xe0b0('0x31')]));_0x1854b8[_0xe0b0('0x30')]=_0x1854b8[_0xe0b0('0x30')][_0xe0b0('0x32')]?_0x1854b8[_0xe0b0('0x30')]:_0x3c0109[_0xe0b0('0x2b')];if(!_0x136bd4[_0xe0b0('0x2d')][_0xe0b0('0x33')](_0xe0b0('0x34'))){_0x1854b8[_0xe0b0('0x1d')]=qs['limit'](_0x136bd4[_0xe0b0('0x2d')][_0xe0b0('0x1d')]);_0x1854b8[_0xe0b0('0x1c')]=qs[_0xe0b0('0x1c')](_0x136bd4[_0xe0b0('0x2d')][_0xe0b0('0x1c')]);}_0x1854b8[_0xe0b0('0x35')]=qs['sort'](_0x136bd4['query']['sort']);_0x1854b8['where']=qs[_0xe0b0('0x2e')](_[_0xe0b0('0x36')](_0x136bd4[_0xe0b0('0x2d')],_0x3c0109['filters']),_0x422575);if(_0x136bd4[_0xe0b0('0x2d')][_0xe0b0('0x37')]){_0x1854b8[_0xe0b0('0x38')]=_[_0xe0b0('0x39')](_0x1854b8['where'],{'$or':_[_0xe0b0('0x3a')](_0x1854b8[_0xe0b0('0x30')],function(_0x43d352){var _0x30dcbb={};_0x30dcbb[_0x43d352]={'$like':'%'+_0x136bd4[_0xe0b0('0x2d')][_0xe0b0('0x37')]+'%'};return _0x30dcbb;})});}_0x1854b8=_[_0xe0b0('0x39')]({},_0x1854b8,_0x136bd4[_0xe0b0('0x3b')]);var _0xeaffbb={'where':_0x1854b8['where']};return db[_0xe0b0('0x3c')]['count'](_0xeaffbb)[_0xe0b0('0x23')](function(_0x2d5f47){_0x48a9b5[_0xe0b0('0x3d')]=_0x2d5f47;if(_0x136bd4[_0xe0b0('0x2d')]['includeAll']){_0x1854b8[_0xe0b0('0x3e')]=[{'all':!![]}];}return db[_0xe0b0('0x3c')][_0xe0b0('0x3f')](_0x1854b8);})[_0xe0b0('0x23')](function(_0x19c80e){_0x48a9b5[_0xe0b0('0x40')]=_0x19c80e;return _0x48a9b5;})[_0xe0b0('0x23')](respondWithFilteredResult(_0x4fb3b7,_0x1854b8))[_0xe0b0('0x41')](handleError(_0x4fb3b7,null));})['catch'](handleError(_0x4fb3b7,null));};exports[_0xe0b0('0x42')]=function(_0x309bbf,_0x528818){var _0x515bd2={'raw':![],'where':{'id':_0x309bbf[_0xe0b0('0x43')]['id']}},_0x327fb4={};_0x327fb4['model']=_[_0xe0b0('0x2c')](db[_0xe0b0('0x3c')][_0xe0b0('0x44')]);_0x327fb4[_0xe0b0('0x2d')]=_[_0xe0b0('0x2c')](_0x309bbf['query']);_0x327fb4['filters']=_['intersection'](_0x327fb4[_0xe0b0('0x2b')],_0x327fb4[_0xe0b0('0x2d')]);_0x515bd2['attributes']=_[_0xe0b0('0x2f')](_0x327fb4[_0xe0b0('0x2b')],qs[_0xe0b0('0x31')](_0x309bbf[_0xe0b0('0x2d')][_0xe0b0('0x31')]));_0x515bd2['attributes']=_0x515bd2['attributes'][_0xe0b0('0x32')]?_0x515bd2[_0xe0b0('0x30')]:_0x327fb4[_0xe0b0('0x2b')];if(_0x309bbf[_0xe0b0('0x2d')][_0xe0b0('0x45')]){_0x515bd2['include']=[{'all':!![]}];}_0x515bd2=_[_0xe0b0('0x39')]({},_0x515bd2,_0x309bbf[_0xe0b0('0x3b')]);return db['CmCompany']['find'](_0x515bd2)['then'](handleEntityNotFound(_0x528818,null))[_0xe0b0('0x23')](respondWithResult(_0x528818,null))[_0xe0b0('0x41')](handleError(_0x528818,null));};exports[_0xe0b0('0x46')]=function(_0x364877,_0x5b1756){return db[_0xe0b0('0x3c')][_0xe0b0('0x46')](_0x364877['body'],{})['then'](function(_0x2365be){var _0x1bc6e0=_0x364877['user'][_0xe0b0('0x47')]({'plain':!![]});if(!_0x1bc6e0)throw new Error(_0xe0b0('0x48'));if(_0x1bc6e0['role']==='user'){var _0x123ad2=_0x2365be['get']({'plain':!![]});var _0x165dc8=_0xe0b0('0x49');return db[_0xe0b0('0x4a')][_0xe0b0('0x4b')]({'where':{'name':_0x165dc8,'userProfileId':_0x1bc6e0[_0xe0b0('0x4c')]},'raw':!![]})[_0xe0b0('0x23')](function(_0x5f5486){if(_0x5f5486&&_0x5f5486['autoAssociation']===0x0){return db[_0xe0b0('0x25')]['create']({'name':_0x123ad2['name'],'resourceId':_0x123ad2['id'],'type':_0x5f5486[_0xe0b0('0x27')],'sectionId':_0x5f5486['id']},{})[_0xe0b0('0x23')](function(){return _0x2365be;});}else{return _0x2365be;}})['catch'](function(_0x4b65d1){logger[_0xe0b0('0x4d')](_0xe0b0('0x4e'),_0x4b65d1);throw _0x4b65d1;});}return _0x2365be;})[_0xe0b0('0x23')](respondWithResult(_0x5b1756,0xc9))[_0xe0b0('0x41')](handleError(_0x5b1756,null));};exports[_0xe0b0('0x4f')]=function(_0x24115f,_0x84fabb){if(_0x24115f['body']['id']){delete _0x24115f[_0xe0b0('0x50')]['id'];}return db['CmCompany'][_0xe0b0('0x4b')]({'where':{'id':_0x24115f['params']['id']}})['then'](handleEntityNotFound(_0x84fabb,null))[_0xe0b0('0x23')](saveUpdates(_0x24115f[_0xe0b0('0x50')],null))[_0xe0b0('0x23')](respondWithResult(_0x84fabb,null))[_0xe0b0('0x41')](handleError(_0x84fabb,null));};exports[_0xe0b0('0x24')]=function(_0x2a588d,_0x4548da){return db[_0xe0b0('0x3c')][_0xe0b0('0x4b')]({'where':{'id':_0x2a588d['params']['id']}})[_0xe0b0('0x23')](handleEntityNotFound(_0x4548da,null))['then'](removeEntity(_0x4548da,null))[_0xe0b0('0x41')](handleError(_0x4548da,null));};exports[_0xe0b0('0x2a')]=function(_0x30c4a9,_0xb9904c){return db[_0xe0b0('0x3c')][_0xe0b0('0x2a')]()['then'](respondWithResult(_0xb9904c,null))[_0xe0b0('0x41')](handleError(_0xb9904c,null));};exports[_0xe0b0('0x51')]=function(_0x437a15,_0x271445,_0x3bb6d6){return db[_0xe0b0('0x52')][_0xe0b0('0x4b')]({'where':{'id':_0x437a15[_0xe0b0('0x43')]['id']}})[_0xe0b0('0x23')](handleEntityNotFound(_0x271445,null))[_0xe0b0('0x23')](function(_0x1eb5d6){if(_0x1eb5d6){return _0x1eb5d6[_0xe0b0('0x51')](_0x437a15[_0xe0b0('0x50')][_0xe0b0('0x53')],_[_0xe0b0('0x54')](_0x437a15[_0xe0b0('0x50')],[_0xe0b0('0x53'),'id'])||{});}})[_0xe0b0('0x23')](respondWithResult(_0x271445,null))['catch'](handleError(_0x271445,null));};exports[_0xe0b0('0x55')]=function(_0xe7fbac,_0x1182dc,_0x2f24e6){var _0x3916ab={};var _0x405d7e={};var _0x2bdb59;var _0x4f818b;return db['CmCompany'][_0xe0b0('0x56')]({'where':{'id':_0xe7fbac[_0xe0b0('0x43')]['id']}})[_0xe0b0('0x23')](handleEntityNotFound(_0x1182dc,null))['then'](function(_0x117d20){if(_0x117d20){_0x2bdb59=_0x117d20;_0x405d7e[_0xe0b0('0x2b')]=_[_0xe0b0('0x2c')](db[_0xe0b0('0x52')][_0xe0b0('0x44')]);_0x405d7e['query']=_[_0xe0b0('0x2c')](_0xe7fbac[_0xe0b0('0x2d')]);_0x405d7e[_0xe0b0('0x2e')]=_['intersection'](_0x405d7e[_0xe0b0('0x2b')],_0x405d7e[_0xe0b0('0x2d')]);_0x3916ab['attributes']=_[_0xe0b0('0x2f')](_0x405d7e['model'],qs['fields'](_0xe7fbac[_0xe0b0('0x2d')]['fields']));_0x3916ab['attributes']=_0x3916ab[_0xe0b0('0x30')][_0xe0b0('0x32')]?_0x3916ab[_0xe0b0('0x30')]:_0x405d7e[_0xe0b0('0x2b')];_0x3916ab['order']=qs[_0xe0b0('0x57')](_0xe7fbac[_0xe0b0('0x2d')][_0xe0b0('0x57')]);_0x3916ab[_0xe0b0('0x38')]=qs[_0xe0b0('0x2e')](_[_0xe0b0('0x36')](_0xe7fbac[_0xe0b0('0x2d')],_0x405d7e[_0xe0b0('0x2e')]));if(_0xe7fbac['query']['filter']){_0x3916ab[_0xe0b0('0x38')]=_[_0xe0b0('0x39')](_0x3916ab[_0xe0b0('0x38')],{'$or':_['map'](_0x3916ab['attributes'],function(_0x2eb16f){var _0x26f36f={};_0x26f36f[_0x2eb16f]={'$like':'%'+_0xe7fbac['query']['filter']+'%'};return _0x26f36f;})});}_0x3916ab=_[_0xe0b0('0x39')]({},_0x3916ab,_0xe7fbac[_0xe0b0('0x3b')]);return _0x2bdb59[_0xe0b0('0x55')](_0x3916ab);}})[_0xe0b0('0x23')](function(_0x3b263f){if(_0x3b263f){_0x4f818b=_0x3b263f[_0xe0b0('0x32')];if(!_0xe7fbac[_0xe0b0('0x2d')][_0xe0b0('0x33')]('nolimit')){_0x3916ab[_0xe0b0('0x1d')]=qs[_0xe0b0('0x1d')](_0xe7fbac[_0xe0b0('0x2d')]['limit']);_0x3916ab['offset']=qs['offset'](_0xe7fbac['query']['offset']);}return _0x2bdb59['getContacts'](_0x3916ab);}})[_0xe0b0('0x23')](function(_0x51b492){if(_0x51b492){return _0x51b492?{'count':_0x4f818b,'rows':_0x51b492}:null;}})['then'](respondWithResult(_0x1182dc,null))[_0xe0b0('0x41')](handleError(_0x1182dc,null));};
\ No newline at end of file