Built motion from commit eddce310.|2.6.12
[motion2.git] / server / api / cmCompany / cmCompany.controller.js
index 684af15..0b29c93 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xd056=['fast-json-patch','moment','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','end','status','undefined','count','offset','limit','set','Content-Range','json','save','then','destroy','get','Companies','error','stack','name','send','CmCompany','describe','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','map','options','findAll','catch','show','params','rawAttributes','includeAll','include','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','addContacts','ids','omit','getContacts','findOne'];(function(_0x55aa41,_0x39c449){var _0xbdf804=function(_0x25c90e){while(--_0x25c90e){_0x55aa41['push'](_0x55aa41['shift']());}};_0xbdf804(++_0x39c449);}(_0xd056,0x164));var _0x6d05=function(_0x2ad5e0,_0x2396b0){_0x2ad5e0=_0x2ad5e0-0x0;var _0x555710=_0xd056[_0x2ad5e0];return _0x555710;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0x6d05('0x0'));var rp=require('request-promise');var moment=require(_0x6d05('0x1'));var BPromise=require('bluebird');var Mustache=require(_0x6d05('0x2'));var util=require(_0x6d05('0x3'));var path=require(_0x6d05('0x4'));var sox=require(_0x6d05('0x5'));var csv=require(_0x6d05('0x6'));var ejs=require(_0x6d05('0x7'));var fs=require('fs');var fs_extra=require(_0x6d05('0x8'));var _=require(_0x6d05('0x9'));var squel=require(_0x6d05('0xa'));var crypto=require(_0x6d05('0xb'));var jsforce=require(_0x6d05('0xc'));var deskjs=require(_0x6d05('0xd'));var toCsv=require(_0x6d05('0x6'));var querystring=require(_0x6d05('0xe'));var Papa=require(_0x6d05('0xf'));var Redis=require(_0x6d05('0x10'));var authService=require(_0x6d05('0x11'));var qs=require(_0x6d05('0x12'));var as=require(_0x6d05('0x13'));var hardwareService=require(_0x6d05('0x14'));var logger=require(_0x6d05('0x15'))(_0x6d05('0x16'));var utils=require(_0x6d05('0x17'));var config=require(_0x6d05('0x18'));var licenseUtil=require(_0x6d05('0x19'));var db=require(_0x6d05('0x1a'))['db'];function respondWithStatusCode(_0x5a1cf3,_0x54e28d){_0x54e28d=_0x54e28d||0xcc;return function(_0x2f548d){if(_0x2f548d){return _0x5a1cf3[_0x6d05('0x1b')](_0x54e28d);}return _0x5a1cf3['status'](_0x54e28d)[_0x6d05('0x1c')]();};}function respondWithResult(_0x237e7f,_0x12d69b){_0x12d69b=_0x12d69b||0xc8;return function(_0x31991d){if(_0x31991d){return _0x237e7f[_0x6d05('0x1d')](_0x12d69b)['json'](_0x31991d);}};}function respondWithFilteredResult(_0x57908a,_0x2f9d80){return function(_0x5f0387){if(_0x5f0387){var _0x52e9b3=typeof _0x2f9d80['offset']===_0x6d05('0x1e')&&typeof _0x2f9d80['limit']===_0x6d05('0x1e');var _0x4c665c=_0x5f0387[_0x6d05('0x1f')];var _0xd28ac9=_0x52e9b3?0x0:_0x2f9d80[_0x6d05('0x20')];var _0x1bab18=_0x52e9b3?_0x5f0387[_0x6d05('0x1f')]:_0x2f9d80['offset']+_0x2f9d80[_0x6d05('0x21')];var _0x2181a1;if(_0x1bab18>=_0x4c665c){_0x1bab18=_0x4c665c;_0x2181a1=0xc8;}else{_0x2181a1=0xce;}_0x57908a['status'](_0x2181a1);return _0x57908a[_0x6d05('0x22')](_0x6d05('0x23'),_0xd28ac9+'-'+_0x1bab18+'/'+_0x4c665c)[_0x6d05('0x24')](_0x5f0387);}return null;};}function patchUpdates(_0x4ebd1a){return function(_0x1ae701){try{jsonpatch['apply'](_0x1ae701,_0x4ebd1a,!![]);}catch(_0x25aadf){return BPromise['reject'](_0x25aadf);}return _0x1ae701[_0x6d05('0x25')]();};}function saveUpdates(_0x2a0ef1,_0x21751f){return function(_0xb42286){if(_0xb42286){return _0xb42286['update'](_0x2a0ef1)[_0x6d05('0x26')](function(_0x4c0bff){return _0x4c0bff;});}return null;};}function removeEntity(_0x32b708,_0x50e49a){return function(_0x707b28){if(_0x707b28){return _0x707b28[_0x6d05('0x27')]()[_0x6d05('0x26')](function(){var _0x449838=_0x707b28[_0x6d05('0x28')]({'plain':!![]});var _0x575978=_0x6d05('0x29');return db['UserProfileResource'][_0x6d05('0x27')]({'where':{'type':_0x575978,'resourceId':_0x449838['id']}})['then'](function(){return _0x707b28;});})[_0x6d05('0x26')](function(){_0x32b708[_0x6d05('0x1d')](0xcc)[_0x6d05('0x1c')]();});}};}function handleEntityNotFound(_0x2ee9bf,_0x553db0){return function(_0x2788bc){if(!_0x2788bc){_0x2ee9bf[_0x6d05('0x1b')](0x194);}return _0x2788bc;};}function handleError(_0x4d2a54,_0x3beba9){_0x3beba9=_0x3beba9||0x1f4;return function(_0x138605){logger[_0x6d05('0x2a')](_0x138605[_0x6d05('0x2b')]);if(_0x138605[_0x6d05('0x2c')]){delete _0x138605['name'];}_0x4d2a54[_0x6d05('0x1d')](_0x3beba9)[_0x6d05('0x2d')](_0x138605);};}exports['index']=function(_0x34b605,_0x9ff78b){var _0x2288b4={},_0x306ed1={},_0x2fe3e5={'count':0x0,'rows':[]};return db[_0x6d05('0x2e')][_0x6d05('0x2f')]()[_0x6d05('0x26')](function(_0x4ec851){_0x306ed1[_0x6d05('0x30')]=_['keys'](_0x4ec851);_0x306ed1[_0x6d05('0x31')]=_[_0x6d05('0x32')](_0x34b605[_0x6d05('0x31')]);_0x306ed1[_0x6d05('0x33')]=_['intersection'](_0x306ed1[_0x6d05('0x30')],_0x306ed1[_0x6d05('0x31')]);_0x2288b4[_0x6d05('0x34')]=_[_0x6d05('0x35')](_0x306ed1[_0x6d05('0x30')],qs[_0x6d05('0x36')](_0x34b605[_0x6d05('0x31')][_0x6d05('0x36')]));_0x2288b4[_0x6d05('0x34')]=_0x2288b4[_0x6d05('0x34')][_0x6d05('0x37')]?_0x2288b4['attributes']:_0x306ed1[_0x6d05('0x30')];if(!_0x34b605[_0x6d05('0x31')][_0x6d05('0x38')](_0x6d05('0x39'))){_0x2288b4[_0x6d05('0x21')]=qs['limit'](_0x34b605[_0x6d05('0x31')][_0x6d05('0x21')]);_0x2288b4[_0x6d05('0x20')]=qs[_0x6d05('0x20')](_0x34b605[_0x6d05('0x31')]['offset']);}_0x2288b4['order']=qs[_0x6d05('0x3a')](_0x34b605['query'][_0x6d05('0x3a')]);_0x2288b4[_0x6d05('0x3b')]=qs[_0x6d05('0x33')](_[_0x6d05('0x3c')](_0x34b605[_0x6d05('0x31')],_0x306ed1[_0x6d05('0x33')]),_0x4ec851);if(_0x34b605[_0x6d05('0x31')][_0x6d05('0x3d')]){_0x2288b4['where']=_[_0x6d05('0x3e')](_0x2288b4['where'],{'$or':_[_0x6d05('0x3f')](_0x2288b4[_0x6d05('0x34')],function(_0x4925dc){var _0x3c9f18={};_0x3c9f18[_0x4925dc]={'$like':'%'+_0x34b605[_0x6d05('0x31')][_0x6d05('0x3d')]+'%'};return _0x3c9f18;})});}_0x2288b4=_[_0x6d05('0x3e')]({},_0x2288b4,_0x34b605[_0x6d05('0x40')]);var _0x375242={'where':_0x2288b4['where']};return db[_0x6d05('0x2e')][_0x6d05('0x1f')](_0x375242)[_0x6d05('0x26')](function(_0x38fafa){_0x2fe3e5['count']=_0x38fafa;if(_0x34b605[_0x6d05('0x31')]['includeAll']){_0x2288b4['include']=[{'all':!![]}];}return db[_0x6d05('0x2e')][_0x6d05('0x41')](_0x2288b4);})[_0x6d05('0x26')](function(_0x227b03){_0x2fe3e5['rows']=_0x227b03;return _0x2fe3e5;})['then'](respondWithFilteredResult(_0x9ff78b,_0x2288b4))[_0x6d05('0x42')](handleError(_0x9ff78b,null));})[_0x6d05('0x42')](handleError(_0x9ff78b,null));};exports[_0x6d05('0x43')]=function(_0xa85508,_0x49bbd0){var _0x17d4ce={'raw':![],'where':{'id':_0xa85508[_0x6d05('0x44')]['id']}},_0x10c8df={};_0x10c8df['model']=_['keys'](db[_0x6d05('0x2e')][_0x6d05('0x45')]);_0x10c8df['query']=_['keys'](_0xa85508[_0x6d05('0x31')]);_0x10c8df[_0x6d05('0x33')]=_[_0x6d05('0x35')](_0x10c8df[_0x6d05('0x30')],_0x10c8df['query']);_0x17d4ce[_0x6d05('0x34')]=_[_0x6d05('0x35')](_0x10c8df[_0x6d05('0x30')],qs['fields'](_0xa85508[_0x6d05('0x31')][_0x6d05('0x36')]));_0x17d4ce[_0x6d05('0x34')]=_0x17d4ce[_0x6d05('0x34')][_0x6d05('0x37')]?_0x17d4ce[_0x6d05('0x34')]:_0x10c8df[_0x6d05('0x30')];if(_0xa85508['query'][_0x6d05('0x46')]){_0x17d4ce[_0x6d05('0x47')]=[{'all':!![]}];}_0x17d4ce=_[_0x6d05('0x3e')]({},_0x17d4ce,_0xa85508[_0x6d05('0x40')]);return db['CmCompany'][_0x6d05('0x48')](_0x17d4ce)[_0x6d05('0x26')](handleEntityNotFound(_0x49bbd0,null))['then'](respondWithResult(_0x49bbd0,null))[_0x6d05('0x42')](handleError(_0x49bbd0,null));};exports[_0x6d05('0x49')]=function(_0x1cde89,_0x5f0ec2){return db['CmCompany'][_0x6d05('0x49')](_0x1cde89[_0x6d05('0x4a')],{})[_0x6d05('0x26')](function(_0x85fadb){var _0x6b3c9d=_0x1cde89['user'][_0x6d05('0x28')]({'plain':!![]});if(!_0x6b3c9d)throw new Error(_0x6d05('0x4b'));if(_0x6b3c9d[_0x6d05('0x4c')]===_0x6d05('0x4d')){var _0x1ad2a7=_0x85fadb['get']({'plain':!![]});var _0x23981f=_0x6d05('0x29');return db[_0x6d05('0x4e')][_0x6d05('0x48')]({'where':{'name':_0x23981f,'userProfileId':_0x6b3c9d[_0x6d05('0x4f')]},'raw':!![]})['then'](function(_0xf3b5b2){if(_0xf3b5b2&&_0xf3b5b2[_0x6d05('0x50')]===0x0){return db[_0x6d05('0x51')][_0x6d05('0x49')]({'name':_0x1ad2a7[_0x6d05('0x2c')],'resourceId':_0x1ad2a7['id'],'type':_0xf3b5b2[_0x6d05('0x2c')],'sectionId':_0xf3b5b2['id']},{})['then'](function(){return _0x85fadb;});}else{return _0x85fadb;}})[_0x6d05('0x42')](function(_0xc385d){logger['error'](_0x6d05('0x52'),_0xc385d);throw _0xc385d;});}return _0x85fadb;})[_0x6d05('0x26')](respondWithResult(_0x5f0ec2,0xc9))[_0x6d05('0x42')](handleError(_0x5f0ec2,null));};exports[_0x6d05('0x53')]=function(_0x2db439,_0x25b7f1){if(_0x2db439['body']['id']){delete _0x2db439['body']['id'];}return db[_0x6d05('0x2e')]['find']({'where':{'id':_0x2db439['params']['id']}})[_0x6d05('0x26')](handleEntityNotFound(_0x25b7f1,null))[_0x6d05('0x26')](saveUpdates(_0x2db439['body'],null))[_0x6d05('0x26')](respondWithResult(_0x25b7f1,null))[_0x6d05('0x42')](handleError(_0x25b7f1,null));};exports[_0x6d05('0x27')]=function(_0x2b8bb2,_0x27e08){return db[_0x6d05('0x2e')][_0x6d05('0x48')]({'where':{'id':_0x2b8bb2[_0x6d05('0x44')]['id']}})[_0x6d05('0x26')](handleEntityNotFound(_0x27e08,null))[_0x6d05('0x26')](removeEntity(_0x27e08,null))[_0x6d05('0x42')](handleError(_0x27e08,null));};exports[_0x6d05('0x2f')]=function(_0x371f22,_0x2acfb0){return db['CmCompany']['describe']()['then'](respondWithResult(_0x2acfb0,null))[_0x6d05('0x42')](handleError(_0x2acfb0,null));};exports['addContacts']=function(_0xb44b99,_0x569718,_0x1758b1){return db['CmContact'][_0x6d05('0x48')]({'where':{'id':_0xb44b99[_0x6d05('0x44')]['id']}})['then'](handleEntityNotFound(_0x569718,null))[_0x6d05('0x26')](function(_0x2c8969){if(_0x2c8969){return _0x2c8969[_0x6d05('0x54')](_0xb44b99[_0x6d05('0x4a')][_0x6d05('0x55')],_[_0x6d05('0x56')](_0xb44b99[_0x6d05('0x4a')],[_0x6d05('0x55'),'id'])||{});}})[_0x6d05('0x26')](respondWithResult(_0x569718,null))['catch'](handleError(_0x569718,null));};exports[_0x6d05('0x57')]=function(_0x4624eb,_0x1f9933,_0xb89384){var _0x59d7f2={};var _0x287232={};var _0x4015a6;var _0x5f81e;return db[_0x6d05('0x2e')][_0x6d05('0x58')]({'where':{'id':_0x4624eb[_0x6d05('0x44')]['id']}})[_0x6d05('0x26')](handleEntityNotFound(_0x1f9933,null))[_0x6d05('0x26')](function(_0x134d32){if(_0x134d32){_0x4015a6=_0x134d32;_0x287232[_0x6d05('0x30')]=_[_0x6d05('0x32')](db['CmContact']['rawAttributes']);_0x287232[_0x6d05('0x31')]=_[_0x6d05('0x32')](_0x4624eb['query']);_0x287232[_0x6d05('0x33')]=_[_0x6d05('0x35')](_0x287232[_0x6d05('0x30')],_0x287232[_0x6d05('0x31')]);_0x59d7f2[_0x6d05('0x34')]=_[_0x6d05('0x35')](_0x287232[_0x6d05('0x30')],qs['fields'](_0x4624eb[_0x6d05('0x31')]['fields']));_0x59d7f2[_0x6d05('0x34')]=_0x59d7f2['attributes'][_0x6d05('0x37')]?_0x59d7f2[_0x6d05('0x34')]:_0x287232[_0x6d05('0x30')];_0x59d7f2['order']=qs[_0x6d05('0x3a')](_0x4624eb[_0x6d05('0x31')][_0x6d05('0x3a')]);_0x59d7f2[_0x6d05('0x3b')]=qs[_0x6d05('0x33')](_[_0x6d05('0x3c')](_0x4624eb['query'],_0x287232[_0x6d05('0x33')]));if(_0x4624eb[_0x6d05('0x31')][_0x6d05('0x3d')]){_0x59d7f2[_0x6d05('0x3b')]=_['merge'](_0x59d7f2['where'],{'$or':_[_0x6d05('0x3f')](_0x59d7f2['attributes'],function(_0x1bbb55){var _0x47a31b={};_0x47a31b[_0x1bbb55]={'$like':'%'+_0x4624eb[_0x6d05('0x31')][_0x6d05('0x3d')]+'%'};return _0x47a31b;})});}_0x59d7f2=_[_0x6d05('0x3e')]({},_0x59d7f2,_0x4624eb[_0x6d05('0x40')]);return _0x4015a6['getContacts'](_0x59d7f2);}})[_0x6d05('0x26')](function(_0x58793d){if(_0x58793d){_0x5f81e=_0x58793d[_0x6d05('0x37')];if(!_0x4624eb['query']['hasOwnProperty'](_0x6d05('0x39'))){_0x59d7f2[_0x6d05('0x21')]=qs[_0x6d05('0x21')](_0x4624eb[_0x6d05('0x31')]['limit']);_0x59d7f2['offset']=qs[_0x6d05('0x20')](_0x4624eb[_0x6d05('0x31')][_0x6d05('0x20')]);}return _0x4015a6['getContacts'](_0x59d7f2);}})[_0x6d05('0x26')](function(_0x384c59){if(_0x384c59){return _0x384c59?{'count':_0x5f81e,'rows':_0x384c59}:null;}})[_0x6d05('0x26')](respondWithResult(_0x1f9933,null))[_0x6d05('0x42')](handleError(_0x1f9933,null));};
\ No newline at end of file
+var _0x4f24=['limit','Content-Range','apply','reject','save','update','destroy','then','Companies','UserProfileResource','end','stack','name','send','CmCompany','model','keys','query','filters','attributes','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','map','options','include','rows','catch','show','params','rawAttributes','fields','includeAll','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','describe','addContacts','CmContact','ids','omit','getContacts','intersection','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','crypto','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','undefined','count','offset'];(function(_0x34f3f7,_0x3ad6b6){var _0x3a01e3=function(_0x21292f){while(--_0x21292f){_0x34f3f7['push'](_0x34f3f7['shift']());}};_0x3a01e3(++_0x3ad6b6);}(_0x4f24,0x8c));var _0x44f2=function(_0x264545,_0x214037){_0x264545=_0x264545-0x0;var _0x114d10=_0x4f24[_0x264545];return _0x114d10;};'use strict';var emlformat=require(_0x44f2('0x0'));var rimraf=require(_0x44f2('0x1'));var zipdir=require(_0x44f2('0x2'));var jsonpatch=require(_0x44f2('0x3'));var rp=require(_0x44f2('0x4'));var moment=require('moment');var BPromise=require(_0x44f2('0x5'));var Mustache=require(_0x44f2('0x6'));var util=require(_0x44f2('0x7'));var path=require(_0x44f2('0x8'));var sox=require(_0x44f2('0x9'));var csv=require(_0x44f2('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x44f2('0xb'));var _=require(_0x44f2('0xc'));var squel=require('squel');var crypto=require(_0x44f2('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x44f2('0xe'));var toCsv=require(_0x44f2('0xa'));var querystring=require(_0x44f2('0xf'));var Papa=require(_0x44f2('0x10'));var Redis=require('ioredis');var authService=require(_0x44f2('0x11'));var qs=require(_0x44f2('0x12'));var as=require(_0x44f2('0x13'));var hardwareService=require(_0x44f2('0x14'));var logger=require(_0x44f2('0x15'))('api');var utils=require(_0x44f2('0x16'));var config=require(_0x44f2('0x17'));var licenseUtil=require(_0x44f2('0x18'));var db=require(_0x44f2('0x19'))['db'];function respondWithStatusCode(_0x4f383b,_0x1e102a){_0x1e102a=_0x1e102a||0xcc;return function(_0x6a2f51){if(_0x6a2f51){return _0x4f383b[_0x44f2('0x1a')](_0x1e102a);}return _0x4f383b['status'](_0x1e102a)['end']();};}function respondWithResult(_0x1865fc,_0x4722b3){_0x4722b3=_0x4722b3||0xc8;return function(_0x516718){if(_0x516718){return _0x1865fc[_0x44f2('0x1b')](_0x4722b3)[_0x44f2('0x1c')](_0x516718);}};}function respondWithFilteredResult(_0x2f91b8,_0x1a1fd5){return function(_0x21b851){if(_0x21b851){var _0x5939f7=typeof _0x1a1fd5['offset']===_0x44f2('0x1d')&&typeof _0x1a1fd5['limit']===_0x44f2('0x1d');var _0x4ab32e=_0x21b851[_0x44f2('0x1e')];var _0x2d378e=_0x5939f7?0x0:_0x1a1fd5[_0x44f2('0x1f')];var _0x1bd615=_0x5939f7?_0x21b851['count']:_0x1a1fd5[_0x44f2('0x1f')]+_0x1a1fd5[_0x44f2('0x20')];var _0x435375;if(_0x1bd615>=_0x4ab32e){_0x1bd615=_0x4ab32e;_0x435375=0xc8;}else{_0x435375=0xce;}_0x2f91b8['status'](_0x435375);return _0x2f91b8['set'](_0x44f2('0x21'),_0x2d378e+'-'+_0x1bd615+'/'+_0x4ab32e)[_0x44f2('0x1c')](_0x21b851);}return null;};}function patchUpdates(_0x31434f){return function(_0x21977d){try{jsonpatch[_0x44f2('0x22')](_0x21977d,_0x31434f,!![]);}catch(_0x1580ec){return BPromise[_0x44f2('0x23')](_0x1580ec);}return _0x21977d[_0x44f2('0x24')]();};}function saveUpdates(_0x53d163,_0x268c63){return function(_0x40ab04){if(_0x40ab04){return _0x40ab04[_0x44f2('0x25')](_0x53d163)['then'](function(_0x5c860d){return _0x5c860d;});}return null;};}function removeEntity(_0x4d5eee,_0x3b2250){return function(_0x140b6e){if(_0x140b6e){return _0x140b6e[_0x44f2('0x26')]()[_0x44f2('0x27')](function(){var _0xeaffe5=_0x140b6e['get']({'plain':!![]});var _0x3eed91=_0x44f2('0x28');return db[_0x44f2('0x29')][_0x44f2('0x26')]({'where':{'type':_0x3eed91,'resourceId':_0xeaffe5['id']}})[_0x44f2('0x27')](function(){return _0x140b6e;});})[_0x44f2('0x27')](function(){_0x4d5eee['status'](0xcc)[_0x44f2('0x2a')]();});}};}function handleEntityNotFound(_0x543e3b,_0xd78045){return function(_0xa6ba5f){if(!_0xa6ba5f){_0x543e3b[_0x44f2('0x1a')](0x194);}return _0xa6ba5f;};}function handleError(_0x37cbfe,_0x28dd2c){_0x28dd2c=_0x28dd2c||0x1f4;return function(_0x4fbf74){logger['error'](_0x4fbf74[_0x44f2('0x2b')]);if(_0x4fbf74[_0x44f2('0x2c')]){delete _0x4fbf74['name'];}_0x37cbfe[_0x44f2('0x1b')](_0x28dd2c)[_0x44f2('0x2d')](_0x4fbf74);};}exports['index']=function(_0x4946fb,_0x2b056f){var _0x229428={},_0x4f478f={},_0x54f41f={'count':0x0,'rows':[]};return db[_0x44f2('0x2e')]['describe']()['then'](function(_0x2d4462){_0x4f478f[_0x44f2('0x2f')]=_[_0x44f2('0x30')](_0x2d4462);_0x4f478f[_0x44f2('0x31')]=_[_0x44f2('0x30')](_0x4946fb[_0x44f2('0x31')]);_0x4f478f[_0x44f2('0x32')]=_['intersection'](_0x4f478f[_0x44f2('0x2f')],_0x4f478f['query']);_0x229428[_0x44f2('0x33')]=_['intersection'](_0x4f478f[_0x44f2('0x2f')],qs['fields'](_0x4946fb['query']['fields']));_0x229428[_0x44f2('0x33')]=_0x229428[_0x44f2('0x33')][_0x44f2('0x34')]?_0x229428['attributes']:_0x4f478f[_0x44f2('0x2f')];if(!_0x4946fb['query'][_0x44f2('0x35')](_0x44f2('0x36'))){_0x229428[_0x44f2('0x20')]=qs['limit'](_0x4946fb['query'][_0x44f2('0x20')]);_0x229428[_0x44f2('0x1f')]=qs[_0x44f2('0x1f')](_0x4946fb[_0x44f2('0x31')][_0x44f2('0x1f')]);}_0x229428[_0x44f2('0x37')]=qs[_0x44f2('0x38')](_0x4946fb[_0x44f2('0x31')][_0x44f2('0x38')]);_0x229428[_0x44f2('0x39')]=qs['filters'](_[_0x44f2('0x3a')](_0x4946fb[_0x44f2('0x31')],_0x4f478f[_0x44f2('0x32')]),_0x2d4462);if(_0x4946fb[_0x44f2('0x31')][_0x44f2('0x3b')]){_0x229428[_0x44f2('0x39')]=_[_0x44f2('0x3c')](_0x229428[_0x44f2('0x39')],{'$or':_[_0x44f2('0x3d')](_0x229428['attributes'],function(_0xad7263){var _0x2e23d3={};_0x2e23d3[_0xad7263]={'$like':'%'+_0x4946fb[_0x44f2('0x31')]['filter']+'%'};return _0x2e23d3;})});}_0x229428=_[_0x44f2('0x3c')]({},_0x229428,_0x4946fb[_0x44f2('0x3e')]);var _0x2d728b={'where':_0x229428['where']};return db[_0x44f2('0x2e')][_0x44f2('0x1e')](_0x2d728b)['then'](function(_0x144b3e){_0x54f41f[_0x44f2('0x1e')]=_0x144b3e;if(_0x4946fb[_0x44f2('0x31')]['includeAll']){_0x229428[_0x44f2('0x3f')]=[{'all':!![]}];}return db['CmCompany']['findAll'](_0x229428);})[_0x44f2('0x27')](function(_0x341145){_0x54f41f[_0x44f2('0x40')]=_0x341145;return _0x54f41f;})[_0x44f2('0x27')](respondWithFilteredResult(_0x2b056f,_0x229428))[_0x44f2('0x41')](handleError(_0x2b056f,null));})[_0x44f2('0x41')](handleError(_0x2b056f,null));};exports[_0x44f2('0x42')]=function(_0x1a95e1,_0x476e1e){var _0x39277a={'raw':![],'where':{'id':_0x1a95e1[_0x44f2('0x43')]['id']}},_0x284117={};_0x284117['model']=_[_0x44f2('0x30')](db[_0x44f2('0x2e')][_0x44f2('0x44')]);_0x284117[_0x44f2('0x31')]=_[_0x44f2('0x30')](_0x1a95e1['query']);_0x284117[_0x44f2('0x32')]=_['intersection'](_0x284117[_0x44f2('0x2f')],_0x284117[_0x44f2('0x31')]);_0x39277a['attributes']=_['intersection'](_0x284117['model'],qs[_0x44f2('0x45')](_0x1a95e1[_0x44f2('0x31')][_0x44f2('0x45')]));_0x39277a[_0x44f2('0x33')]=_0x39277a[_0x44f2('0x33')][_0x44f2('0x34')]?_0x39277a[_0x44f2('0x33')]:_0x284117[_0x44f2('0x2f')];if(_0x1a95e1[_0x44f2('0x31')][_0x44f2('0x46')]){_0x39277a['include']=[{'all':!![]}];}_0x39277a=_[_0x44f2('0x3c')]({},_0x39277a,_0x1a95e1[_0x44f2('0x3e')]);return db[_0x44f2('0x2e')][_0x44f2('0x47')](_0x39277a)[_0x44f2('0x27')](handleEntityNotFound(_0x476e1e,null))[_0x44f2('0x27')](respondWithResult(_0x476e1e,null))[_0x44f2('0x41')](handleError(_0x476e1e,null));};exports[_0x44f2('0x48')]=function(_0x22ff60,_0x38948b){return db[_0x44f2('0x2e')]['create'](_0x22ff60[_0x44f2('0x49')],{})[_0x44f2('0x27')](function(_0x2519ef){var _0x2188c3=_0x22ff60[_0x44f2('0x4a')]['get']({'plain':!![]});if(!_0x2188c3)throw new Error(_0x44f2('0x4b'));if(_0x2188c3['role']===_0x44f2('0x4a')){var _0x4ed0b2=_0x2519ef['get']({'plain':!![]});var _0x300373=_0x44f2('0x28');return db[_0x44f2('0x4c')]['find']({'where':{'name':_0x300373,'userProfileId':_0x2188c3[_0x44f2('0x4d')]},'raw':!![]})[_0x44f2('0x27')](function(_0x289cbd){if(_0x289cbd&&_0x289cbd['autoAssociation']===0x0){return db[_0x44f2('0x29')][_0x44f2('0x48')]({'name':_0x4ed0b2[_0x44f2('0x2c')],'resourceId':_0x4ed0b2['id'],'type':_0x289cbd[_0x44f2('0x2c')],'sectionId':_0x289cbd['id']},{})[_0x44f2('0x27')](function(){return _0x2519ef;});}else{return _0x2519ef;}})['catch'](function(_0x1f9914){logger['error'](_0x44f2('0x4e'),_0x1f9914);throw _0x1f9914;});}return _0x2519ef;})[_0x44f2('0x27')](respondWithResult(_0x38948b,0xc9))[_0x44f2('0x41')](handleError(_0x38948b,null));};exports[_0x44f2('0x25')]=function(_0xfdb306,_0x3dd28f){if(_0xfdb306[_0x44f2('0x49')]['id']){delete _0xfdb306['body']['id'];}return db[_0x44f2('0x2e')]['find']({'where':{'id':_0xfdb306[_0x44f2('0x43')]['id']}})[_0x44f2('0x27')](handleEntityNotFound(_0x3dd28f,null))['then'](saveUpdates(_0xfdb306[_0x44f2('0x49')],null))['then'](respondWithResult(_0x3dd28f,null))[_0x44f2('0x41')](handleError(_0x3dd28f,null));};exports[_0x44f2('0x26')]=function(_0x21b8fc,_0x4b2c95){return db[_0x44f2('0x2e')][_0x44f2('0x47')]({'where':{'id':_0x21b8fc[_0x44f2('0x43')]['id']}})['then'](handleEntityNotFound(_0x4b2c95,null))['then'](removeEntity(_0x4b2c95,null))[_0x44f2('0x41')](handleError(_0x4b2c95,null));};exports[_0x44f2('0x4f')]=function(_0x3857f5,_0xe57ba1){return db['CmCompany'][_0x44f2('0x4f')]()['then'](respondWithResult(_0xe57ba1,null))[_0x44f2('0x41')](handleError(_0xe57ba1,null));};exports[_0x44f2('0x50')]=function(_0x309bfb,_0x2b9839,_0x5cd25f){return db[_0x44f2('0x51')][_0x44f2('0x47')]({'where':{'id':_0x309bfb['params']['id']}})[_0x44f2('0x27')](handleEntityNotFound(_0x2b9839,null))[_0x44f2('0x27')](function(_0x1e2944){if(_0x1e2944){return _0x1e2944[_0x44f2('0x50')](_0x309bfb[_0x44f2('0x49')][_0x44f2('0x52')],_[_0x44f2('0x53')](_0x309bfb['body'],['ids','id'])||{});}})['then'](respondWithResult(_0x2b9839,null))[_0x44f2('0x41')](handleError(_0x2b9839,null));};exports[_0x44f2('0x54')]=function(_0x10c09d,_0x157834,_0x28a9ab){var _0x31e2fd={};var _0x166d38={};var _0x96cb71;var _0x3054a3;return db[_0x44f2('0x2e')]['findOne']({'where':{'id':_0x10c09d[_0x44f2('0x43')]['id']}})['then'](handleEntityNotFound(_0x157834,null))['then'](function(_0x4576ea){if(_0x4576ea){_0x96cb71=_0x4576ea;_0x166d38['model']=_['keys'](db[_0x44f2('0x51')][_0x44f2('0x44')]);_0x166d38[_0x44f2('0x31')]=_['keys'](_0x10c09d['query']);_0x166d38[_0x44f2('0x32')]=_[_0x44f2('0x55')](_0x166d38[_0x44f2('0x2f')],_0x166d38[_0x44f2('0x31')]);_0x31e2fd[_0x44f2('0x33')]=_[_0x44f2('0x55')](_0x166d38['model'],qs['fields'](_0x10c09d[_0x44f2('0x31')][_0x44f2('0x45')]));_0x31e2fd['attributes']=_0x31e2fd['attributes'][_0x44f2('0x34')]?_0x31e2fd[_0x44f2('0x33')]:_0x166d38[_0x44f2('0x2f')];_0x31e2fd[_0x44f2('0x37')]=qs[_0x44f2('0x38')](_0x10c09d[_0x44f2('0x31')][_0x44f2('0x38')]);_0x31e2fd[_0x44f2('0x39')]=qs['filters'](_[_0x44f2('0x3a')](_0x10c09d[_0x44f2('0x31')],_0x166d38['filters']));if(_0x10c09d[_0x44f2('0x31')][_0x44f2('0x3b')]){_0x31e2fd[_0x44f2('0x39')]=_[_0x44f2('0x3c')](_0x31e2fd[_0x44f2('0x39')],{'$or':_[_0x44f2('0x3d')](_0x31e2fd[_0x44f2('0x33')],function(_0x536612){var _0x482e18={};_0x482e18[_0x536612]={'$like':'%'+_0x10c09d[_0x44f2('0x31')][_0x44f2('0x3b')]+'%'};return _0x482e18;})});}_0x31e2fd=_[_0x44f2('0x3c')]({},_0x31e2fd,_0x10c09d[_0x44f2('0x3e')]);return _0x96cb71[_0x44f2('0x54')](_0x31e2fd);}})[_0x44f2('0x27')](function(_0x4916ad){if(_0x4916ad){_0x3054a3=_0x4916ad[_0x44f2('0x34')];if(!_0x10c09d[_0x44f2('0x31')][_0x44f2('0x35')](_0x44f2('0x36'))){_0x31e2fd['limit']=qs[_0x44f2('0x20')](_0x10c09d['query'][_0x44f2('0x20')]);_0x31e2fd[_0x44f2('0x1f')]=qs[_0x44f2('0x1f')](_0x10c09d[_0x44f2('0x31')][_0x44f2('0x1f')]);}return _0x96cb71[_0x44f2('0x54')](_0x31e2fd);}})[_0x44f2('0x27')](function(_0x72b470){if(_0x72b470){return _0x72b470?{'count':_0x3054a3,'rows':_0x72b470}:null;}})[_0x44f2('0x27')](respondWithResult(_0x157834,null))[_0x44f2('0x41')](handleError(_0x157834,null));};
\ No newline at end of file