Built motion from commit bab6f49e.|2.6.17
[motion2.git] / server / api / squareProject / squareProject.controller.js
index 855272d..46327e4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x126f=['../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/license/util','../../mysqldb','redis','localhost','socket.io-emitter','./squareProject.socket','register','sendStatus','status','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','then','destroy','get','SquareProjects','UserProfileResource','error','stack','name','send','index','map','SquareProject','rawAttributes','fieldName','key','model','filters','intersection','query','attributes','fields','length','hasOwnProperty','nolimit','sort','where','pick','filter','merge','type','options','includeAll','findAll','rows','catch','show','keys','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','addUsers','omit','ids','removeUsers','isArray','userSquareProject:remove','findOne','User','getUsers','eml-format','rimraf','zip-dir','fast-json-patch','bluebird','mustache','util','path','to-csv','ejs','fs-extra','lodash','squel','jsforce','querystring','ioredis','../../components/auth/service','../../components/parsers/qs'];(function(_0x2a60a6,_0x3968ff){var _0x574216=function(_0x39eddd){while(--_0x39eddd){_0x2a60a6['push'](_0x2a60a6['shift']());}};_0x574216(++_0x3968ff);}(_0x126f,0x1d8));var _0xf126=function(_0x35dfe6,_0x4244fa){_0x35dfe6=_0x35dfe6-0x0;var _0x59651c=_0x126f[_0x35dfe6];return _0x59651c;};'use strict';var emlformat=require(_0xf126('0x0'));var rimraf=require(_0xf126('0x1'));var zipdir=require(_0xf126('0x2'));var jsonpatch=require(_0xf126('0x3'));var rp=require('request-promise');var moment=require('moment');var BPromise=require(_0xf126('0x4'));var Mustache=require(_0xf126('0x5'));var util=require(_0xf126('0x6'));var path=require(_0xf126('0x7'));var sox=require('sox');var csv=require(_0xf126('0x8'));var ejs=require(_0xf126('0x9'));var fs=require('fs');var fs_extra=require(_0xf126('0xa'));var _=require(_0xf126('0xb'));var squel=require(_0xf126('0xc'));var crypto=require('crypto');var jsforce=require(_0xf126('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xf126('0x8'));var querystring=require(_0xf126('0xe'));var Papa=require('papaparse');var Redis=require(_0xf126('0xf'));var authService=require(_0xf126('0x10'));var qs=require(_0xf126('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xf126('0x12'));var logger=require(_0xf126('0x13'))(_0xf126('0x14'));var utils=require(_0xf126('0x15'));var config=require('../../config/environment');var licenseUtil=require(_0xf126('0x16'));var db=require(_0xf126('0x17'))['db'];config[_0xf126('0x18')]=_['defaults'](config['redis'],{'host':_0xf126('0x19'),'port':0x18eb});var socket=require(_0xf126('0x1a'))(new Redis(config['redis']));require(_0xf126('0x1b'))[_0xf126('0x1c')](socket);function respondWithStatusCode(_0x54ae44,_0x5c4210){_0x5c4210=_0x5c4210||0xcc;return function(_0x110c64){if(_0x110c64){return _0x54ae44[_0xf126('0x1d')](_0x5c4210);}return _0x54ae44[_0xf126('0x1e')](_0x5c4210)[_0xf126('0x1f')]();};}function respondWithResult(_0x51fc45,_0x3428cf){_0x3428cf=_0x3428cf||0xc8;return function(_0x309c69){if(_0x309c69){return _0x51fc45[_0xf126('0x1e')](_0x3428cf)[_0xf126('0x20')](_0x309c69);}};}function respondWithFilteredResult(_0x1d9e25,_0xb3c56e){return function(_0xc1f9ec){if(_0xc1f9ec){var _0x3c8b83=typeof _0xb3c56e[_0xf126('0x21')]===_0xf126('0x22')&&typeof _0xb3c56e[_0xf126('0x23')]===_0xf126('0x22');var _0x2fa7e6=_0xc1f9ec[_0xf126('0x24')];var _0x32c6b9=_0x3c8b83?0x0:_0xb3c56e[_0xf126('0x21')];var _0x451211=_0x3c8b83?_0xc1f9ec[_0xf126('0x24')]:_0xb3c56e[_0xf126('0x21')]+_0xb3c56e[_0xf126('0x23')];var _0xe82625;if(_0x451211>=_0x2fa7e6){_0x451211=_0x2fa7e6;_0xe82625=0xc8;}else{_0xe82625=0xce;}_0x1d9e25[_0xf126('0x1e')](_0xe82625);return _0x1d9e25[_0xf126('0x25')](_0xf126('0x26'),_0x32c6b9+'-'+_0x451211+'/'+_0x2fa7e6)['json'](_0xc1f9ec);}return null;};}function patchUpdates(_0x39bbed){return function(_0x569fa9){try{jsonpatch[_0xf126('0x27')](_0x569fa9,_0x39bbed,!![]);}catch(_0x26eb26){return BPromise[_0xf126('0x28')](_0x26eb26);}return _0x569fa9['save']();};}function saveUpdates(_0x29d018,_0x726083){return function(_0x5044b4){if(_0x5044b4){return _0x5044b4[_0xf126('0x29')](_0x29d018)[_0xf126('0x2a')](function(_0x17b12a){return _0x17b12a;});}return null;};}function removeEntity(_0xc76220,_0x42d1b9){return function(_0xf4d040){if(_0xf4d040){return _0xf4d040[_0xf126('0x2b')]()[_0xf126('0x2a')](function(){var _0x1f0fb3=_0xf4d040[_0xf126('0x2c')]({'plain':!![]});var _0x3eef2c=_0xf126('0x2d');return db[_0xf126('0x2e')]['destroy']({'where':{'type':_0x3eef2c,'resourceId':_0x1f0fb3['id']}})[_0xf126('0x2a')](function(){return _0xf4d040;});})[_0xf126('0x2a')](function(){_0xc76220['status'](0xcc)[_0xf126('0x1f')]();});}};}function handleEntityNotFound(_0x1e38ca,_0xfea39d){return function(_0x4af0e8){if(!_0x4af0e8){_0x1e38ca['sendStatus'](0x194);}return _0x4af0e8;};}function handleError(_0x20719a,_0x2db676){_0x2db676=_0x2db676||0x1f4;return function(_0x16cf4e){logger[_0xf126('0x2f')](_0x16cf4e[_0xf126('0x30')]);if(_0x16cf4e[_0xf126('0x31')]){delete _0x16cf4e['name'];}_0x20719a['status'](_0x2db676)[_0xf126('0x32')](_0x16cf4e);};}exports[_0xf126('0x33')]=function(_0x520dd6,_0x2f2e3b){var _0x18b756={},_0x3da34b={},_0x7a7d20={'count':0x0,'rows':[]};var _0x4e0a43=_[_0xf126('0x34')](db[_0xf126('0x35')][_0xf126('0x36')],function(_0x8712f3){return{'name':_0x8712f3[_0xf126('0x37')],'type':_0x8712f3['type'][_0xf126('0x38')]};});_0x3da34b[_0xf126('0x39')]=_[_0xf126('0x34')](_0x4e0a43,_0xf126('0x31'));_0x3da34b['query']=_['keys'](_0x520dd6['query']);_0x3da34b[_0xf126('0x3a')]=_[_0xf126('0x3b')](_0x3da34b[_0xf126('0x39')],_0x3da34b[_0xf126('0x3c')]);_0x18b756[_0xf126('0x3d')]=_[_0xf126('0x3b')](_0x3da34b[_0xf126('0x39')],qs[_0xf126('0x3e')](_0x520dd6[_0xf126('0x3c')][_0xf126('0x3e')]));_0x18b756['attributes']=_0x18b756['attributes'][_0xf126('0x3f')]?_0x18b756['attributes']:_0x3da34b[_0xf126('0x39')];if(!_0x520dd6['query'][_0xf126('0x40')](_0xf126('0x41'))){_0x18b756['limit']=qs['limit'](_0x520dd6[_0xf126('0x3c')][_0xf126('0x23')]);_0x18b756[_0xf126('0x21')]=qs[_0xf126('0x21')](_0x520dd6[_0xf126('0x3c')]['offset']);}_0x18b756['order']=qs[_0xf126('0x42')](_0x520dd6[_0xf126('0x3c')]['sort']);_0x18b756[_0xf126('0x43')]=qs[_0xf126('0x3a')](_[_0xf126('0x44')](_0x520dd6[_0xf126('0x3c')],_0x3da34b['filters']),_0x4e0a43);if(_0x520dd6[_0xf126('0x3c')][_0xf126('0x45')]){_0x18b756[_0xf126('0x43')]=_[_0xf126('0x46')](_0x18b756['where'],{'$or':_[_0xf126('0x34')](_0x4e0a43,function(_0x589b77){if(_0x589b77[_0xf126('0x47')]!=='VIRTUAL'){var _0x330cbe={};_0x330cbe[_0x589b77[_0xf126('0x31')]]={'$like':'%'+_0x520dd6['query'][_0xf126('0x45')]+'%'};return _0x330cbe;}})});}_0x18b756=_[_0xf126('0x46')]({},_0x18b756,_0x520dd6[_0xf126('0x48')]);var _0x49471d={'where':_0x18b756[_0xf126('0x43')]};return db[_0xf126('0x35')][_0xf126('0x24')](_0x49471d)['then'](function(_0x1bbbf1){_0x7a7d20[_0xf126('0x24')]=_0x1bbbf1;if(_0x520dd6['query'][_0xf126('0x49')]){_0x18b756['include']=[{'all':!![]}];}return db[_0xf126('0x35')][_0xf126('0x4a')](_0x18b756);})[_0xf126('0x2a')](function(_0x58d137){_0x7a7d20[_0xf126('0x4b')]=_0x58d137;return _0x7a7d20;})[_0xf126('0x2a')](respondWithFilteredResult(_0x2f2e3b,_0x18b756))[_0xf126('0x4c')](handleError(_0x2f2e3b,null));};exports[_0xf126('0x4d')]=function(_0xa56354,_0x5b6cb3){var _0x57820c={'raw':![],'where':{'id':_0xa56354['params']['id']}},_0x43b876={};_0x43b876[_0xf126('0x39')]=_['keys'](db[_0xf126('0x35')][_0xf126('0x36')]);_0x43b876[_0xf126('0x3c')]=_[_0xf126('0x4e')](_0xa56354['query']);_0x43b876[_0xf126('0x3a')]=_[_0xf126('0x3b')](_0x43b876[_0xf126('0x39')],_0x43b876[_0xf126('0x3c')]);_0x57820c[_0xf126('0x3d')]=_[_0xf126('0x3b')](_0x43b876[_0xf126('0x39')],qs[_0xf126('0x3e')](_0xa56354[_0xf126('0x3c')][_0xf126('0x3e')]));_0x57820c['attributes']=_0x57820c['attributes'][_0xf126('0x3f')]?_0x57820c[_0xf126('0x3d')]:_0x43b876[_0xf126('0x39')];if(_0xa56354['query'][_0xf126('0x49')]){_0x57820c['include']=[{'all':!![]}];}_0x57820c=_['merge']({},_0x57820c,_0xa56354['options']);return db[_0xf126('0x35')][_0xf126('0x4f')](_0x57820c)[_0xf126('0x2a')](handleEntityNotFound(_0x5b6cb3,null))['then'](respondWithResult(_0x5b6cb3,null))['catch'](handleError(_0x5b6cb3,null));};exports[_0xf126('0x50')]=function(_0x4c1b8b,_0x2a9b3b){return db['SquareProject'][_0xf126('0x50')](_0x4c1b8b[_0xf126('0x51')],{})['then'](function(_0x2b0db8){var _0x89bef=_0x4c1b8b[_0xf126('0x52')][_0xf126('0x2c')]({'plain':!![]});if(!_0x89bef)throw new Error(_0xf126('0x53'));if(_0x89bef[_0xf126('0x54')]==='user'){var _0x4b9c7d=_0x2b0db8['get']({'plain':!![]});var _0x41b18e='SquareProjects';return db['UserProfileSection'][_0xf126('0x4f')]({'where':{'name':_0x41b18e,'userProfileId':_0x89bef[_0xf126('0x55')]},'raw':!![]})[_0xf126('0x2a')](function(_0x319cb0){if(_0x319cb0&&_0x319cb0[_0xf126('0x56')]===0x0){return db[_0xf126('0x2e')][_0xf126('0x50')]({'name':_0x4b9c7d['name'],'resourceId':_0x4b9c7d['id'],'type':_0x319cb0[_0xf126('0x31')],'sectionId':_0x319cb0['id']},{})['then'](function(){return _0x2b0db8;});}else{return _0x2b0db8;}})[_0xf126('0x4c')](function(_0x3f8b05){logger['error'](_0xf126('0x57'),_0x3f8b05);throw _0x3f8b05;});}return _0x2b0db8;})[_0xf126('0x2a')](respondWithResult(_0x2a9b3b,0xc9))[_0xf126('0x4c')](handleError(_0x2a9b3b,null));};exports[_0xf126('0x29')]=function(_0x2819f5,_0x545628){if(_0x2819f5[_0xf126('0x51')]['id']){delete _0x2819f5[_0xf126('0x51')]['id'];}return db[_0xf126('0x35')]['find']({'where':{'id':_0x2819f5['params']['id']}})['then'](handleEntityNotFound(_0x545628,null))[_0xf126('0x2a')](saveUpdates(_0x2819f5[_0xf126('0x51')],null))['then'](respondWithResult(_0x545628,null))[_0xf126('0x4c')](handleError(_0x545628,null));};exports[_0xf126('0x2b')]=function(_0x469b65,_0xf7a6cc){return db['SquareProject'][_0xf126('0x4f')]({'where':{'id':_0x469b65['params']['id']}})[_0xf126('0x2a')](handleEntityNotFound(_0xf7a6cc,null))[_0xf126('0x2a')](removeEntity(_0xf7a6cc,null))[_0xf126('0x4c')](handleError(_0xf7a6cc,null));};exports['addUsers']=function(_0x46ff26,_0x1077c7,_0x40c1f6){return db[_0xf126('0x35')]['find']({'where':{'id':_0x46ff26[_0xf126('0x58')]['id']}})[_0xf126('0x2a')](handleEntityNotFound(_0x1077c7,null))[_0xf126('0x2a')](function(_0x3780e0){if(_0x3780e0){return _0x3780e0[_0xf126('0x59')](_0x46ff26[_0xf126('0x51')]['ids'],_[_0xf126('0x5a')](_0x46ff26[_0xf126('0x51')],[_0xf126('0x5b'),'id'])||{});}})[_0xf126('0x2a')](respondWithResult(_0x1077c7,null))['catch'](handleError(_0x1077c7,null));};exports[_0xf126('0x5c')]=function(_0xcf00b,_0x4831fd,_0x5d988d){return db[_0xf126('0x35')]['find']({'where':{'id':_0xcf00b[_0xf126('0x58')]['id']}})[_0xf126('0x2a')](handleEntityNotFound(_0x4831fd,null))[_0xf126('0x2a')](function(_0x18090f){if(_0x18090f){return _0x18090f['removeUsers'](_0xcf00b['query'][_0xf126('0x5b')])['then'](function(){if(_[_0xf126('0x5d')](_0xcf00b[_0xf126('0x3c')][_0xf126('0x5b')])){for(var _0x5484e9=0x0;_0x5484e9<_0xcf00b[_0xf126('0x3c')][_0xf126('0x5b')][_0xf126('0x3f')];_0x5484e9+=0x1){socket['emit']('userSquareProject:remove',{'UserId':Number(_0xcf00b[_0xf126('0x3c')][_0xf126('0x5b')][_0x5484e9]),'SquareProjectId':Number(_0xcf00b[_0xf126('0x58')]['id'])});}}else{socket['emit'](_0xf126('0x5e'),{'UserId':Number(_0xcf00b[_0xf126('0x3c')][_0xf126('0x5b')]),'SquareProjectId':Number(_0xcf00b[_0xf126('0x58')]['id'])});}});}})[_0xf126('0x2a')](respondWithStatusCode(_0x4831fd,null))[_0xf126('0x4c')](handleError(_0x4831fd,null));};exports['getUsers']=function(_0x3df4fe,_0x73c4cc,_0x392c1c){var _0x5fcf95={};var _0x2fc398={};var _0x127f2b;var _0x2ef15a;return db[_0xf126('0x35')][_0xf126('0x5f')]({'where':{'id':_0x3df4fe[_0xf126('0x58')]['id']}})[_0xf126('0x2a')](handleEntityNotFound(_0x73c4cc,null))['then'](function(_0x661280){if(_0x661280){_0x127f2b=_0x661280;_0x2fc398[_0xf126('0x39')]=_['keys'](db[_0xf126('0x60')][_0xf126('0x36')]);_0x2fc398['query']=_[_0xf126('0x4e')](_0x3df4fe[_0xf126('0x3c')]);_0x2fc398[_0xf126('0x3a')]=_[_0xf126('0x3b')](_0x2fc398[_0xf126('0x39')],_0x2fc398[_0xf126('0x3c')]);_0x5fcf95[_0xf126('0x3d')]=_[_0xf126('0x3b')](_0x2fc398[_0xf126('0x39')],qs[_0xf126('0x3e')](_0x3df4fe[_0xf126('0x3c')][_0xf126('0x3e')]));_0x5fcf95[_0xf126('0x3d')]=_0x5fcf95[_0xf126('0x3d')][_0xf126('0x3f')]?_0x5fcf95[_0xf126('0x3d')]:_0x2fc398['model'];_0x5fcf95['order']=qs['sort'](_0x3df4fe['query'][_0xf126('0x42')]);_0x5fcf95[_0xf126('0x43')]=qs['filters'](_[_0xf126('0x44')](_0x3df4fe[_0xf126('0x3c')],_0x2fc398[_0xf126('0x3a')]));if(_0x3df4fe[_0xf126('0x3c')][_0xf126('0x45')]){_0x5fcf95[_0xf126('0x43')]=_[_0xf126('0x46')](_0x5fcf95[_0xf126('0x43')],{'$or':_[_0xf126('0x34')](_0x5fcf95[_0xf126('0x3d')],function(_0x3e3af2){var _0x371ca8={};_0x371ca8[_0x3e3af2]={'$like':'%'+_0x3df4fe[_0xf126('0x3c')][_0xf126('0x45')]+'%'};return _0x371ca8;})});}_0x5fcf95=_['merge']({},_0x5fcf95,_0x3df4fe['options']);return _0x127f2b[_0xf126('0x61')](_0x5fcf95);}})[_0xf126('0x2a')](function(_0x1ec082){if(_0x1ec082){_0x2ef15a=_0x1ec082[_0xf126('0x3f')];if(!_0x3df4fe[_0xf126('0x3c')]['hasOwnProperty'](_0xf126('0x41'))){_0x5fcf95[_0xf126('0x23')]=qs[_0xf126('0x23')](_0x3df4fe['query']['limit']);_0x5fcf95[_0xf126('0x21')]=qs[_0xf126('0x21')](_0x3df4fe[_0xf126('0x3c')][_0xf126('0x21')]);}return _0x127f2b[_0xf126('0x61')](_0x5fcf95);}})['then'](function(_0x27a73f){if(_0x27a73f){return _0x27a73f?{'count':_0x2ef15a,'rows':_0x27a73f}:null;}})[_0xf126('0x2a')](respondWithResult(_0x73c4cc,null))[_0xf126('0x4c')](handleError(_0x73c4cc,null));};
\ No newline at end of file
+var _0x8ad7=['attributes','intersection','length','nolimit','sort','where','pick','merge','VIRTUAL','options','count','include','findAll','rows','show','params','fields','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','production','lodash','ioredis','../../config/logger','api','../../config/environment','redis','defaults','socket.io-emitter','./squareProject.socket','register','json','offset','undefined','limit','set','Content-Range','update','then','get','SquareProjects','UserProfileResource','destroy','publish','agi','stringify','status','end','error','stack','name','index','map','SquareProject','rawAttributes','type','key','model','query','keys','filters'];(function(_0x2c1ce,_0x5728fc){var _0x56f56f=function(_0x5488de){while(--_0x5488de){_0x2c1ce['push'](_0x2c1ce['shift']());}};_0x56f56f(++_0x5728fc);}(_0x8ad7,0xa7));var _0x78ad=function(_0x26462c,_0xd20a35){_0x26462c=_0x26462c-0x0;var _0x509a42=_0x8ad7[_0x26462c];return _0x509a42;};'use strict';var _=require(_0x78ad('0x0'));var Redis=require(_0x78ad('0x1'));var qs=require('../../components/parsers/qs');var logger=require(_0x78ad('0x2'))(_0x78ad('0x3'));var config=require(_0x78ad('0x4'));var db=require('../../mysqldb')['db'];config[_0x78ad('0x5')]=_[_0x78ad('0x6')](config[_0x78ad('0x5')],{'host':'localhost','port':0x18eb});var socket=require(_0x78ad('0x7'))(new Redis(config[_0x78ad('0x5')]));require(_0x78ad('0x8'))[_0x78ad('0x9')](socket);function respondWithResult(_0xc3028,_0x1921bd){_0x1921bd=_0x1921bd||0xc8;return function(_0x2ad9dd){if(_0x2ad9dd){return _0xc3028['status'](_0x1921bd)[_0x78ad('0xa')](_0x2ad9dd);}};}function respondWithFilteredResult(_0x19a2b4,_0x3ee423){return function(_0x31c393){if(_0x31c393){var _0xc94a65=typeof _0x3ee423[_0x78ad('0xb')]===_0x78ad('0xc')&&typeof _0x3ee423[_0x78ad('0xd')]===_0x78ad('0xc');var _0x1817e4=_0x31c393['count'];var _0x3f6c56=_0xc94a65?0x0:_0x3ee423[_0x78ad('0xb')];var _0x2a9e57=_0xc94a65?_0x31c393['count']:_0x3ee423['offset']+_0x3ee423[_0x78ad('0xd')];var _0x1ac892;if(_0x2a9e57>=_0x1817e4){_0x2a9e57=_0x1817e4;_0x1ac892=0xc8;}else{_0x1ac892=0xce;}_0x19a2b4['status'](_0x1ac892);return _0x19a2b4[_0x78ad('0xe')](_0x78ad('0xf'),_0x3f6c56+'-'+_0x2a9e57+'/'+_0x1817e4)[_0x78ad('0xa')](_0x31c393);}return null;};}function saveUpdates(_0x4b8185){return function(_0x363fb7){if(_0x363fb7){return _0x363fb7[_0x78ad('0x10')](_0x4b8185)[_0x78ad('0x11')](function(_0x5bea0a){return _0x5bea0a;});}return null;};}function removeEntity(_0x3b888b){return function(_0x2d6eea){if(_0x2d6eea){return _0x2d6eea['destroy']()[_0x78ad('0x11')](function(){var _0x142cf9=_0x2d6eea[_0x78ad('0x12')]({'plain':!![]});var _0x4be0f7=_0x78ad('0x13');return db[_0x78ad('0x14')][_0x78ad('0x15')]({'where':{'type':_0x4be0f7,'resourceId':_0x142cf9['id']}})[_0x78ad('0x11')](function(){return _0x2d6eea;});})['then'](function(){var _0x11a03f=new Redis(config[_0x78ad('0x5')]);_0x11a03f[_0x78ad('0x16')](_0x78ad('0x17'),JSON[_0x78ad('0x18')]({'id':_0x2d6eea['id'],'deleted':!![]}));})['then'](function(){_0x3b888b[_0x78ad('0x19')](0xcc)[_0x78ad('0x1a')]();});}};}function handleEntityNotFound(_0x4f947e){return function(_0x3e233b){if(!_0x3e233b){_0x4f947e['sendStatus'](0x194);}return _0x3e233b;};}function handleError(_0x26a175,_0x423221){_0x423221=_0x423221||0x1f4;return function(_0xdace9b){logger[_0x78ad('0x1b')](_0xdace9b[_0x78ad('0x1c')]);if(_0xdace9b['name']){delete _0xdace9b[_0x78ad('0x1d')];}_0x26a175['status'](_0x423221)['send'](_0xdace9b);};}exports[_0x78ad('0x1e')]=function(_0x4ea2f1,_0x193906){var _0x5088e5={},_0x5c0217={},_0x58498a={'count':0x0,'rows':[]};var _0x24704b=_[_0x78ad('0x1f')](db[_0x78ad('0x20')][_0x78ad('0x21')],function(_0x19d488){return{'name':_0x19d488['fieldName'],'type':_0x19d488[_0x78ad('0x22')][_0x78ad('0x23')]};});_0x5c0217[_0x78ad('0x24')]=_[_0x78ad('0x1f')](_0x24704b,_0x78ad('0x1d'));_0x5c0217[_0x78ad('0x25')]=_[_0x78ad('0x26')](_0x4ea2f1['query']);_0x5c0217[_0x78ad('0x27')]=_['intersection'](_0x5c0217['model'],_0x5c0217['query']);_0x5088e5[_0x78ad('0x28')]=_[_0x78ad('0x29')](_0x5c0217['model'],qs['fields'](_0x4ea2f1[_0x78ad('0x25')]['fields']));_0x5088e5['attributes']=_0x5088e5[_0x78ad('0x28')][_0x78ad('0x2a')]?_0x5088e5[_0x78ad('0x28')]:_0x5c0217[_0x78ad('0x24')];if(!_0x4ea2f1[_0x78ad('0x25')]['hasOwnProperty'](_0x78ad('0x2b'))){_0x5088e5[_0x78ad('0xd')]=qs[_0x78ad('0xd')](_0x4ea2f1[_0x78ad('0x25')][_0x78ad('0xd')]);_0x5088e5[_0x78ad('0xb')]=qs[_0x78ad('0xb')](_0x4ea2f1[_0x78ad('0x25')][_0x78ad('0xb')]);}_0x5088e5['order']=qs['sort'](_0x4ea2f1['query'][_0x78ad('0x2c')]);_0x5088e5[_0x78ad('0x2d')]=qs['filters'](_[_0x78ad('0x2e')](_0x4ea2f1['query'],_0x5c0217[_0x78ad('0x27')]),_0x24704b);if(_0x4ea2f1['query']['filter']){_0x5088e5[_0x78ad('0x2d')]=_[_0x78ad('0x2f')](_0x5088e5[_0x78ad('0x2d')],{'$or':_['map'](_0x24704b,function(_0x213259){if(_0x213259[_0x78ad('0x22')]!==_0x78ad('0x30')){var _0x54dd77={};_0x54dd77[_0x213259[_0x78ad('0x1d')]]={'$like':'%'+_0x4ea2f1[_0x78ad('0x25')]['filter']+'%'};return _0x54dd77;}})});}_0x5088e5=_[_0x78ad('0x2f')]({},_0x5088e5,_0x4ea2f1[_0x78ad('0x31')]);var _0x4a5d31={'where':_0x5088e5['where']};return db[_0x78ad('0x20')][_0x78ad('0x32')](_0x4a5d31)[_0x78ad('0x11')](function(_0x2cbdf0){_0x58498a[_0x78ad('0x32')]=_0x2cbdf0;if(_0x4ea2f1[_0x78ad('0x25')]['includeAll']){_0x5088e5[_0x78ad('0x33')]=[{'all':!![]}];}return db[_0x78ad('0x20')][_0x78ad('0x34')](_0x5088e5);})[_0x78ad('0x11')](function(_0x818e4d){_0x58498a[_0x78ad('0x35')]=_0x818e4d;return _0x58498a;})['then'](respondWithFilteredResult(_0x193906,_0x5088e5))['catch'](handleError(_0x193906,null));};exports[_0x78ad('0x36')]=function(_0x14ab8d,_0x448821){var _0x5df69f={'raw':![],'where':{'id':_0x14ab8d[_0x78ad('0x37')]['id']}},_0x5e4da2={};_0x5e4da2['model']=_[_0x78ad('0x26')](db[_0x78ad('0x20')]['rawAttributes']);_0x5e4da2[_0x78ad('0x25')]=_[_0x78ad('0x26')](_0x14ab8d[_0x78ad('0x25')]);_0x5e4da2[_0x78ad('0x27')]=_[_0x78ad('0x29')](_0x5e4da2[_0x78ad('0x24')],_0x5e4da2[_0x78ad('0x25')]);_0x5df69f['attributes']=_['intersection'](_0x5e4da2[_0x78ad('0x24')],qs[_0x78ad('0x38')](_0x14ab8d[_0x78ad('0x25')][_0x78ad('0x38')]));_0x5df69f[_0x78ad('0x28')]=_0x5df69f['attributes'][_0x78ad('0x2a')]?_0x5df69f[_0x78ad('0x28')]:_0x5e4da2[_0x78ad('0x24')];if(_0x14ab8d[_0x78ad('0x25')]['includeAll']){_0x5df69f['include']=[{'all':!![]}];}_0x5df69f=_[_0x78ad('0x2f')]({},_0x5df69f,_0x14ab8d['options']);return db[_0x78ad('0x20')][_0x78ad('0x39')](_0x5df69f)[_0x78ad('0x11')](handleEntityNotFound(_0x448821,null))['then'](respondWithResult(_0x448821,null))[_0x78ad('0x3a')](handleError(_0x448821,null));};exports[_0x78ad('0x3b')]=function(_0x2dd373,_0x504730){return db[_0x78ad('0x20')][_0x78ad('0x3b')](_0x2dd373[_0x78ad('0x3c')],{})[_0x78ad('0x11')](function(_0x4e1773){var _0x198fa4=_0x2dd373[_0x78ad('0x3d')][_0x78ad('0x12')]({'plain':!![]});if(!_0x198fa4)throw new Error(_0x78ad('0x3e'));if(_0x198fa4[_0x78ad('0x3f')]===_0x78ad('0x3d')){var _0x51b125=_0x4e1773[_0x78ad('0x12')]({'plain':!![]});var _0x2bff08=_0x78ad('0x13');return db[_0x78ad('0x40')][_0x78ad('0x39')]({'where':{'name':_0x2bff08,'userProfileId':_0x198fa4[_0x78ad('0x41')]},'raw':!![]})[_0x78ad('0x11')](function(_0x134c18){if(_0x134c18&&_0x134c18[_0x78ad('0x42')]===0x0){return db[_0x78ad('0x14')][_0x78ad('0x3b')]({'name':_0x51b125['name'],'resourceId':_0x51b125['id'],'type':_0x134c18[_0x78ad('0x1d')],'sectionId':_0x134c18['id']},{})[_0x78ad('0x11')](function(){return _0x4e1773;});}else{return _0x4e1773;}})[_0x78ad('0x3a')](function(_0x561d3c){logger[_0x78ad('0x1b')](_0x78ad('0x43'),_0x561d3c);throw _0x561d3c;});}return _0x4e1773;})['then'](respondWithResult(_0x504730,0xc9))[_0x78ad('0x3a')](handleError(_0x504730,null));};exports[_0x78ad('0x10')]=function(_0x4e64f7,_0x337256){if(_0x4e64f7['body']['id']){delete _0x4e64f7[_0x78ad('0x3c')]['id'];}return db[_0x78ad('0x20')][_0x78ad('0x39')]({'where':{'id':_0x4e64f7[_0x78ad('0x37')]['id']}})[_0x78ad('0x11')](handleEntityNotFound(_0x337256,null))['then'](saveUpdates(_0x4e64f7[_0x78ad('0x3c')],null))[_0x78ad('0x11')](function(_0x55c8ea){if(!_0x55c8ea)return;var _0x424c3a=_0x55c8ea[_0x78ad('0x12')]({'plain':!![]});return _0x424c3a;})[_0x78ad('0x11')](function(_0x3e587c){var _0x4c2d86=new Redis(config[_0x78ad('0x5')]);_0x4c2d86['publish'](_0x78ad('0x17'),JSON[_0x78ad('0x18')](_[_0x78ad('0x2e')](_0x3e587c,['id',_0x78ad('0x1d'),_0x78ad('0x44')])));return _0x3e587c;})['then'](respondWithResult(_0x337256,null))['catch'](handleError(_0x337256,null));};exports['destroy']=function(_0x4a0638,_0x127ffb){return db[_0x78ad('0x20')][_0x78ad('0x39')]({'where':{'id':_0x4a0638[_0x78ad('0x37')]['id']}})[_0x78ad('0x11')](handleEntityNotFound(_0x127ffb,null))[_0x78ad('0x11')](removeEntity(_0x127ffb,null))[_0x78ad('0x3a')](handleError(_0x127ffb,null));};
\ No newline at end of file