Built motion from commit ffdca78c.|2.6.24
[motion2.git] / server / api / variable / variable.controller.js
index 4547328..5b5f0ec 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x27ff=['keys','filters','intersection','fields','attributes','length','nolimit','order','sort','pick','where','merge','filter','options','includeAll','include','findAll','rows','params','find','create','body','user','UserProfileSection','userProfileId','catch','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','eml-format','rimraf','zip-dir','moment','mustache','path','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','to-csv','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','offset','undefined','limit','count','Content-Range','apply','save','then','destroy','get','Variables','UserProfileResource','error','stack','name','send','index','map','Variable','rawAttributes','fieldName','type','key','model','query'];(function(_0x1789c3,_0x29b7d4){var _0x16f236=function(_0x5e1006){while(--_0x5e1006){_0x1789c3['push'](_0x1789c3['shift']());}};_0x16f236(++_0x29b7d4);}(_0x27ff,0x158));var _0xf27f=function(_0x3b5f66,_0x1dbfc5){_0x3b5f66=_0x3b5f66-0x0;var _0x4aa1a8=_0x27ff[_0x3b5f66];return _0x4aa1a8;};'use strict';var emlformat=require(_0xf27f('0x0'));var rimraf=require(_0xf27f('0x1'));var zipdir=require(_0xf27f('0x2'));var jsonpatch=require('fast-json-patch');var rp=require('request-promise');var moment=require(_0xf27f('0x3'));var BPromise=require('bluebird');var Mustache=require(_0xf27f('0x4'));var util=require('util');var path=require(_0xf27f('0x5'));var sox=require(_0xf27f('0x6'));var csv=require('to-csv');var ejs=require(_0xf27f('0x7'));var fs=require('fs');var fs_extra=require(_0xf27f('0x8'));var _=require(_0xf27f('0x9'));var squel=require(_0xf27f('0xa'));var crypto=require(_0xf27f('0xb'));var jsforce=require(_0xf27f('0xc'));var deskjs=require('desk.js');var toCsv=require(_0xf27f('0xd'));var querystring=require(_0xf27f('0xe'));var Papa=require('papaparse');var Redis=require(_0xf27f('0xf'));var authService=require(_0xf27f('0x10'));var qs=require('../../components/parsers/qs');var as=require(_0xf27f('0x11'));var hardwareService=require(_0xf27f('0x12'));var logger=require(_0xf27f('0x13'))('api');var utils=require('../../config/utils');var config=require(_0xf27f('0x14'));var licenseUtil=require(_0xf27f('0x15'));var db=require(_0xf27f('0x16'))['db'];function respondWithStatusCode(_0x47ddfa,_0x3f0b48){_0x3f0b48=_0x3f0b48||0xcc;return function(_0xfa50e7){if(_0xfa50e7){return _0x47ddfa[_0xf27f('0x17')](_0x3f0b48);}return _0x47ddfa[_0xf27f('0x18')](_0x3f0b48)['end']();};}function respondWithResult(_0x4a9fdb,_0x3f2b5e){_0x3f2b5e=_0x3f2b5e||0xc8;return function(_0xbe0d81){if(_0xbe0d81){return _0x4a9fdb[_0xf27f('0x18')](_0x3f2b5e)[_0xf27f('0x19')](_0xbe0d81);}};}function respondWithFilteredResult(_0x4a5b08,_0x49d836){return function(_0x1dc9f1){if(_0x1dc9f1){var _0x90ad4c=typeof _0x49d836[_0xf27f('0x1a')]===_0xf27f('0x1b')&&typeof _0x49d836[_0xf27f('0x1c')]===_0xf27f('0x1b');var _0x21538d=_0x1dc9f1[_0xf27f('0x1d')];var _0x1f40fa=_0x90ad4c?0x0:_0x49d836[_0xf27f('0x1a')];var _0x28e4b6=_0x90ad4c?_0x1dc9f1[_0xf27f('0x1d')]:_0x49d836[_0xf27f('0x1a')]+_0x49d836[_0xf27f('0x1c')];var _0xa383e9;if(_0x28e4b6>=_0x21538d){_0x28e4b6=_0x21538d;_0xa383e9=0xc8;}else{_0xa383e9=0xce;}_0x4a5b08['status'](_0xa383e9);return _0x4a5b08['set'](_0xf27f('0x1e'),_0x1f40fa+'-'+_0x28e4b6+'/'+_0x21538d)[_0xf27f('0x19')](_0x1dc9f1);}return null;};}function patchUpdates(_0x359816){return function(_0x3957ad){try{jsonpatch[_0xf27f('0x1f')](_0x3957ad,_0x359816,!![]);}catch(_0x56c2aa){return BPromise['reject'](_0x56c2aa);}return _0x3957ad[_0xf27f('0x20')]();};}function saveUpdates(_0x15130d,_0x2a7217){return function(_0x1b815c){if(_0x1b815c){return _0x1b815c['update'](_0x15130d)[_0xf27f('0x21')](function(_0x38214a){return _0x38214a;});}return null;};}function removeEntity(_0x2ac8c3,_0x2d9087){return function(_0x5bcf09){if(_0x5bcf09){return _0x5bcf09[_0xf27f('0x22')]()['then'](function(){var _0x1e0d17=_0x5bcf09[_0xf27f('0x23')]({'plain':!![]});var _0x18bea0=_0xf27f('0x24');return db[_0xf27f('0x25')][_0xf27f('0x22')]({'where':{'type':_0x18bea0,'resourceId':_0x1e0d17['id']}})[_0xf27f('0x21')](function(){return _0x5bcf09;});})[_0xf27f('0x21')](function(){_0x2ac8c3[_0xf27f('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x4a07cb,_0x5aea24){return function(_0x40d7e1){if(!_0x40d7e1){_0x4a07cb[_0xf27f('0x17')](0x194);}return _0x40d7e1;};}function handleError(_0x313b21,_0x2d7256){_0x2d7256=_0x2d7256||0x1f4;return function(_0x36803e){logger[_0xf27f('0x26')](_0x36803e[_0xf27f('0x27')]);if(_0x36803e['name']){delete _0x36803e[_0xf27f('0x28')];}_0x313b21['status'](_0x2d7256)[_0xf27f('0x29')](_0x36803e);};}exports[_0xf27f('0x2a')]=function(_0x347555,_0x79ac22){var _0x5d47b8={},_0x2353a3={},_0x2f20e9={'count':0x0,'rows':[]};var _0x2bf4bd=_[_0xf27f('0x2b')](db[_0xf27f('0x2c')][_0xf27f('0x2d')],function(_0x5e89f3){return{'name':_0x5e89f3[_0xf27f('0x2e')],'type':_0x5e89f3[_0xf27f('0x2f')][_0xf27f('0x30')]};});_0x2353a3[_0xf27f('0x31')]=_['map'](_0x2bf4bd,'name');_0x2353a3[_0xf27f('0x32')]=_[_0xf27f('0x33')](_0x347555['query']);_0x2353a3[_0xf27f('0x34')]=_[_0xf27f('0x35')](_0x2353a3['model'],_0x2353a3['query']);_0x5d47b8['attributes']=_[_0xf27f('0x35')](_0x2353a3[_0xf27f('0x31')],qs[_0xf27f('0x36')](_0x347555[_0xf27f('0x32')][_0xf27f('0x36')]));_0x5d47b8[_0xf27f('0x37')]=_0x5d47b8[_0xf27f('0x37')][_0xf27f('0x38')]?_0x5d47b8[_0xf27f('0x37')]:_0x2353a3['model'];if(!_0x347555['query']['hasOwnProperty'](_0xf27f('0x39'))){_0x5d47b8[_0xf27f('0x1c')]=qs['limit'](_0x347555['query'][_0xf27f('0x1c')]);_0x5d47b8['offset']=qs[_0xf27f('0x1a')](_0x347555['query'][_0xf27f('0x1a')]);}_0x5d47b8[_0xf27f('0x3a')]=qs[_0xf27f('0x3b')](_0x347555[_0xf27f('0x32')]['sort']);_0x5d47b8['where']=qs['filters'](_[_0xf27f('0x3c')](_0x347555['query'],_0x2353a3[_0xf27f('0x34')]),_0x2bf4bd);if(_0x347555[_0xf27f('0x32')]['filter']){_0x5d47b8[_0xf27f('0x3d')]=_[_0xf27f('0x3e')](_0x5d47b8[_0xf27f('0x3d')],{'$or':_[_0xf27f('0x2b')](_0x2bf4bd,function(_0x5098ae){if(_0x5098ae[_0xf27f('0x2f')]!=='VIRTUAL'){var _0x24e550={};_0x24e550[_0x5098ae[_0xf27f('0x28')]]={'$like':'%'+_0x347555[_0xf27f('0x32')][_0xf27f('0x3f')]+'%'};return _0x24e550;}})});}_0x5d47b8=_[_0xf27f('0x3e')]({},_0x5d47b8,_0x347555[_0xf27f('0x40')]);var _0x1245c6={'where':_0x5d47b8['where']};return db['Variable'][_0xf27f('0x1d')](_0x1245c6)[_0xf27f('0x21')](function(_0x2c2484){_0x2f20e9[_0xf27f('0x1d')]=_0x2c2484;if(_0x347555['query'][_0xf27f('0x41')]){_0x5d47b8[_0xf27f('0x42')]=[{'all':!![]}];}return db[_0xf27f('0x2c')][_0xf27f('0x43')](_0x5d47b8);})['then'](function(_0x4e4750){_0x2f20e9[_0xf27f('0x44')]=_0x4e4750;return _0x2f20e9;})[_0xf27f('0x21')](respondWithFilteredResult(_0x79ac22,_0x5d47b8))['catch'](handleError(_0x79ac22,null));};exports['show']=function(_0x12c119,_0x3ae450){var _0x2e673a={'raw':!![],'where':{'id':_0x12c119[_0xf27f('0x45')]['id']}},_0x15b558={};_0x15b558[_0xf27f('0x31')]=_[_0xf27f('0x33')](db['Variable'][_0xf27f('0x2d')]);_0x15b558[_0xf27f('0x32')]=_['keys'](_0x12c119[_0xf27f('0x32')]);_0x15b558[_0xf27f('0x34')]=_[_0xf27f('0x35')](_0x15b558[_0xf27f('0x31')],_0x15b558[_0xf27f('0x32')]);_0x2e673a[_0xf27f('0x37')]=_['intersection'](_0x15b558[_0xf27f('0x31')],qs[_0xf27f('0x36')](_0x12c119[_0xf27f('0x32')][_0xf27f('0x36')]));_0x2e673a[_0xf27f('0x37')]=_0x2e673a[_0xf27f('0x37')]['length']?_0x2e673a[_0xf27f('0x37')]:_0x15b558['model'];if(_0x12c119[_0xf27f('0x32')][_0xf27f('0x41')]){_0x2e673a[_0xf27f('0x42')]=[{'all':!![]}];}_0x2e673a=_[_0xf27f('0x3e')]({},_0x2e673a,_0x12c119[_0xf27f('0x40')]);return db[_0xf27f('0x2c')][_0xf27f('0x46')](_0x2e673a)['then'](handleEntityNotFound(_0x3ae450,null))[_0xf27f('0x21')](respondWithResult(_0x3ae450,null))['catch'](handleError(_0x3ae450,null));};exports[_0xf27f('0x47')]=function(_0x2637a4,_0x2f2613){return db['Variable'][_0xf27f('0x47')](_0x2637a4[_0xf27f('0x48')],{})[_0xf27f('0x21')](function(_0x1310de){var _0x56a58c=_0x2637a4[_0xf27f('0x49')]['get']({'plain':!![]});if(!_0x56a58c)throw new Error('Unable\x20to\x20retrieve\x20the\x20current\x20user');if(_0x56a58c['role']===_0xf27f('0x49')){var _0x391a80=_0x1310de['get']({'plain':!![]});var _0x1b4d72=_0xf27f('0x24');return db[_0xf27f('0x4a')][_0xf27f('0x46')]({'where':{'name':_0x1b4d72,'userProfileId':_0x56a58c[_0xf27f('0x4b')]},'raw':!![]})[_0xf27f('0x21')](function(_0x402408){if(_0x402408&&_0x402408['autoAssociation']===0x0){return db['UserProfileResource'][_0xf27f('0x47')]({'name':_0x391a80[_0xf27f('0x28')],'resourceId':_0x391a80['id'],'type':_0x402408[_0xf27f('0x28')],'sectionId':_0x402408['id']},{})[_0xf27f('0x21')](function(){return _0x1310de;});}else{return _0x1310de;}})[_0xf27f('0x4c')](function(_0x1e5483){logger[_0xf27f('0x26')](_0xf27f('0x4d'),_0x1e5483);throw _0x1e5483;});}return _0x1310de;})[_0xf27f('0x21')](respondWithResult(_0x2f2613,0xc9))[_0xf27f('0x4c')](handleError(_0x2f2613,null));};exports[_0xf27f('0x4e')]=function(_0x573e61,_0x2ef2f1){if(_0x573e61['body']['id']){delete _0x573e61[_0xf27f('0x48')]['id'];}return db[_0xf27f('0x2c')]['find']({'where':{'id':_0x573e61[_0xf27f('0x45')]['id']}})[_0xf27f('0x21')](handleEntityNotFound(_0x2ef2f1,null))['then'](saveUpdates(_0x573e61[_0xf27f('0x48')],null))[_0xf27f('0x21')](respondWithResult(_0x2ef2f1,null))['catch'](handleError(_0x2ef2f1,null));};exports[_0xf27f('0x22')]=function(_0x92cff9,_0x4cd33c){return db[_0xf27f('0x2c')]['find']({'where':{'id':_0x92cff9['params']['id']}})[_0xf27f('0x21')](handleEntityNotFound(_0x4cd33c,null))['then'](removeEntity(_0x4cd33c,null))[_0xf27f('0x4c')](handleError(_0x4cd33c,null));};
\ No newline at end of file
+var _0xc2f5=['error','stack','name','Variable','rawAttributes','fieldName','key','model','query','keys','filters','fields','attributes','nolimit','limit','order','sort','filter','where','merge','map','VIRTUAL','options','includeAll','rows','catch','show','params','intersection','length','include','create','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','find','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','body','destroy','eml-format','rimraf','fast-json-patch','request-promise','moment','util','path','to-csv','ejs','fs-extra','lodash','jsforce','desk.js','querystring','papaparse','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','end','json','offset','count','apply','reject','save','update','then','get','Variables','UserProfileResource'];(function(_0x351509,_0x54725c){var _0x4e9861=function(_0x54f92c){while(--_0x54f92c){_0x351509['push'](_0x351509['shift']());}};_0x4e9861(++_0x54725c);}(_0xc2f5,0x10f));var _0x5c2f=function(_0x37fbe7,_0x367180){_0x37fbe7=_0x37fbe7-0x0;var _0x158032=_0xc2f5[_0x37fbe7];return _0x158032;};'use strict';var emlformat=require(_0x5c2f('0x0'));var rimraf=require(_0x5c2f('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x5c2f('0x2'));var rp=require(_0x5c2f('0x3'));var moment=require(_0x5c2f('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x5c2f('0x5'));var path=require(_0x5c2f('0x6'));var sox=require('sox');var csv=require(_0x5c2f('0x7'));var ejs=require(_0x5c2f('0x8'));var fs=require('fs');var fs_extra=require(_0x5c2f('0x9'));var _=require(_0x5c2f('0xa'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x5c2f('0xb'));var deskjs=require(_0x5c2f('0xc'));var toCsv=require(_0x5c2f('0x7'));var querystring=require(_0x5c2f('0xd'));var Papa=require(_0x5c2f('0xe'));var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x5c2f('0xf'));var as=require(_0x5c2f('0x10'));var hardwareService=require(_0x5c2f('0x11'));var logger=require(_0x5c2f('0x12'))(_0x5c2f('0x13'));var utils=require(_0x5c2f('0x14'));var config=require(_0x5c2f('0x15'));var licenseUtil=require(_0x5c2f('0x16'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x51e015,_0x45ebac){_0x45ebac=_0x45ebac||0xcc;return function(_0x12ffae){if(_0x12ffae){return _0x51e015[_0x5c2f('0x17')](_0x45ebac);}return _0x51e015[_0x5c2f('0x18')](_0x45ebac)[_0x5c2f('0x19')]();};}function respondWithResult(_0x49f97c,_0x1671a6){_0x1671a6=_0x1671a6||0xc8;return function(_0x1bcd97){if(_0x1bcd97){return _0x49f97c['status'](_0x1671a6)[_0x5c2f('0x1a')](_0x1bcd97);}};}function respondWithFilteredResult(_0x45e4d4,_0x5f50a6){return function(_0x4dffd1){if(_0x4dffd1){var _0x285b44=typeof _0x5f50a6[_0x5c2f('0x1b')]==='undefined'&&typeof _0x5f50a6['limit']==='undefined';var _0x1463f6=_0x4dffd1[_0x5c2f('0x1c')];var _0x28719c=_0x285b44?0x0:_0x5f50a6[_0x5c2f('0x1b')];var _0x51527f=_0x285b44?_0x4dffd1['count']:_0x5f50a6[_0x5c2f('0x1b')]+_0x5f50a6['limit'];var _0x30ecd6;if(_0x51527f>=_0x1463f6){_0x51527f=_0x1463f6;_0x30ecd6=0xc8;}else{_0x30ecd6=0xce;}_0x45e4d4[_0x5c2f('0x18')](_0x30ecd6);return _0x45e4d4['set']('Content-Range',_0x28719c+'-'+_0x51527f+'/'+_0x1463f6)['json'](_0x4dffd1);}return null;};}function patchUpdates(_0x3ce879){return function(_0xbcee77){try{jsonpatch[_0x5c2f('0x1d')](_0xbcee77,_0x3ce879,!![]);}catch(_0x22f07a){return BPromise[_0x5c2f('0x1e')](_0x22f07a);}return _0xbcee77[_0x5c2f('0x1f')]();};}function saveUpdates(_0x443e74,_0xcffc36){return function(_0x28b765){if(_0x28b765){return _0x28b765[_0x5c2f('0x20')](_0x443e74)[_0x5c2f('0x21')](function(_0x142f67){return _0x142f67;});}return null;};}function removeEntity(_0x2961cd,_0x438ca6){return function(_0x3d18d7){if(_0x3d18d7){return _0x3d18d7['destroy']()[_0x5c2f('0x21')](function(){var _0x144444=_0x3d18d7[_0x5c2f('0x22')]({'plain':!![]});var _0x3fa35c=_0x5c2f('0x23');return db[_0x5c2f('0x24')]['destroy']({'where':{'type':_0x3fa35c,'resourceId':_0x144444['id']}})[_0x5c2f('0x21')](function(){return _0x3d18d7;});})[_0x5c2f('0x21')](function(){_0x2961cd['status'](0xcc)[_0x5c2f('0x19')]();});}};}function handleEntityNotFound(_0x13d164,_0x8ca40){return function(_0x57dd52){if(!_0x57dd52){_0x13d164[_0x5c2f('0x17')](0x194);}return _0x57dd52;};}function handleError(_0x2532db,_0x14052d){_0x14052d=_0x14052d||0x1f4;return function(_0x2a10b6){logger[_0x5c2f('0x25')](_0x2a10b6[_0x5c2f('0x26')]);if(_0x2a10b6[_0x5c2f('0x27')]){delete _0x2a10b6[_0x5c2f('0x27')];}_0x2532db[_0x5c2f('0x18')](_0x14052d)['send'](_0x2a10b6);};}exports['index']=function(_0x42a3d6,_0x47b5ef){var _0x9319c8={},_0x5d735c={},_0x4a364a={'count':0x0,'rows':[]};var _0x48e7cd=_['map'](db[_0x5c2f('0x28')][_0x5c2f('0x29')],function(_0x27d8b9){return{'name':_0x27d8b9[_0x5c2f('0x2a')],'type':_0x27d8b9['type'][_0x5c2f('0x2b')]};});_0x5d735c[_0x5c2f('0x2c')]=_['map'](_0x48e7cd,_0x5c2f('0x27'));_0x5d735c[_0x5c2f('0x2d')]=_[_0x5c2f('0x2e')](_0x42a3d6[_0x5c2f('0x2d')]);_0x5d735c[_0x5c2f('0x2f')]=_['intersection'](_0x5d735c['model'],_0x5d735c[_0x5c2f('0x2d')]);_0x9319c8['attributes']=_['intersection'](_0x5d735c[_0x5c2f('0x2c')],qs[_0x5c2f('0x30')](_0x42a3d6[_0x5c2f('0x2d')]['fields']));_0x9319c8[_0x5c2f('0x31')]=_0x9319c8[_0x5c2f('0x31')]['length']?_0x9319c8[_0x5c2f('0x31')]:_0x5d735c[_0x5c2f('0x2c')];if(!_0x42a3d6[_0x5c2f('0x2d')]['hasOwnProperty'](_0x5c2f('0x32'))){_0x9319c8['limit']=qs[_0x5c2f('0x33')](_0x42a3d6[_0x5c2f('0x2d')][_0x5c2f('0x33')]);_0x9319c8[_0x5c2f('0x1b')]=qs[_0x5c2f('0x1b')](_0x42a3d6[_0x5c2f('0x2d')][_0x5c2f('0x1b')]);}_0x9319c8[_0x5c2f('0x34')]=qs[_0x5c2f('0x35')](_0x42a3d6[_0x5c2f('0x2d')][_0x5c2f('0x35')]);_0x9319c8['where']=qs[_0x5c2f('0x2f')](_['pick'](_0x42a3d6[_0x5c2f('0x2d')],_0x5d735c['filters']),_0x48e7cd);if(_0x42a3d6[_0x5c2f('0x2d')][_0x5c2f('0x36')]){_0x9319c8[_0x5c2f('0x37')]=_[_0x5c2f('0x38')](_0x9319c8[_0x5c2f('0x37')],{'$or':_[_0x5c2f('0x39')](_0x48e7cd,function(_0x58119e){if(_0x58119e['type']!==_0x5c2f('0x3a')){var _0x13924f={};_0x13924f[_0x58119e[_0x5c2f('0x27')]]={'$like':'%'+_0x42a3d6[_0x5c2f('0x2d')]['filter']+'%'};return _0x13924f;}})});}_0x9319c8=_[_0x5c2f('0x38')]({},_0x9319c8,_0x42a3d6[_0x5c2f('0x3b')]);var _0x12abaf={'where':_0x9319c8['where']};return db['Variable']['count'](_0x12abaf)['then'](function(_0xa3ced6){_0x4a364a['count']=_0xa3ced6;if(_0x42a3d6['query'][_0x5c2f('0x3c')]){_0x9319c8['include']=[{'all':!![]}];}return db[_0x5c2f('0x28')]['findAll'](_0x9319c8);})[_0x5c2f('0x21')](function(_0x5c1dce){_0x4a364a[_0x5c2f('0x3d')]=_0x5c1dce;return _0x4a364a;})[_0x5c2f('0x21')](respondWithFilteredResult(_0x47b5ef,_0x9319c8))[_0x5c2f('0x3e')](handleError(_0x47b5ef,null));};exports[_0x5c2f('0x3f')]=function(_0x571cbb,_0x589a12){var _0x56ce8c={'raw':!![],'where':{'id':_0x571cbb[_0x5c2f('0x40')]['id']}},_0x51307e={};_0x51307e['model']=_[_0x5c2f('0x2e')](db['Variable'][_0x5c2f('0x29')]);_0x51307e['query']=_[_0x5c2f('0x2e')](_0x571cbb[_0x5c2f('0x2d')]);_0x51307e[_0x5c2f('0x2f')]=_[_0x5c2f('0x41')](_0x51307e[_0x5c2f('0x2c')],_0x51307e['query']);_0x56ce8c[_0x5c2f('0x31')]=_[_0x5c2f('0x41')](_0x51307e[_0x5c2f('0x2c')],qs[_0x5c2f('0x30')](_0x571cbb[_0x5c2f('0x2d')][_0x5c2f('0x30')]));_0x56ce8c[_0x5c2f('0x31')]=_0x56ce8c['attributes'][_0x5c2f('0x42')]?_0x56ce8c['attributes']:_0x51307e[_0x5c2f('0x2c')];if(_0x571cbb[_0x5c2f('0x2d')]['includeAll']){_0x56ce8c[_0x5c2f('0x43')]=[{'all':!![]}];}_0x56ce8c=_[_0x5c2f('0x38')]({},_0x56ce8c,_0x571cbb['options']);return db[_0x5c2f('0x28')]['find'](_0x56ce8c)[_0x5c2f('0x21')](handleEntityNotFound(_0x589a12,null))[_0x5c2f('0x21')](respondWithResult(_0x589a12,null))[_0x5c2f('0x3e')](handleError(_0x589a12,null));};exports[_0x5c2f('0x44')]=function(_0x106e00,_0x40af3d){return db[_0x5c2f('0x28')]['create'](_0x106e00['body'],{})[_0x5c2f('0x21')](function(_0x48a67f){var _0xc3c2eb=_0x106e00[_0x5c2f('0x45')][_0x5c2f('0x22')]({'plain':!![]});if(!_0xc3c2eb)throw new Error(_0x5c2f('0x46'));if(_0xc3c2eb['role']===_0x5c2f('0x45')){var _0x1c960d=_0x48a67f[_0x5c2f('0x22')]({'plain':!![]});var _0x430fed=_0x5c2f('0x23');return db[_0x5c2f('0x47')][_0x5c2f('0x48')]({'where':{'name':_0x430fed,'userProfileId':_0xc3c2eb['userProfileId']},'raw':!![]})['then'](function(_0x1bc589){if(_0x1bc589&&_0x1bc589[_0x5c2f('0x49')]===0x0){return db[_0x5c2f('0x24')][_0x5c2f('0x44')]({'name':_0x1c960d['name'],'resourceId':_0x1c960d['id'],'type':_0x1bc589[_0x5c2f('0x27')],'sectionId':_0x1bc589['id']},{})[_0x5c2f('0x21')](function(){return _0x48a67f;});}else{return _0x48a67f;}})[_0x5c2f('0x3e')](function(_0x57a6d0){logger[_0x5c2f('0x25')](_0x5c2f('0x4a'),_0x57a6d0);throw _0x57a6d0;});}return _0x48a67f;})['then'](respondWithResult(_0x40af3d,0xc9))[_0x5c2f('0x3e')](handleError(_0x40af3d,null));};exports[_0x5c2f('0x20')]=function(_0x2fda16,_0x31d698){if(_0x2fda16['body']['id']){delete _0x2fda16[_0x5c2f('0x4b')]['id'];}return db[_0x5c2f('0x28')][_0x5c2f('0x48')]({'where':{'id':_0x2fda16[_0x5c2f('0x40')]['id']}})[_0x5c2f('0x21')](handleEntityNotFound(_0x31d698,null))['then'](saveUpdates(_0x2fda16[_0x5c2f('0x4b')],null))[_0x5c2f('0x21')](respondWithResult(_0x31d698,null))[_0x5c2f('0x3e')](handleError(_0x31d698,null));};exports[_0x5c2f('0x4c')]=function(_0x38a7ec,_0x24bb8c){return db[_0x5c2f('0x28')][_0x5c2f('0x48')]({'where':{'id':_0x38a7ec['params']['id']}})[_0x5c2f('0x21')](handleEntityNotFound(_0x24bb8c,null))['then'](removeEntity(_0x24bb8c,null))[_0x5c2f('0x3e')](handleError(_0x24bb8c,null));};
\ No newline at end of file