Built motion from commit 639a1a7f.|2.6.19
[motion2.git] / server / api / squareProject / squareProject.controller.js
index 8304851..2ba8bc4 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xa563=['count','offset','limit','set','json','reject','save','update','then','destroy','SquareProjects','end','error','stack','send','map','SquareProject','fieldName','key','model','query','filters','intersection','attributes','fields','hasOwnProperty','order','sort','where','filter','merge','type','VIRTUAL','name','options','includeAll','include','catch','show','params','rawAttributes','keys','length','create','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','userProfileId','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','find','addUsers','ids','omit','removeUsers','userSquareProject:remove','getUsers','pick','nolimit','html-pdf','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','sox','to-csv','ejs','lodash','crypto','desk.js','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../mysqldb','redis','localhost','socket.io-emitter','./squareProject.socket','register','sendStatus','status'];(function(_0x2b4411,_0x2625ed){var _0x8e41ef=function(_0x2aa8c1){while(--_0x2aa8c1){_0x2b4411['push'](_0x2b4411['shift']());}};_0x8e41ef(++_0x2625ed);}(_0xa563,0x96));var _0x3a56=function(_0x34f270,_0x26851b){_0x34f270=_0x34f270-0x0;var _0x172825=_0xa563[_0x34f270];return _0x172825;};'use strict';var pdf=require(_0x3a56('0x0'));var emlformat=require('eml-format');var rimraf=require(_0x3a56('0x1'));var zipdir=require(_0x3a56('0x2'));var jsonpatch=require(_0x3a56('0x3'));var rp=require(_0x3a56('0x4'));var moment=require(_0x3a56('0x5'));var BPromise=require(_0x3a56('0x6'));var Mustache=require(_0x3a56('0x7'));var util=require(_0x3a56('0x8'));var path=require('path');var sox=require(_0x3a56('0x9'));var csv=require(_0x3a56('0xa'));var ejs=require(_0x3a56('0xb'));var fs=require('fs');var _=require(_0x3a56('0xc'));var squel=require('squel');var crypto=require(_0x3a56('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x3a56('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0x3a56('0xf'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x3a56('0x10'));var as=require(_0x3a56('0x11'));var hardwareService=require(_0x3a56('0x12'));var logger=require('../../config/logger')(_0x3a56('0x13'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x3a56('0x14'))['db'];config[_0x3a56('0x15')]=_['defaults'](config[_0x3a56('0x15')],{'host':_0x3a56('0x16'),'port':0x18eb});var socket=require(_0x3a56('0x17'))(new Redis(config[_0x3a56('0x15')]));require(_0x3a56('0x18'))[_0x3a56('0x19')](socket);function respondWithStatusCode(_0x341905,_0x26814e){_0x26814e=_0x26814e||0xcc;return function(_0x4081b3){if(_0x4081b3){return _0x341905[_0x3a56('0x1a')](_0x26814e);}return _0x341905[_0x3a56('0x1b')](_0x26814e)['end']();};}function respondWithResult(_0x3e97d6,_0x8ae283){_0x8ae283=_0x8ae283||0xc8;return function(_0x4f95de){if(_0x4f95de){return _0x3e97d6['status'](_0x8ae283)['json'](_0x4f95de);}};}function respondWithFilteredResult(_0x31cae3,_0x330963){return function(_0x32656c){if(_0x32656c){var _0x47120a=_0x32656c[_0x3a56('0x1c')],_0x4b81e0=_0x330963[_0x3a56('0x1d')],_0x510844=_0x330963[_0x3a56('0x1d')]+_0x330963[_0x3a56('0x1e')],_0x32a65c;if(_0x510844>=_0x47120a){_0x510844=_0x47120a;_0x32a65c=0xc8;}else{_0x32a65c=0xce;}_0x31cae3['status'](_0x32a65c);return _0x31cae3[_0x3a56('0x1f')]('Content-Range',_0x4b81e0+'-'+_0x510844+'/'+_0x47120a)[_0x3a56('0x20')](_0x32656c);}return null;};}function patchUpdates(_0x1a3bd5){return function(_0x2f6664){try{jsonpatch['apply'](_0x2f6664,_0x1a3bd5,!![]);}catch(_0x511242){return BPromise[_0x3a56('0x21')](_0x511242);}return _0x2f6664[_0x3a56('0x22')]();};}function saveUpdates(_0x14b392,_0x366c7b){return function(_0x51979f){if(_0x51979f){return _0x51979f[_0x3a56('0x23')](_0x14b392)[_0x3a56('0x24')](function(_0x1d3778){return _0x1d3778;});}return null;};}function removeEntity(_0x342b28,_0x3881e0){return function(_0x3de523){if(_0x3de523){return _0x3de523[_0x3a56('0x25')]()['then'](function(){var _0x5d8e66=_0x3de523['get']({'plain':!![]});var _0x5ae0f3=_0x3a56('0x26');return db['UserProfileResource'][_0x3a56('0x25')]({'where':{'type':_0x5ae0f3,'resourceId':_0x5d8e66['id']}})['then'](function(){return _0x3de523;});})[_0x3a56('0x24')](function(){_0x342b28[_0x3a56('0x1b')](0xcc)[_0x3a56('0x27')]();});}};}function handleEntityNotFound(_0x247af3,_0x627275){return function(_0xef580e){if(!_0xef580e){_0x247af3['sendStatus'](0x194);}return _0xef580e;};}function handleError(_0x2b1954,_0x342ecb){_0x342ecb=_0x342ecb||0x1f4;return function(_0x37df96){logger[_0x3a56('0x28')](_0x37df96[_0x3a56('0x29')]);if(_0x37df96['name']){delete _0x37df96['name'];}_0x2b1954['status'](_0x342ecb)[_0x3a56('0x2a')](_0x37df96);};}exports['index']=function(_0x2c1a39,_0x62a6fb){var _0x49a0f2={},_0x17a800={},_0x14b9a8={'count':0x0,'rows':[]};var _0x163dc3=_[_0x3a56('0x2b')](db[_0x3a56('0x2c')]['rawAttributes'],function(_0xba6d80){return{'name':_0xba6d80[_0x3a56('0x2d')],'type':_0xba6d80['type'][_0x3a56('0x2e')]};});_0x17a800[_0x3a56('0x2f')]=_[_0x3a56('0x2b')](_0x163dc3,'name');_0x17a800[_0x3a56('0x30')]=_['keys'](_0x2c1a39[_0x3a56('0x30')]);_0x17a800[_0x3a56('0x31')]=_[_0x3a56('0x32')](_0x17a800[_0x3a56('0x2f')],_0x17a800['query']);_0x49a0f2[_0x3a56('0x33')]=_['intersection'](_0x17a800[_0x3a56('0x2f')],qs[_0x3a56('0x34')](_0x2c1a39[_0x3a56('0x30')][_0x3a56('0x34')]));_0x49a0f2[_0x3a56('0x33')]=_0x49a0f2['attributes']['length']?_0x49a0f2[_0x3a56('0x33')]:_0x17a800[_0x3a56('0x2f')];if(!_0x2c1a39[_0x3a56('0x30')][_0x3a56('0x35')]('nolimit')){_0x49a0f2['limit']=qs[_0x3a56('0x1e')](_0x2c1a39['query'][_0x3a56('0x1e')]);_0x49a0f2[_0x3a56('0x1d')]=qs[_0x3a56('0x1d')](_0x2c1a39['query'][_0x3a56('0x1d')]);}_0x49a0f2[_0x3a56('0x36')]=qs[_0x3a56('0x37')](_0x2c1a39['query'][_0x3a56('0x37')]);_0x49a0f2[_0x3a56('0x38')]=qs[_0x3a56('0x31')](_['pick'](_0x2c1a39[_0x3a56('0x30')],_0x17a800['filters']),_0x163dc3);if(_0x2c1a39['query'][_0x3a56('0x39')]){_0x49a0f2['where']=_[_0x3a56('0x3a')](_0x49a0f2[_0x3a56('0x38')],{'$or':_[_0x3a56('0x2b')](_0x163dc3,function(_0x117d50){if(_0x117d50[_0x3a56('0x3b')]!==_0x3a56('0x3c')){var _0x3680ea={};_0x3680ea[_0x117d50[_0x3a56('0x3d')]]={'$like':'%'+_0x2c1a39[_0x3a56('0x30')][_0x3a56('0x39')]+'%'};return _0x3680ea;}})});}_0x49a0f2=_['merge']({},_0x49a0f2,_0x2c1a39[_0x3a56('0x3e')]);var _0x2ab54d={'where':_0x49a0f2[_0x3a56('0x38')]};return db['SquareProject'][_0x3a56('0x1c')](_0x2ab54d)[_0x3a56('0x24')](function(_0x14e7f9){_0x14b9a8['count']=_0x14e7f9;if(_0x2c1a39[_0x3a56('0x30')][_0x3a56('0x3f')]){_0x49a0f2[_0x3a56('0x40')]=[{'all':!![]}];}return db[_0x3a56('0x2c')]['findAll'](_0x49a0f2);})['then'](function(_0xf1628a){_0x14b9a8['rows']=_0xf1628a;return _0x14b9a8;})[_0x3a56('0x24')](respondWithFilteredResult(_0x62a6fb,_0x49a0f2))[_0x3a56('0x41')](handleError(_0x62a6fb,null));};exports[_0x3a56('0x42')]=function(_0x2103ca,_0x1f0e87){var _0x2213a4={'raw':![],'where':{'id':_0x2103ca[_0x3a56('0x43')]['id']}},_0x43d6d3={};_0x43d6d3['model']=_['keys'](db['SquareProject'][_0x3a56('0x44')]);_0x43d6d3[_0x3a56('0x30')]=_[_0x3a56('0x45')](_0x2103ca['query']);_0x43d6d3[_0x3a56('0x31')]=_[_0x3a56('0x32')](_0x43d6d3[_0x3a56('0x2f')],_0x43d6d3[_0x3a56('0x30')]);_0x2213a4['attributes']=_[_0x3a56('0x32')](_0x43d6d3[_0x3a56('0x2f')],qs[_0x3a56('0x34')](_0x2103ca[_0x3a56('0x30')][_0x3a56('0x34')]));_0x2213a4[_0x3a56('0x33')]=_0x2213a4[_0x3a56('0x33')][_0x3a56('0x46')]?_0x2213a4[_0x3a56('0x33')]:_0x43d6d3[_0x3a56('0x2f')];if(_0x2103ca[_0x3a56('0x30')]['includeAll']){_0x2213a4['include']=[{'all':!![]}];}_0x2213a4=_[_0x3a56('0x3a')]({},_0x2213a4,_0x2103ca[_0x3a56('0x3e')]);return db[_0x3a56('0x2c')]['find'](_0x2213a4)[_0x3a56('0x24')](handleEntityNotFound(_0x1f0e87,null))['then'](respondWithResult(_0x1f0e87,null))[_0x3a56('0x41')](handleError(_0x1f0e87,null));};exports[_0x3a56('0x47')]=function(_0x5ac0ae,_0x1e57ca){return db[_0x3a56('0x2c')][_0x3a56('0x47')](_0x5ac0ae['body'],{})[_0x3a56('0x24')](function(_0x44bea4){var _0x36d970=_0x5ac0ae[_0x3a56('0x48')][_0x3a56('0x49')]({'plain':!![]});if(!_0x36d970)throw new Error(_0x3a56('0x4a'));if(_0x36d970[_0x3a56('0x4b')]==='user'){var _0x37cac8=_0x44bea4[_0x3a56('0x49')]({'plain':!![]});var _0x3233fd=_0x3a56('0x26');return db['UserProfileSection']['find']({'where':{'name':_0x3233fd,'userProfileId':_0x36d970[_0x3a56('0x4c')]},'raw':!![]})[_0x3a56('0x24')](function(_0x4218d0){if(_0x4218d0&&_0x4218d0['autoAssociation']===0x0){return db[_0x3a56('0x4d')][_0x3a56('0x47')]({'name':_0x37cac8[_0x3a56('0x3d')],'resourceId':_0x37cac8['id'],'type':_0x4218d0[_0x3a56('0x3d')],'sectionId':_0x4218d0['id']},{})['then'](function(){return _0x44bea4;});}else{return _0x44bea4;}})[_0x3a56('0x41')](function(_0x3057ff){logger['error'](_0x3a56('0x4e'),_0x3057ff);throw _0x3057ff;});}return _0x44bea4;})['then'](respondWithResult(_0x1e57ca,0xc9))['catch'](handleError(_0x1e57ca,null));};exports[_0x3a56('0x23')]=function(_0x40e757,_0x2cb5e6){if(_0x40e757[_0x3a56('0x4f')]['id']){delete _0x40e757[_0x3a56('0x4f')]['id'];}return db[_0x3a56('0x2c')][_0x3a56('0x50')]({'where':{'id':_0x40e757[_0x3a56('0x43')]['id']}})['then'](handleEntityNotFound(_0x2cb5e6,null))[_0x3a56('0x24')](saveUpdates(_0x40e757[_0x3a56('0x4f')],null))['then'](respondWithResult(_0x2cb5e6,null))[_0x3a56('0x41')](handleError(_0x2cb5e6,null));};exports[_0x3a56('0x25')]=function(_0x238b8b,_0x5eae11){return db[_0x3a56('0x2c')]['find']({'where':{'id':_0x238b8b['params']['id']}})['then'](handleEntityNotFound(_0x5eae11,null))[_0x3a56('0x24')](removeEntity(_0x5eae11,null))[_0x3a56('0x41')](handleError(_0x5eae11,null));};exports[_0x3a56('0x51')]=function(_0x3fff34,_0x24c22e,_0x394f11){return db[_0x3a56('0x2c')]['find']({'where':{'id':_0x3fff34[_0x3a56('0x43')]['id']}})[_0x3a56('0x24')](handleEntityNotFound(_0x24c22e,null))[_0x3a56('0x24')](function(_0x45a624){if(_0x45a624){return _0x45a624[_0x3a56('0x51')](_0x3fff34[_0x3a56('0x4f')][_0x3a56('0x52')],_[_0x3a56('0x53')](_0x3fff34[_0x3a56('0x4f')],[_0x3a56('0x52'),'id'])||{});}})[_0x3a56('0x24')](respondWithResult(_0x24c22e,null))[_0x3a56('0x41')](handleError(_0x24c22e,null));};exports[_0x3a56('0x54')]=function(_0x110db2,_0x5789a0,_0x123750){return db[_0x3a56('0x2c')][_0x3a56('0x50')]({'where':{'id':_0x110db2['params']['id']}})[_0x3a56('0x24')](handleEntityNotFound(_0x5789a0,null))[_0x3a56('0x24')](function(_0x578cd9){if(_0x578cd9){return _0x578cd9['removeUsers'](_0x110db2['query']['ids'])['then'](function(){if(_['isArray'](_0x110db2['query'][_0x3a56('0x52')])){for(var _0xb376da=0x0;_0xb376da<_0x110db2['query']['ids'][_0x3a56('0x46')];_0xb376da+=0x1){socket['emit'](_0x3a56('0x55'),{'UserId':Number(_0x110db2[_0x3a56('0x30')][_0x3a56('0x52')][_0xb376da]),'SquareProjectId':Number(_0x110db2['params']['id'])});}}else{socket['emit'](_0x3a56('0x55'),{'UserId':Number(_0x110db2[_0x3a56('0x30')][_0x3a56('0x52')]),'SquareProjectId':Number(_0x110db2[_0x3a56('0x43')]['id'])});}});}})[_0x3a56('0x24')](respondWithStatusCode(_0x5789a0,null))[_0x3a56('0x41')](handleError(_0x5789a0,null));};exports[_0x3a56('0x56')]=function(_0x2532d0,_0x38883a,_0x19087a){var _0x1c6cc4={};var _0x2da427={};var _0x69fab9;var _0x1fc836;return db['SquareProject']['findOne']({'where':{'id':_0x2532d0[_0x3a56('0x43')]['id']}})[_0x3a56('0x24')](handleEntityNotFound(_0x38883a,null))[_0x3a56('0x24')](function(_0x14ec61){if(_0x14ec61){_0x69fab9=_0x14ec61;_0x2da427[_0x3a56('0x2f')]=_[_0x3a56('0x45')](db['User']['rawAttributes']);_0x2da427[_0x3a56('0x30')]=_[_0x3a56('0x45')](_0x2532d0[_0x3a56('0x30')]);_0x2da427['filters']=_[_0x3a56('0x32')](_0x2da427[_0x3a56('0x2f')],_0x2da427['query']);_0x1c6cc4[_0x3a56('0x33')]=_[_0x3a56('0x32')](_0x2da427[_0x3a56('0x2f')],qs[_0x3a56('0x34')](_0x2532d0[_0x3a56('0x30')][_0x3a56('0x34')]));_0x1c6cc4[_0x3a56('0x33')]=_0x1c6cc4[_0x3a56('0x33')][_0x3a56('0x46')]?_0x1c6cc4[_0x3a56('0x33')]:_0x2da427[_0x3a56('0x2f')];_0x1c6cc4[_0x3a56('0x36')]=qs[_0x3a56('0x37')](_0x2532d0['query'][_0x3a56('0x37')]);_0x1c6cc4[_0x3a56('0x38')]=qs[_0x3a56('0x31')](_[_0x3a56('0x57')](_0x2532d0['query'],_0x2da427[_0x3a56('0x31')]));if(_0x2532d0[_0x3a56('0x30')]['filter']){_0x1c6cc4[_0x3a56('0x38')]=_[_0x3a56('0x3a')](_0x1c6cc4[_0x3a56('0x38')],{'$or':_[_0x3a56('0x2b')](_0x1c6cc4[_0x3a56('0x33')],function(_0x3c37a4){var _0x50a9cb={};_0x50a9cb[_0x3c37a4]={'$like':'%'+_0x2532d0[_0x3a56('0x30')][_0x3a56('0x39')]+'%'};return _0x50a9cb;})});}_0x1c6cc4=_[_0x3a56('0x3a')]({},_0x1c6cc4,_0x2532d0['options']);return _0x69fab9[_0x3a56('0x56')](_0x1c6cc4);}})[_0x3a56('0x24')](function(_0x41dc3f){if(_0x41dc3f){_0x1fc836=_0x41dc3f[_0x3a56('0x46')];if(!_0x2532d0['query'][_0x3a56('0x35')](_0x3a56('0x58'))){_0x1c6cc4[_0x3a56('0x1e')]=qs[_0x3a56('0x1e')](_0x2532d0['query'][_0x3a56('0x1e')]);_0x1c6cc4[_0x3a56('0x1d')]=qs[_0x3a56('0x1d')](_0x2532d0[_0x3a56('0x30')][_0x3a56('0x1d')]);}return _0x69fab9[_0x3a56('0x56')](_0x1c6cc4);}})[_0x3a56('0x24')](function(_0x1b725e){if(_0x1b725e){return _0x1b725e?{'count':_0x1fc836,'rows':_0x1b725e}:null;}})[_0x3a56('0x24')](respondWithResult(_0x38883a,null))[_0x3a56('0x41')](handleError(_0x38883a,null));};
\ No newline at end of file
+var _0xf485=['includeAll','include','findAll','rows','catch','show','keys','rawAttributes','intersection','find','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','update','body','params','production','lodash','../../components/parsers/qs','../../config/logger','api','../../config/environment','redis','defaults','localhost','./squareProject.socket','register','status','json','offset','limit','undefined','count','set','Content-Range','then','destroy','get','SquareProjects','UserProfileResource','publish','agi','stringify','sendStatus','error','stack','name','send','index','map','fieldName','key','model','query','filters','fields','attributes','length','nolimit','sort','where','pick','merge','VIRTUAL','options','SquareProject'];(function(_0x4408f6,_0x597ade){var _0x31f8fd=function(_0x384b2a){while(--_0x384b2a){_0x4408f6['push'](_0x4408f6['shift']());}};_0x31f8fd(++_0x597ade);}(_0xf485,0xe7));var _0x5f48=function(_0x3b8597,_0x57ce17){_0x3b8597=_0x3b8597-0x0;var _0x2089dc=_0xf485[_0x3b8597];return _0x2089dc;};'use strict';var _=require(_0x5f48('0x0'));var Redis=require('ioredis');var qs=require(_0x5f48('0x1'));var logger=require(_0x5f48('0x2'))(_0x5f48('0x3'));var config=require(_0x5f48('0x4'));var db=require('../../mysqldb')['db'];config[_0x5f48('0x5')]=_[_0x5f48('0x6')](config[_0x5f48('0x5')],{'host':_0x5f48('0x7'),'port':0x18eb});var socket=require('socket.io-emitter')(new Redis(config['redis']));require(_0x5f48('0x8'))[_0x5f48('0x9')](socket);function respondWithResult(_0x5ad1f6,_0x3a23ce){_0x3a23ce=_0x3a23ce||0xc8;return function(_0x47e52f){if(_0x47e52f){return _0x5ad1f6[_0x5f48('0xa')](_0x3a23ce)[_0x5f48('0xb')](_0x47e52f);}};}function respondWithFilteredResult(_0x2ae04f,_0x4991e9){return function(_0x20b040){if(_0x20b040){var _0x62d41e=typeof _0x4991e9[_0x5f48('0xc')]==='undefined'&&typeof _0x4991e9[_0x5f48('0xd')]===_0x5f48('0xe');var _0x43cc94=_0x20b040[_0x5f48('0xf')];var _0x586228=_0x62d41e?0x0:_0x4991e9[_0x5f48('0xc')];var _0x149b4c=_0x62d41e?_0x20b040[_0x5f48('0xf')]:_0x4991e9['offset']+_0x4991e9[_0x5f48('0xd')];var _0x1bf082;if(_0x149b4c>=_0x43cc94){_0x149b4c=_0x43cc94;_0x1bf082=0xc8;}else{_0x1bf082=0xce;}_0x2ae04f[_0x5f48('0xa')](_0x1bf082);return _0x2ae04f[_0x5f48('0x10')](_0x5f48('0x11'),_0x586228+'-'+_0x149b4c+'/'+_0x43cc94)[_0x5f48('0xb')](_0x20b040);}return null;};}function saveUpdates(_0x402c29){return function(_0x24fcbc){if(_0x24fcbc){return _0x24fcbc['update'](_0x402c29)[_0x5f48('0x12')](function(_0x545e3c){return _0x545e3c;});}return null;};}function removeEntity(_0x546d78){return function(_0x4d2c10){if(_0x4d2c10){return _0x4d2c10[_0x5f48('0x13')]()['then'](function(){var _0x3a3c54=_0x4d2c10[_0x5f48('0x14')]({'plain':!![]});var _0x3624a4=_0x5f48('0x15');return db[_0x5f48('0x16')][_0x5f48('0x13')]({'where':{'type':_0x3624a4,'resourceId':_0x3a3c54['id']}})[_0x5f48('0x12')](function(){return _0x4d2c10;});})['then'](function(){var _0x58a07f=new Redis(config[_0x5f48('0x5')]);_0x58a07f[_0x5f48('0x17')](_0x5f48('0x18'),JSON[_0x5f48('0x19')]({'id':_0x4d2c10['id'],'deleted':!![]}));})[_0x5f48('0x12')](function(){_0x546d78['status'](0xcc)['end']();});}};}function handleEntityNotFound(_0x315393){return function(_0x1c8048){if(!_0x1c8048){_0x315393[_0x5f48('0x1a')](0x194);}return _0x1c8048;};}function handleError(_0x376592,_0x4440e8){_0x4440e8=_0x4440e8||0x1f4;return function(_0x6e307b){logger[_0x5f48('0x1b')](_0x6e307b[_0x5f48('0x1c')]);if(_0x6e307b[_0x5f48('0x1d')]){delete _0x6e307b['name'];}_0x376592[_0x5f48('0xa')](_0x4440e8)[_0x5f48('0x1e')](_0x6e307b);};}exports[_0x5f48('0x1f')]=function(_0x46dd83,_0x192816){var _0x1992a1={},_0x3cb5c7={},_0x1f72d9={'count':0x0,'rows':[]};var _0x45ac33=_[_0x5f48('0x20')](db['SquareProject']['rawAttributes'],function(_0x228f21){return{'name':_0x228f21[_0x5f48('0x21')],'type':_0x228f21['type'][_0x5f48('0x22')]};});_0x3cb5c7[_0x5f48('0x23')]=_[_0x5f48('0x20')](_0x45ac33,_0x5f48('0x1d'));_0x3cb5c7[_0x5f48('0x24')]=_['keys'](_0x46dd83['query']);_0x3cb5c7[_0x5f48('0x25')]=_['intersection'](_0x3cb5c7['model'],_0x3cb5c7[_0x5f48('0x24')]);_0x1992a1['attributes']=_['intersection'](_0x3cb5c7[_0x5f48('0x23')],qs[_0x5f48('0x26')](_0x46dd83[_0x5f48('0x24')][_0x5f48('0x26')]));_0x1992a1[_0x5f48('0x27')]=_0x1992a1['attributes'][_0x5f48('0x28')]?_0x1992a1['attributes']:_0x3cb5c7[_0x5f48('0x23')];if(!_0x46dd83[_0x5f48('0x24')]['hasOwnProperty'](_0x5f48('0x29'))){_0x1992a1[_0x5f48('0xd')]=qs['limit'](_0x46dd83[_0x5f48('0x24')]['limit']);_0x1992a1[_0x5f48('0xc')]=qs[_0x5f48('0xc')](_0x46dd83[_0x5f48('0x24')]['offset']);}_0x1992a1['order']=qs[_0x5f48('0x2a')](_0x46dd83[_0x5f48('0x24')][_0x5f48('0x2a')]);_0x1992a1[_0x5f48('0x2b')]=qs['filters'](_[_0x5f48('0x2c')](_0x46dd83[_0x5f48('0x24')],_0x3cb5c7[_0x5f48('0x25')]),_0x45ac33);if(_0x46dd83[_0x5f48('0x24')]['filter']){_0x1992a1['where']=_[_0x5f48('0x2d')](_0x1992a1['where'],{'$or':_[_0x5f48('0x20')](_0x45ac33,function(_0x3e7345){if(_0x3e7345['type']!==_0x5f48('0x2e')){var _0x5ec385={};_0x5ec385[_0x3e7345[_0x5f48('0x1d')]]={'$like':'%'+_0x46dd83[_0x5f48('0x24')]['filter']+'%'};return _0x5ec385;}})});}_0x1992a1=_[_0x5f48('0x2d')]({},_0x1992a1,_0x46dd83[_0x5f48('0x2f')]);var _0x120084={'where':_0x1992a1[_0x5f48('0x2b')]};return db[_0x5f48('0x30')]['count'](_0x120084)[_0x5f48('0x12')](function(_0x3cfba9){_0x1f72d9['count']=_0x3cfba9;if(_0x46dd83['query'][_0x5f48('0x31')]){_0x1992a1[_0x5f48('0x32')]=[{'all':!![]}];}return db['SquareProject'][_0x5f48('0x33')](_0x1992a1);})[_0x5f48('0x12')](function(_0x3f9ce1){_0x1f72d9[_0x5f48('0x34')]=_0x3f9ce1;return _0x1f72d9;})[_0x5f48('0x12')](respondWithFilteredResult(_0x192816,_0x1992a1))[_0x5f48('0x35')](handleError(_0x192816,null));};exports[_0x5f48('0x36')]=function(_0x444bb8,_0x547a22){var _0xc91b01={'raw':![],'where':{'id':_0x444bb8['params']['id']}},_0x373149={};_0x373149[_0x5f48('0x23')]=_[_0x5f48('0x37')](db[_0x5f48('0x30')][_0x5f48('0x38')]);_0x373149['query']=_[_0x5f48('0x37')](_0x444bb8[_0x5f48('0x24')]);_0x373149[_0x5f48('0x25')]=_[_0x5f48('0x39')](_0x373149[_0x5f48('0x23')],_0x373149[_0x5f48('0x24')]);_0xc91b01[_0x5f48('0x27')]=_[_0x5f48('0x39')](_0x373149[_0x5f48('0x23')],qs['fields'](_0x444bb8[_0x5f48('0x24')][_0x5f48('0x26')]));_0xc91b01[_0x5f48('0x27')]=_0xc91b01[_0x5f48('0x27')][_0x5f48('0x28')]?_0xc91b01[_0x5f48('0x27')]:_0x373149[_0x5f48('0x23')];if(_0x444bb8[_0x5f48('0x24')][_0x5f48('0x31')]){_0xc91b01[_0x5f48('0x32')]=[{'all':!![]}];}_0xc91b01=_[_0x5f48('0x2d')]({},_0xc91b01,_0x444bb8['options']);return db[_0x5f48('0x30')][_0x5f48('0x3a')](_0xc91b01)[_0x5f48('0x12')](handleEntityNotFound(_0x547a22,null))[_0x5f48('0x12')](respondWithResult(_0x547a22,null))[_0x5f48('0x35')](handleError(_0x547a22,null));};exports[_0x5f48('0x3b')]=function(_0x5ae128,_0x338354){return db[_0x5f48('0x30')][_0x5f48('0x3b')](_0x5ae128['body'],{})[_0x5f48('0x12')](function(_0x220e34){var _0x23f6bc=_0x5ae128[_0x5f48('0x3c')]['get']({'plain':!![]});if(!_0x23f6bc)throw new Error(_0x5f48('0x3d'));if(_0x23f6bc[_0x5f48('0x3e')]===_0x5f48('0x3c')){var _0x518efb=_0x220e34[_0x5f48('0x14')]({'plain':!![]});var _0x38c8b4=_0x5f48('0x15');return db[_0x5f48('0x3f')]['find']({'where':{'name':_0x38c8b4,'userProfileId':_0x23f6bc[_0x5f48('0x40')]},'raw':!![]})[_0x5f48('0x12')](function(_0x3ebaf2){if(_0x3ebaf2&&_0x3ebaf2[_0x5f48('0x41')]===0x0){return db[_0x5f48('0x16')]['create']({'name':_0x518efb['name'],'resourceId':_0x518efb['id'],'type':_0x3ebaf2[_0x5f48('0x1d')],'sectionId':_0x3ebaf2['id']},{})[_0x5f48('0x12')](function(){return _0x220e34;});}else{return _0x220e34;}})['catch'](function(_0x19953a){logger[_0x5f48('0x1b')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x19953a);throw _0x19953a;});}return _0x220e34;})[_0x5f48('0x12')](respondWithResult(_0x338354,0xc9))[_0x5f48('0x35')](handleError(_0x338354,null));};exports[_0x5f48('0x42')]=function(_0x13f9fc,_0x5ab9ed){if(_0x13f9fc['body']['id']){delete _0x13f9fc[_0x5f48('0x43')]['id'];}return db[_0x5f48('0x30')][_0x5f48('0x3a')]({'where':{'id':_0x13f9fc[_0x5f48('0x44')]['id']}})[_0x5f48('0x12')](handleEntityNotFound(_0x5ab9ed,null))[_0x5f48('0x12')](saveUpdates(_0x13f9fc[_0x5f48('0x43')],null))[_0x5f48('0x12')](function(_0x416e59){if(!_0x416e59)return;var _0x9e1f82=_0x416e59['get']({'plain':!![]});return _0x9e1f82;})[_0x5f48('0x12')](function(_0x1dc33c){var _0x4a45d2=new Redis(config[_0x5f48('0x5')]);_0x4a45d2[_0x5f48('0x17')](_0x5f48('0x18'),JSON[_0x5f48('0x19')](_[_0x5f48('0x2c')](_0x1dc33c,['id',_0x5f48('0x1d'),_0x5f48('0x45')])));return _0x1dc33c;})[_0x5f48('0x12')](respondWithResult(_0x5ab9ed,null))[_0x5f48('0x35')](handleError(_0x5ab9ed,null));};exports[_0x5f48('0x13')]=function(_0x58af4c,_0x3d9fb0){return db[_0x5f48('0x30')]['find']({'where':{'id':_0x58af4c[_0x5f48('0x44')]['id']}})[_0x5f48('0x12')](handleEntityNotFound(_0x3d9fb0,null))['then'](removeEntity(_0x3d9fb0,null))[_0x5f48('0x35')](handleError(_0x3d9fb0,null));};
\ No newline at end of file