Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / template / template.controller.js
index 9824806..61086bb 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb460=['body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../mysqldb','sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','reject','get','Templates','UserProfileResource','destroy','then','stack','name','send','index','map','Template','fieldName','type','query','keys','intersection','model','attributes','fields','hasOwnProperty','order','sort','where','filters','pick','filter','merge','options','includeAll','include','rows','catch','show','params','rawAttributes','find','create'];(function(_0x3565ae,_0x42ce0e){var _0x1f6ef9=function(_0x27ffd8){while(--_0x27ffd8){_0x3565ae['push'](_0x3565ae['shift']());}};_0x1f6ef9(++_0x42ce0e);}(_0xb460,0x100));var _0x0b46=function(_0x5dee7f,_0x1451af){_0x5dee7f=_0x5dee7f-0x0;var _0x2699fa=_0xb460[_0x5dee7f];return _0x2699fa;};'use strict';var emlformat=require(_0x0b46('0x0'));var rimraf=require(_0x0b46('0x1'));var zipdir=require(_0x0b46('0x2'));var jsonpatch=require(_0x0b46('0x3'));var rp=require('request-promise');var moment=require(_0x0b46('0x4'));var BPromise=require(_0x0b46('0x5'));var Mustache=require('mustache');var util=require('util');var path=require(_0x0b46('0x6'));var sox=require(_0x0b46('0x7'));var csv=require(_0x0b46('0x8'));var ejs=require(_0x0b46('0x9'));var fs=require('fs');var fs_extra=require(_0x0b46('0xa'));var _=require(_0x0b46('0xb'));var squel=require(_0x0b46('0xc'));var crypto=require('crypto');var jsforce=require(_0x0b46('0xd'));var deskjs=require(_0x0b46('0xe'));var toCsv=require('to-csv');var querystring=require(_0x0b46('0xf'));var Papa=require(_0x0b46('0x10'));var Redis=require('ioredis');var authService=require(_0x0b46('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x0b46('0x12'));var hardwareService=require(_0x0b46('0x13'));var logger=require(_0x0b46('0x14'))(_0x0b46('0x15'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x0b46('0x16'))['db'];function respondWithStatusCode(_0xf4d219,_0x3470c7){_0x3470c7=_0x3470c7||0xcc;return function(_0x22a8a8){if(_0x22a8a8){return _0xf4d219[_0x0b46('0x17')](_0x3470c7);}return _0xf4d219[_0x0b46('0x18')](_0x3470c7)[_0x0b46('0x19')]();};}function respondWithResult(_0x310a75,_0x81820a){_0x81820a=_0x81820a||0xc8;return function(_0xea587a){if(_0xea587a){return _0x310a75[_0x0b46('0x18')](_0x81820a)[_0x0b46('0x1a')](_0xea587a);}};}function respondWithFilteredResult(_0x14a482,_0x599578){return function(_0x36a226){if(_0x36a226){var _0x1911e3=typeof _0x599578['offset']===_0x0b46('0x1b')&&typeof _0x599578[_0x0b46('0x1c')]===_0x0b46('0x1b');var _0x41f195=_0x36a226[_0x0b46('0x1d')];var _0xe3792=_0x1911e3?0x0:_0x599578[_0x0b46('0x1e')];var _0x17fc0b=_0x1911e3?_0x36a226[_0x0b46('0x1d')]:_0x599578['offset']+_0x599578[_0x0b46('0x1c')];var _0x4ec3e4;if(_0x17fc0b>=_0x41f195){_0x17fc0b=_0x41f195;_0x4ec3e4=0xc8;}else{_0x4ec3e4=0xce;}_0x14a482[_0x0b46('0x18')](_0x4ec3e4);return _0x14a482[_0x0b46('0x1f')](_0x0b46('0x20'),_0xe3792+'-'+_0x17fc0b+'/'+_0x41f195)[_0x0b46('0x1a')](_0x36a226);}return null;};}function patchUpdates(_0x5ef155){return function(_0x18b979){try{jsonpatch[_0x0b46('0x21')](_0x18b979,_0x5ef155,!![]);}catch(_0x449116){return BPromise[_0x0b46('0x22')](_0x449116);}return _0x18b979['save']();};}function saveUpdates(_0x45bde3,_0x78ee7b){return function(_0x3a449e){if(_0x3a449e){return _0x3a449e['update'](_0x45bde3)['then'](function(_0x2c7f6e){return _0x2c7f6e;});}return null;};}function removeEntity(_0x57dfa5,_0x58b24c){return function(_0x235696){if(_0x235696){return _0x235696['destroy']()['then'](function(){var _0x2944ad=_0x235696[_0x0b46('0x23')]({'plain':!![]});var _0x49057e=_0x0b46('0x24');return db[_0x0b46('0x25')][_0x0b46('0x26')]({'where':{'type':_0x49057e,'resourceId':_0x2944ad['id']}})[_0x0b46('0x27')](function(){return _0x235696;});})[_0x0b46('0x27')](function(){_0x57dfa5[_0x0b46('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x382911,_0x414af8){return function(_0x221a39){if(!_0x221a39){_0x382911[_0x0b46('0x17')](0x194);}return _0x221a39;};}function handleError(_0x457968,_0x2d6d74){_0x2d6d74=_0x2d6d74||0x1f4;return function(_0x56abd9){logger['error'](_0x56abd9[_0x0b46('0x28')]);if(_0x56abd9[_0x0b46('0x29')]){delete _0x56abd9[_0x0b46('0x29')];}_0x457968[_0x0b46('0x18')](_0x2d6d74)[_0x0b46('0x2a')](_0x56abd9);};}exports[_0x0b46('0x2b')]=function(_0x49b536,_0x19566e){var _0x5b50f6={},_0xf44c94={},_0x4df1f5={'count':0x0,'rows':[]};var _0x5db314=_[_0x0b46('0x2c')](db[_0x0b46('0x2d')]['rawAttributes'],function(_0x4e4eb3){return{'name':_0x4e4eb3[_0x0b46('0x2e')],'type':_0x4e4eb3[_0x0b46('0x2f')]['key']};});_0xf44c94['model']=_[_0x0b46('0x2c')](_0x5db314,_0x0b46('0x29'));_0xf44c94[_0x0b46('0x30')]=_[_0x0b46('0x31')](_0x49b536[_0x0b46('0x30')]);_0xf44c94['filters']=_[_0x0b46('0x32')](_0xf44c94[_0x0b46('0x33')],_0xf44c94[_0x0b46('0x30')]);_0x5b50f6[_0x0b46('0x34')]=_[_0x0b46('0x32')](_0xf44c94['model'],qs[_0x0b46('0x35')](_0x49b536[_0x0b46('0x30')][_0x0b46('0x35')]));_0x5b50f6[_0x0b46('0x34')]=_0x5b50f6[_0x0b46('0x34')]['length']?_0x5b50f6['attributes']:_0xf44c94['model'];if(!_0x49b536[_0x0b46('0x30')][_0x0b46('0x36')]('nolimit')){_0x5b50f6[_0x0b46('0x1c')]=qs[_0x0b46('0x1c')](_0x49b536['query'][_0x0b46('0x1c')]);_0x5b50f6[_0x0b46('0x1e')]=qs['offset'](_0x49b536['query'][_0x0b46('0x1e')]);}_0x5b50f6[_0x0b46('0x37')]=qs[_0x0b46('0x38')](_0x49b536[_0x0b46('0x30')][_0x0b46('0x38')]);_0x5b50f6[_0x0b46('0x39')]=qs[_0x0b46('0x3a')](_[_0x0b46('0x3b')](_0x49b536[_0x0b46('0x30')],_0xf44c94[_0x0b46('0x3a')]),_0x5db314);if(_0x49b536[_0x0b46('0x30')][_0x0b46('0x3c')]){_0x5b50f6[_0x0b46('0x39')]=_[_0x0b46('0x3d')](_0x5b50f6[_0x0b46('0x39')],{'$or':_[_0x0b46('0x2c')](_0x5db314,function(_0x3639e5){if(_0x3639e5[_0x0b46('0x2f')]!=='VIRTUAL'){var _0x1eda1d={};_0x1eda1d[_0x3639e5['name']]={'$like':'%'+_0x49b536[_0x0b46('0x30')][_0x0b46('0x3c')]+'%'};return _0x1eda1d;}})});}_0x5b50f6=_[_0x0b46('0x3d')]({},_0x5b50f6,_0x49b536[_0x0b46('0x3e')]);var _0x5680aa={'where':_0x5b50f6[_0x0b46('0x39')]};return db['Template'][_0x0b46('0x1d')](_0x5680aa)[_0x0b46('0x27')](function(_0x15c9c6){_0x4df1f5[_0x0b46('0x1d')]=_0x15c9c6;if(_0x49b536[_0x0b46('0x30')][_0x0b46('0x3f')]){_0x5b50f6[_0x0b46('0x40')]=[{'all':!![]}];}return db[_0x0b46('0x2d')]['findAll'](_0x5b50f6);})['then'](function(_0x18956b){_0x4df1f5[_0x0b46('0x41')]=_0x18956b;return _0x4df1f5;})[_0x0b46('0x27')](respondWithFilteredResult(_0x19566e,_0x5b50f6))[_0x0b46('0x42')](handleError(_0x19566e,null));};exports[_0x0b46('0x43')]=function(_0x47f09f,_0x4ae8b9){var _0x344e1f={'raw':!![],'where':{'id':_0x47f09f[_0x0b46('0x44')]['id']}},_0x5445fc={};_0x5445fc[_0x0b46('0x33')]=_['keys'](db[_0x0b46('0x2d')][_0x0b46('0x45')]);_0x5445fc['query']=_[_0x0b46('0x31')](_0x47f09f[_0x0b46('0x30')]);_0x5445fc[_0x0b46('0x3a')]=_[_0x0b46('0x32')](_0x5445fc[_0x0b46('0x33')],_0x5445fc['query']);_0x344e1f[_0x0b46('0x34')]=_[_0x0b46('0x32')](_0x5445fc[_0x0b46('0x33')],qs[_0x0b46('0x35')](_0x47f09f[_0x0b46('0x30')][_0x0b46('0x35')]));_0x344e1f[_0x0b46('0x34')]=_0x344e1f[_0x0b46('0x34')]['length']?_0x344e1f[_0x0b46('0x34')]:_0x5445fc['model'];if(_0x47f09f[_0x0b46('0x30')][_0x0b46('0x3f')]){_0x344e1f['include']=[{'all':!![]}];}_0x344e1f=_['merge']({},_0x344e1f,_0x47f09f[_0x0b46('0x3e')]);return db['Template'][_0x0b46('0x46')](_0x344e1f)[_0x0b46('0x27')](handleEntityNotFound(_0x4ae8b9,null))[_0x0b46('0x27')](respondWithResult(_0x4ae8b9,null))[_0x0b46('0x42')](handleError(_0x4ae8b9,null));};exports[_0x0b46('0x47')]=function(_0x5d8b09,_0x1d9a58){return db['Template'][_0x0b46('0x47')](_0x5d8b09[_0x0b46('0x48')],{})[_0x0b46('0x27')](function(_0x52c14a){var _0x1a9d38=_0x5d8b09[_0x0b46('0x49')]['get']({'plain':!![]});if(!_0x1a9d38)throw new Error(_0x0b46('0x4a'));if(_0x1a9d38[_0x0b46('0x4b')]===_0x0b46('0x49')){var _0xc43138=_0x52c14a[_0x0b46('0x23')]({'plain':!![]});var _0x107e66=_0x0b46('0x24');return db[_0x0b46('0x4c')][_0x0b46('0x46')]({'where':{'name':_0x107e66,'userProfileId':_0x1a9d38[_0x0b46('0x4d')]},'raw':!![]})[_0x0b46('0x27')](function(_0x3ba8e6){if(_0x3ba8e6&&_0x3ba8e6[_0x0b46('0x4e')]===0x0){return db[_0x0b46('0x25')][_0x0b46('0x47')]({'name':_0xc43138[_0x0b46('0x29')],'resourceId':_0xc43138['id'],'type':_0x3ba8e6['name'],'sectionId':_0x3ba8e6['id']},{})[_0x0b46('0x27')](function(){return _0x52c14a;});}else{return _0x52c14a;}})[_0x0b46('0x42')](function(_0x30a8a2){logger[_0x0b46('0x4f')](_0x0b46('0x50'),_0x30a8a2);throw _0x30a8a2;});}return _0x52c14a;})['then'](respondWithResult(_0x1d9a58,0xc9))['catch'](handleError(_0x1d9a58,null));};exports[_0x0b46('0x51')]=function(_0x1259ea,_0x352cf1){if(_0x1259ea[_0x0b46('0x48')]['id']){delete _0x1259ea[_0x0b46('0x48')]['id'];}return db[_0x0b46('0x2d')]['find']({'where':{'id':_0x1259ea[_0x0b46('0x44')]['id']}})[_0x0b46('0x27')](handleEntityNotFound(_0x352cf1,null))[_0x0b46('0x27')](saveUpdates(_0x1259ea[_0x0b46('0x48')],null))[_0x0b46('0x27')](respondWithResult(_0x352cf1,null))['catch'](handleError(_0x352cf1,null));};exports['destroy']=function(_0x2fc10b,_0x5e772d){return db[_0x0b46('0x2d')][_0x0b46('0x46')]({'where':{'id':_0x2fc10b[_0x0b46('0x44')]['id']}})[_0x0b46('0x27')](handleEntityNotFound(_0x5e772d,null))[_0x0b46('0x27')](removeEntity(_0x5e772d,null))[_0x0b46('0x42')](handleError(_0x5e772d,null));};
\ No newline at end of file
+var _0xf02b=['query','filters','intersection','attributes','fields','nolimit','order','sort','pick','filter','where','type','VIRTUAL','merge','options','includeAll','include','findAll','rows','catch','show','keys','length','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','eml-format','rimraf','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','squel','jsforce','desk.js','papaparse','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','api','../../config/utils','../../config/license/util','../../mysqldb','sendStatus','end','json','offset','undefined','limit','count','set','Content-Range','apply','reject','update','then','destroy','get','Templates','UserProfileResource','status','error','name','send','index','Template','rawAttributes','fieldName','key','model','map'];(function(_0x4c5c69,_0x356630){var _0x35a82c=function(_0x2ef5f2){while(--_0x2ef5f2){_0x4c5c69['push'](_0x4c5c69['shift']());}};_0x35a82c(++_0x356630);}(_0xf02b,0x77));var _0xbf02=function(_0x283a81,_0x42f033){_0x283a81=_0x283a81-0x0;var _0x57533f=_0xf02b[_0x283a81];return _0x57533f;};'use strict';var emlformat=require(_0xbf02('0x0'));var rimraf=require(_0xbf02('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0xbf02('0x2'));var rp=require('request-promise');var moment=require(_0xbf02('0x3'));var BPromise=require(_0xbf02('0x4'));var Mustache=require(_0xbf02('0x5'));var util=require(_0xbf02('0x6'));var path=require(_0xbf02('0x7'));var sox=require(_0xbf02('0x8'));var csv=require(_0xbf02('0x9'));var ejs=require(_0xbf02('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xbf02('0xb'));var squel=require(_0xbf02('0xc'));var crypto=require('crypto');var jsforce=require(_0xbf02('0xd'));var deskjs=require(_0xbf02('0xe'));var toCsv=require(_0xbf02('0x9'));var querystring=require('querystring');var Papa=require(_0xbf02('0xf'));var Redis=require('ioredis');var authService=require(_0xbf02('0x10'));var qs=require(_0xbf02('0x11'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbf02('0x12'));var logger=require('../../config/logger')(_0xbf02('0x13'));var utils=require(_0xbf02('0x14'));var config=require('../../config/environment');var licenseUtil=require(_0xbf02('0x15'));var db=require(_0xbf02('0x16'))['db'];function respondWithStatusCode(_0x41a407,_0x2a9de9){_0x2a9de9=_0x2a9de9||0xcc;return function(_0x3a49cc){if(_0x3a49cc){return _0x41a407[_0xbf02('0x17')](_0x2a9de9);}return _0x41a407['status'](_0x2a9de9)[_0xbf02('0x18')]();};}function respondWithResult(_0x2ad661,_0x290a1d){_0x290a1d=_0x290a1d||0xc8;return function(_0x232086){if(_0x232086){return _0x2ad661['status'](_0x290a1d)[_0xbf02('0x19')](_0x232086);}};}function respondWithFilteredResult(_0x2bb33b,_0x1c0c1d){return function(_0x1e31f9){if(_0x1e31f9){var _0x2a0525=typeof _0x1c0c1d[_0xbf02('0x1a')]===_0xbf02('0x1b')&&typeof _0x1c0c1d[_0xbf02('0x1c')]===_0xbf02('0x1b');var _0x4952e1=_0x1e31f9[_0xbf02('0x1d')];var _0x25b7ad=_0x2a0525?0x0:_0x1c0c1d[_0xbf02('0x1a')];var _0x27fc44=_0x2a0525?_0x1e31f9['count']:_0x1c0c1d[_0xbf02('0x1a')]+_0x1c0c1d[_0xbf02('0x1c')];var _0x3d32e9;if(_0x27fc44>=_0x4952e1){_0x27fc44=_0x4952e1;_0x3d32e9=0xc8;}else{_0x3d32e9=0xce;}_0x2bb33b['status'](_0x3d32e9);return _0x2bb33b[_0xbf02('0x1e')](_0xbf02('0x1f'),_0x25b7ad+'-'+_0x27fc44+'/'+_0x4952e1)[_0xbf02('0x19')](_0x1e31f9);}return null;};}function patchUpdates(_0x14098b){return function(_0x27c67b){try{jsonpatch[_0xbf02('0x20')](_0x27c67b,_0x14098b,!![]);}catch(_0x150ead){return BPromise[_0xbf02('0x21')](_0x150ead);}return _0x27c67b['save']();};}function saveUpdates(_0x2885c6,_0x3963f6){return function(_0x4bfdd6){if(_0x4bfdd6){return _0x4bfdd6[_0xbf02('0x22')](_0x2885c6)[_0xbf02('0x23')](function(_0x9b684e){return _0x9b684e;});}return null;};}function removeEntity(_0x40a367,_0x15e8e2){return function(_0x7ad728){if(_0x7ad728){return _0x7ad728[_0xbf02('0x24')]()[_0xbf02('0x23')](function(){var _0xfe11fb=_0x7ad728[_0xbf02('0x25')]({'plain':!![]});var _0x1b32c7=_0xbf02('0x26');return db[_0xbf02('0x27')][_0xbf02('0x24')]({'where':{'type':_0x1b32c7,'resourceId':_0xfe11fb['id']}})[_0xbf02('0x23')](function(){return _0x7ad728;});})['then'](function(){_0x40a367[_0xbf02('0x28')](0xcc)['end']();});}};}function handleEntityNotFound(_0xbab84c,_0x6b8a32){return function(_0x31b8de){if(!_0x31b8de){_0xbab84c[_0xbf02('0x17')](0x194);}return _0x31b8de;};}function handleError(_0x432b6d,_0x1eb06a){_0x1eb06a=_0x1eb06a||0x1f4;return function(_0x2b8603){logger[_0xbf02('0x29')](_0x2b8603['stack']);if(_0x2b8603['name']){delete _0x2b8603[_0xbf02('0x2a')];}_0x432b6d[_0xbf02('0x28')](_0x1eb06a)[_0xbf02('0x2b')](_0x2b8603);};}exports[_0xbf02('0x2c')]=function(_0x5b9195,_0x96ee09){var _0x271dc6={},_0x470f71={},_0x48573d={'count':0x0,'rows':[]};var _0x30bfe1=_['map'](db[_0xbf02('0x2d')][_0xbf02('0x2e')],function(_0x5d7863){return{'name':_0x5d7863[_0xbf02('0x2f')],'type':_0x5d7863['type'][_0xbf02('0x30')]};});_0x470f71[_0xbf02('0x31')]=_[_0xbf02('0x32')](_0x30bfe1,_0xbf02('0x2a'));_0x470f71[_0xbf02('0x33')]=_['keys'](_0x5b9195[_0xbf02('0x33')]);_0x470f71[_0xbf02('0x34')]=_[_0xbf02('0x35')](_0x470f71['model'],_0x470f71[_0xbf02('0x33')]);_0x271dc6[_0xbf02('0x36')]=_[_0xbf02('0x35')](_0x470f71['model'],qs[_0xbf02('0x37')](_0x5b9195['query']['fields']));_0x271dc6[_0xbf02('0x36')]=_0x271dc6[_0xbf02('0x36')]['length']?_0x271dc6[_0xbf02('0x36')]:_0x470f71[_0xbf02('0x31')];if(!_0x5b9195[_0xbf02('0x33')]['hasOwnProperty'](_0xbf02('0x38'))){_0x271dc6[_0xbf02('0x1c')]=qs['limit'](_0x5b9195[_0xbf02('0x33')][_0xbf02('0x1c')]);_0x271dc6[_0xbf02('0x1a')]=qs[_0xbf02('0x1a')](_0x5b9195['query'][_0xbf02('0x1a')]);}_0x271dc6[_0xbf02('0x39')]=qs[_0xbf02('0x3a')](_0x5b9195[_0xbf02('0x33')][_0xbf02('0x3a')]);_0x271dc6['where']=qs[_0xbf02('0x34')](_[_0xbf02('0x3b')](_0x5b9195['query'],_0x470f71['filters']),_0x30bfe1);if(_0x5b9195[_0xbf02('0x33')][_0xbf02('0x3c')]){_0x271dc6[_0xbf02('0x3d')]=_['merge'](_0x271dc6[_0xbf02('0x3d')],{'$or':_['map'](_0x30bfe1,function(_0x40ae65){if(_0x40ae65[_0xbf02('0x3e')]!==_0xbf02('0x3f')){var _0x5ed356={};_0x5ed356[_0x40ae65['name']]={'$like':'%'+_0x5b9195[_0xbf02('0x33')][_0xbf02('0x3c')]+'%'};return _0x5ed356;}})});}_0x271dc6=_[_0xbf02('0x40')]({},_0x271dc6,_0x5b9195[_0xbf02('0x41')]);var _0x596b28={'where':_0x271dc6['where']};return db[_0xbf02('0x2d')][_0xbf02('0x1d')](_0x596b28)['then'](function(_0x5f7a28){_0x48573d[_0xbf02('0x1d')]=_0x5f7a28;if(_0x5b9195['query'][_0xbf02('0x42')]){_0x271dc6[_0xbf02('0x43')]=[{'all':!![]}];}return db[_0xbf02('0x2d')][_0xbf02('0x44')](_0x271dc6);})[_0xbf02('0x23')](function(_0x376deb){_0x48573d[_0xbf02('0x45')]=_0x376deb;return _0x48573d;})['then'](respondWithFilteredResult(_0x96ee09,_0x271dc6))[_0xbf02('0x46')](handleError(_0x96ee09,null));};exports[_0xbf02('0x47')]=function(_0x3e2ffa,_0xb870d1){var _0x5ccf0a={'raw':!![],'where':{'id':_0x3e2ffa['params']['id']}},_0x115ca8={};_0x115ca8[_0xbf02('0x31')]=_[_0xbf02('0x48')](db[_0xbf02('0x2d')][_0xbf02('0x2e')]);_0x115ca8['query']=_[_0xbf02('0x48')](_0x3e2ffa[_0xbf02('0x33')]);_0x115ca8['filters']=_['intersection'](_0x115ca8[_0xbf02('0x31')],_0x115ca8[_0xbf02('0x33')]);_0x5ccf0a[_0xbf02('0x36')]=_['intersection'](_0x115ca8[_0xbf02('0x31')],qs['fields'](_0x3e2ffa['query']['fields']));_0x5ccf0a[_0xbf02('0x36')]=_0x5ccf0a[_0xbf02('0x36')][_0xbf02('0x49')]?_0x5ccf0a['attributes']:_0x115ca8[_0xbf02('0x31')];if(_0x3e2ffa['query']['includeAll']){_0x5ccf0a[_0xbf02('0x43')]=[{'all':!![]}];}_0x5ccf0a=_['merge']({},_0x5ccf0a,_0x3e2ffa['options']);return db[_0xbf02('0x2d')][_0xbf02('0x4a')](_0x5ccf0a)[_0xbf02('0x23')](handleEntityNotFound(_0xb870d1,null))[_0xbf02('0x23')](respondWithResult(_0xb870d1,null))[_0xbf02('0x46')](handleError(_0xb870d1,null));};exports[_0xbf02('0x4b')]=function(_0x5200fb,_0x41a02b){return db['Template'][_0xbf02('0x4b')](_0x5200fb[_0xbf02('0x4c')],{})['then'](function(_0x5ebf00){var _0x29b264=_0x5200fb[_0xbf02('0x4d')][_0xbf02('0x25')]({'plain':!![]});if(!_0x29b264)throw new Error(_0xbf02('0x4e'));if(_0x29b264[_0xbf02('0x4f')]==='user'){var _0x5e98e4=_0x5ebf00['get']({'plain':!![]});var _0x287612=_0xbf02('0x26');return db[_0xbf02('0x50')]['find']({'where':{'name':_0x287612,'userProfileId':_0x29b264[_0xbf02('0x51')]},'raw':!![]})[_0xbf02('0x23')](function(_0x398c13){if(_0x398c13&&_0x398c13[_0xbf02('0x52')]===0x0){return db[_0xbf02('0x27')][_0xbf02('0x4b')]({'name':_0x5e98e4[_0xbf02('0x2a')],'resourceId':_0x5e98e4['id'],'type':_0x398c13[_0xbf02('0x2a')],'sectionId':_0x398c13['id']},{})[_0xbf02('0x23')](function(){return _0x5ebf00;});}else{return _0x5ebf00;}})['catch'](function(_0x29f21c){logger[_0xbf02('0x29')](_0xbf02('0x53'),_0x29f21c);throw _0x29f21c;});}return _0x5ebf00;})[_0xbf02('0x23')](respondWithResult(_0x41a02b,0xc9))[_0xbf02('0x46')](handleError(_0x41a02b,null));};exports[_0xbf02('0x22')]=function(_0x499ba5,_0x5c480b){if(_0x499ba5[_0xbf02('0x4c')]['id']){delete _0x499ba5['body']['id'];}return db[_0xbf02('0x2d')][_0xbf02('0x4a')]({'where':{'id':_0x499ba5[_0xbf02('0x54')]['id']}})[_0xbf02('0x23')](handleEntityNotFound(_0x5c480b,null))[_0xbf02('0x23')](saveUpdates(_0x499ba5['body'],null))[_0xbf02('0x23')](respondWithResult(_0x5c480b,null))[_0xbf02('0x46')](handleError(_0x5c480b,null));};exports[_0xbf02('0x24')]=function(_0x189b77,_0x18893e){return db[_0xbf02('0x2d')][_0xbf02('0x4a')]({'where':{'id':_0x189b77['params']['id']}})[_0xbf02('0x23')](handleEntityNotFound(_0x18893e,null))['then'](removeEntity(_0x18893e,null))[_0xbf02('0x46')](handleError(_0x18893e,null));};
\ No newline at end of file