Built motion from commit 775e2a94.|2.6.3
[motion2.git] / server / api / interval / interval.controller.js
index df9e29e..fd0e741 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x5047=['filters','intersection','model','attributes','fields','nolimit','order','sort','pick','filter','where','merge','VIRTUAL','includeAll','rows','show','params','keys','length','options','catch','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','find','addInterval','IntervalId','getIntervals','findOne','rawAttributes','hasOwnProperty','addIntervals','bulkCreate','eml-format','rimraf','fast-json-patch','request-promise','moment','util','sox','lodash','squel','jsforce','desk.js','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../config/environment','../../config/license/util','status','end','json','undefined','limit','count','offset','set','apply','reject','update','destroy','Intervals','then','name','send','index','map','Interval','fieldName','type','key','query'];(function(_0x32ea77,_0x400110){var _0x1c4b8e=function(_0x3c56e4){while(--_0x3c56e4){_0x32ea77['push'](_0x32ea77['shift']());}};_0x1c4b8e(++_0x400110);}(_0x5047,0xce));var _0x7504=function(_0x19e35c,_0x29cd1e){_0x19e35c=_0x19e35c-0x0;var _0x3e1fe8=_0x5047[_0x19e35c];return _0x3e1fe8;};'use strict';var emlformat=require(_0x7504('0x0'));var rimraf=require(_0x7504('0x1'));var zipdir=require('zip-dir');var jsonpatch=require(_0x7504('0x2'));var rp=require(_0x7504('0x3'));var moment=require(_0x7504('0x4'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x7504('0x5'));var path=require('path');var sox=require(_0x7504('0x6'));var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x7504('0x7'));var squel=require(_0x7504('0x8'));var crypto=require('crypto');var jsforce=require(_0x7504('0x9'));var deskjs=require(_0x7504('0xa'));var toCsv=require('to-csv');var querystring=require(_0x7504('0xb'));var Papa=require(_0x7504('0xc'));var Redis=require('ioredis');var authService=require(_0x7504('0xd'));var qs=require(_0x7504('0xe'));var as=require(_0x7504('0xf'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x7504('0x10'))(_0x7504('0x11'));var utils=require('../../config/utils');var config=require(_0x7504('0x12'));var licenseUtil=require(_0x7504('0x13'));var db=require('../../mysqldb')['db'];var extensions=require('../../components/extensions/rewrite');function respondWithStatusCode(_0x2befb4,_0x1a4d04){_0x1a4d04=_0x1a4d04||0xcc;return function(_0x10eb6b){if(_0x10eb6b){return _0x2befb4['sendStatus'](_0x1a4d04);}return _0x2befb4[_0x7504('0x14')](_0x1a4d04)[_0x7504('0x15')]();};}function respondWithResult(_0x2cd4ef,_0x9672c9){_0x9672c9=_0x9672c9||0xc8;return function(_0x3bbdcf){if(_0x3bbdcf){return _0x2cd4ef[_0x7504('0x14')](_0x9672c9)[_0x7504('0x16')](_0x3bbdcf);}};}function respondWithFilteredResult(_0x390bee,_0x4afb2e){return function(_0x2a52bd){if(_0x2a52bd){var _0x42391d=typeof _0x4afb2e['offset']===_0x7504('0x17')&&typeof _0x4afb2e[_0x7504('0x18')]==='undefined';var _0x418dd2=_0x2a52bd[_0x7504('0x19')];var _0x4b03d5=_0x42391d?0x0:_0x4afb2e[_0x7504('0x1a')];var _0x520fa7=_0x42391d?_0x2a52bd[_0x7504('0x19')]:_0x4afb2e[_0x7504('0x1a')]+_0x4afb2e[_0x7504('0x18')];var _0x3d69a7;if(_0x520fa7>=_0x418dd2){_0x520fa7=_0x418dd2;_0x3d69a7=0xc8;}else{_0x3d69a7=0xce;}_0x390bee[_0x7504('0x14')](_0x3d69a7);return _0x390bee[_0x7504('0x1b')]('Content-Range',_0x4b03d5+'-'+_0x520fa7+'/'+_0x418dd2)[_0x7504('0x16')](_0x2a52bd);}return null;};}function patchUpdates(_0x24141d){return function(_0x1fb81c){try{jsonpatch[_0x7504('0x1c')](_0x1fb81c,_0x24141d,!![]);}catch(_0x15ef08){return BPromise[_0x7504('0x1d')](_0x15ef08);}return _0x1fb81c['save']();};}function saveUpdates(_0x2c68ba,_0x407e81){return function(_0x160a29){if(_0x160a29){return _0x160a29[_0x7504('0x1e')](_0x2c68ba)['then'](function(_0xfa1694){return _0xfa1694;});}return null;};}function removeEntity(_0x34b77e,_0x22c4f1){return function(_0x59e381){if(_0x59e381){return _0x59e381[_0x7504('0x1f')]()['then'](function(){var _0x3750ce=_0x59e381['get']({'plain':!![]});var _0x561540=_0x7504('0x20');return db['UserProfileResource'][_0x7504('0x1f')]({'where':{'type':_0x561540,'resourceId':_0x3750ce['id']}})[_0x7504('0x21')](function(){return _0x59e381;});})[_0x7504('0x21')](function(){_0x34b77e[_0x7504('0x14')](0xcc)[_0x7504('0x15')]();});}};}function handleEntityNotFound(_0x13ef32,_0x4015db){return function(_0x913ced){if(!_0x913ced){_0x13ef32['sendStatus'](0x194);}return _0x913ced;};}function handleError(_0x3f2567,_0x4d4b60){_0x4d4b60=_0x4d4b60||0x1f4;return function(_0xf0b998){logger['error'](_0xf0b998['stack']);if(_0xf0b998[_0x7504('0x22')]){delete _0xf0b998['name'];}_0x3f2567['status'](_0x4d4b60)[_0x7504('0x23')](_0xf0b998);};}exports[_0x7504('0x24')]=function(_0x31b522,_0x5de210){var _0x1bf019={},_0x17cafb={},_0xfe5129={'count':0x0,'rows':[]};var _0x246771=_[_0x7504('0x25')](db[_0x7504('0x26')]['rawAttributes'],function(_0x5ebd58){return{'name':_0x5ebd58[_0x7504('0x27')],'type':_0x5ebd58[_0x7504('0x28')][_0x7504('0x29')]};});_0x17cafb['model']=_['map'](_0x246771,'name');_0x17cafb['query']=_['keys'](_0x31b522[_0x7504('0x2a')]);_0x17cafb[_0x7504('0x2b')]=_[_0x7504('0x2c')](_0x17cafb[_0x7504('0x2d')],_0x17cafb[_0x7504('0x2a')]);_0x1bf019[_0x7504('0x2e')]=_[_0x7504('0x2c')](_0x17cafb[_0x7504('0x2d')],qs[_0x7504('0x2f')](_0x31b522[_0x7504('0x2a')][_0x7504('0x2f')]));_0x1bf019['attributes']=_0x1bf019[_0x7504('0x2e')]['length']?_0x1bf019[_0x7504('0x2e')]:_0x17cafb[_0x7504('0x2d')];if(!_0x31b522['query']['hasOwnProperty'](_0x7504('0x30'))){_0x1bf019[_0x7504('0x18')]=qs[_0x7504('0x18')](_0x31b522['query']['limit']);_0x1bf019[_0x7504('0x1a')]=qs[_0x7504('0x1a')](_0x31b522[_0x7504('0x2a')][_0x7504('0x1a')]);}_0x1bf019[_0x7504('0x31')]=qs[_0x7504('0x32')](_0x31b522[_0x7504('0x2a')]['sort']);_0x1bf019['where']=qs[_0x7504('0x2b')](_[_0x7504('0x33')](_0x31b522[_0x7504('0x2a')],_0x17cafb[_0x7504('0x2b')]),_0x246771);if(_0x31b522[_0x7504('0x2a')][_0x7504('0x34')]){_0x1bf019[_0x7504('0x35')]=_[_0x7504('0x36')](_0x1bf019[_0x7504('0x35')],{'$or':_['map'](_0x246771,function(_0x1e19df){if(_0x1e19df[_0x7504('0x28')]!==_0x7504('0x37')){var _0x10435a={};_0x10435a[_0x1e19df[_0x7504('0x22')]]={'$like':'%'+_0x31b522[_0x7504('0x2a')]['filter']+'%'};return _0x10435a;}})});}_0x1bf019=_[_0x7504('0x36')]({},_0x1bf019,_0x31b522['options']);var _0x1a708f={'where':_0x1bf019['where']};return db[_0x7504('0x26')]['count'](_0x1a708f)['then'](function(_0x304846){_0xfe5129[_0x7504('0x19')]=_0x304846;if(_0x31b522[_0x7504('0x2a')][_0x7504('0x38')]){_0x1bf019['include']=[{'all':!![]}];}return db[_0x7504('0x26')]['findAll'](_0x1bf019);})['then'](function(_0x84fd3c){_0xfe5129[_0x7504('0x39')]=_0x84fd3c;return _0xfe5129;})[_0x7504('0x21')](respondWithFilteredResult(_0x5de210,_0x1bf019))['catch'](handleError(_0x5de210,null));};exports[_0x7504('0x3a')]=function(_0x30e438,_0x1e19e0){var _0x1cd4d1={'raw':!![],'where':{'id':_0x30e438[_0x7504('0x3b')]['id']}},_0xdcbb8b={};_0xdcbb8b['model']=_[_0x7504('0x3c')](db[_0x7504('0x26')]['rawAttributes']);_0xdcbb8b['query']=_[_0x7504('0x3c')](_0x30e438['query']);_0xdcbb8b[_0x7504('0x2b')]=_['intersection'](_0xdcbb8b[_0x7504('0x2d')],_0xdcbb8b[_0x7504('0x2a')]);_0x1cd4d1['attributes']=_['intersection'](_0xdcbb8b[_0x7504('0x2d')],qs['fields'](_0x30e438[_0x7504('0x2a')][_0x7504('0x2f')]));_0x1cd4d1['attributes']=_0x1cd4d1[_0x7504('0x2e')][_0x7504('0x3d')]?_0x1cd4d1[_0x7504('0x2e')]:_0xdcbb8b[_0x7504('0x2d')];if(_0x30e438[_0x7504('0x2a')][_0x7504('0x38')]){_0x1cd4d1['include']=[{'all':!![]}];}_0x1cd4d1=_['merge']({},_0x1cd4d1,_0x30e438[_0x7504('0x3e')]);return db[_0x7504('0x26')]['find'](_0x1cd4d1)['then'](handleEntityNotFound(_0x1e19e0,null))[_0x7504('0x21')](respondWithResult(_0x1e19e0,null))[_0x7504('0x3f')](handleError(_0x1e19e0,null));};exports[_0x7504('0x40')]=function(_0x3b2f15,_0x3e8083){return db[_0x7504('0x26')][_0x7504('0x40')](_0x3b2f15[_0x7504('0x41')],{})[_0x7504('0x21')](function(_0x24725b){var _0x195e28=_0x3b2f15[_0x7504('0x42')][_0x7504('0x43')]({'plain':!![]});if(!_0x195e28)throw new Error(_0x7504('0x44'));if(_0x195e28[_0x7504('0x45')]===_0x7504('0x42')){var _0x18f2bb=_0x24725b[_0x7504('0x43')]({'plain':!![]});var _0x297422=_0x7504('0x20');return db[_0x7504('0x46')]['find']({'where':{'name':_0x297422,'userProfileId':_0x195e28['userProfileId']},'raw':!![]})[_0x7504('0x21')](function(_0x157176){if(_0x157176&&_0x157176[_0x7504('0x47')]===0x0){return db['UserProfileResource']['create']({'name':_0x18f2bb['name'],'resourceId':_0x18f2bb['id'],'type':_0x157176[_0x7504('0x22')],'sectionId':_0x157176['id']},{})['then'](function(){return _0x24725b;});}else{return _0x24725b;}})[_0x7504('0x3f')](function(_0x4de121){logger[_0x7504('0x48')](_0x7504('0x49'),_0x4de121);throw _0x4de121;});}return _0x24725b;})['then'](respondWithResult(_0x3e8083,0xc9))[_0x7504('0x3f')](handleError(_0x3e8083,null));};exports[_0x7504('0x1e')]=function(_0x1fa5d2,_0x5ed8d1){if(_0x1fa5d2['body']['id']){delete _0x1fa5d2[_0x7504('0x41')]['id'];}return db[_0x7504('0x26')][_0x7504('0x4a')]({'where':{'id':_0x1fa5d2[_0x7504('0x3b')]['id']}})[_0x7504('0x21')](handleEntityNotFound(_0x5ed8d1,null))[_0x7504('0x21')](saveUpdates(_0x1fa5d2[_0x7504('0x41')],null))[_0x7504('0x21')](respondWithResult(_0x5ed8d1,null))[_0x7504('0x3f')](handleError(_0x5ed8d1,null));};exports[_0x7504('0x1f')]=function(_0x132d5e,_0xd20501){return db[_0x7504('0x26')][_0x7504('0x4a')]({'where':{'id':_0x132d5e['params']['id']}})[_0x7504('0x21')](handleEntityNotFound(_0xd20501,null))['then'](removeEntity(_0xd20501,null))[_0x7504('0x3f')](handleError(_0xd20501,null));};exports[_0x7504('0x4b')]=function(_0x35e0d9,_0x545e09,_0x296760){if(_0x35e0d9[_0x7504('0x41')]['id']){delete _0x35e0d9[_0x7504('0x41')]['id'];}return db['Interval'][_0x7504('0x4a')]({'where':{'id':_0x35e0d9['params']['id']}})['then'](handleEntityNotFound(_0x545e09,null))[_0x7504('0x21')](function(_0x2522c3){if(_0x2522c3){_0x35e0d9[_0x7504('0x41')][_0x7504('0x4c')]=_0x2522c3['id'];return db[_0x7504('0x26')]['create'](_0x35e0d9['body']);}})[_0x7504('0x21')](respondWithResult(_0x545e09,null))[_0x7504('0x3f')](handleError(_0x545e09,null));};exports[_0x7504('0x4d')]=function(_0x2bcea1,_0x27ef23,_0x4d8461){var _0x5b3c1f={};var _0x1c58dc={};var _0xf99903;var _0x3169f4;return db[_0x7504('0x26')][_0x7504('0x4e')]({'where':{'id':_0x2bcea1['params']['id']}})[_0x7504('0x21')](handleEntityNotFound(_0x27ef23,null))['then'](function(_0x29023e){if(_0x29023e){_0xf99903=_0x29023e;_0x1c58dc['model']=_['keys'](db[_0x7504('0x26')][_0x7504('0x4f')]);_0x1c58dc[_0x7504('0x2a')]=_[_0x7504('0x3c')](_0x2bcea1[_0x7504('0x2a')]);_0x1c58dc[_0x7504('0x2b')]=_['intersection'](_0x1c58dc[_0x7504('0x2d')],_0x1c58dc[_0x7504('0x2a')]);_0x5b3c1f[_0x7504('0x2e')]=_['intersection'](_0x1c58dc['model'],qs[_0x7504('0x2f')](_0x2bcea1[_0x7504('0x2a')][_0x7504('0x2f')]));_0x5b3c1f[_0x7504('0x2e')]=_0x5b3c1f[_0x7504('0x2e')]['length']?_0x5b3c1f[_0x7504('0x2e')]:_0x1c58dc[_0x7504('0x2d')];_0x5b3c1f[_0x7504('0x31')]=qs[_0x7504('0x32')](_0x2bcea1[_0x7504('0x2a')][_0x7504('0x32')]);_0x5b3c1f[_0x7504('0x35')]=qs[_0x7504('0x2b')](_[_0x7504('0x33')](_0x2bcea1['query'],_0x1c58dc[_0x7504('0x2b')]));if(_0x2bcea1[_0x7504('0x2a')][_0x7504('0x34')]){_0x5b3c1f[_0x7504('0x35')]=_[_0x7504('0x36')](_0x5b3c1f[_0x7504('0x35')],{'$or':_['map'](_0x5b3c1f[_0x7504('0x2e')],function(_0x35b44a){var _0x30e987={};_0x30e987[_0x35b44a]={'$like':'%'+_0x2bcea1[_0x7504('0x2a')]['filter']+'%'};return _0x30e987;})});}_0x5b3c1f=_[_0x7504('0x36')]({},_0x5b3c1f,_0x2bcea1['options']);return _0xf99903[_0x7504('0x4d')](_0x5b3c1f);}})[_0x7504('0x21')](function(_0x23db39){if(_0x23db39){_0x3169f4=_0x23db39[_0x7504('0x3d')];if(!_0x2bcea1[_0x7504('0x2a')][_0x7504('0x50')](_0x7504('0x30'))){_0x5b3c1f[_0x7504('0x18')]=qs[_0x7504('0x18')](_0x2bcea1[_0x7504('0x2a')][_0x7504('0x18')]);_0x5b3c1f[_0x7504('0x1a')]=qs['offset'](_0x2bcea1[_0x7504('0x2a')][_0x7504('0x1a')]);}return _0xf99903['getIntervals'](_0x5b3c1f);}})[_0x7504('0x21')](function(_0x46d836){if(_0x46d836){return _0x46d836?{'count':_0x3169f4,'rows':_0x46d836}:null;}})[_0x7504('0x21')](respondWithResult(_0x27ef23,null))[_0x7504('0x3f')](handleError(_0x27ef23,null));};exports[_0x7504('0x51')]=function(_0x42f018,_0x39f443,_0x13d37c){return db[_0x7504('0x26')][_0x7504('0x4e')]({'where':{'id':_0x42f018[_0x7504('0x3b')]['id']}})[_0x7504('0x21')](handleEntityNotFound(_0x39f443,null))[_0x7504('0x21')](function(_0xa911a4){if(_0xa911a4){return db['sequelize']['transaction'](function(_0x594e6c){return db[_0x7504('0x26')][_0x7504('0x1f')]({'where':{'IntervalId':_0x42f018['params']['id']},'transaction':_0x594e6c})[_0x7504('0x21')](function(_0x496b9f){var _0x4f558d=_['map'](_0x42f018[_0x7504('0x41')],function(_0x383aac){delete _0x383aac['id'];_0x383aac[_0x7504('0x4c')]=_0x42f018[_0x7504('0x3b')]['id'];return _0x383aac;});return db[_0x7504('0x26')][_0x7504('0x52')](_0x4f558d,{'transaction':_0x594e6c});});})['then'](function(){return db[_0x7504('0x26')]['findAll']({'where':{'IntervalId':_0x42f018[_0x7504('0x3b')]['id']}});});}})[_0x7504('0x21')](respondWithResult(_0x39f443,null))[_0x7504('0x3f')](handleError(_0x39f443,null));};
\ No newline at end of file
+var _0x1058=['keys','query','intersection','fields','attributes','length','nolimit','order','sort','where','filters','pick','filter','VIRTUAL','merge','options','Interval','includeAll','include','findAll','rows','catch','show','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update','params','addInterval','IntervalId','getIntervals','findOne','rawAttributes','hasOwnProperty','addIntervals','sequelize','transaction','bulkCreate','eml-format','rimraf','request-promise','moment','path','ejs','fs-extra','lodash','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','api','../../config/utils','../../config/environment','../../mysqldb','../../components/extensions/rewrite','sendStatus','status','end','json','undefined','limit','count','offset','set','Content-Range','apply','save','destroy','then','get','Intervals','UserProfileResource','stack','name','send','map','fieldName','type','key','model'];(function(_0x21c7c5,_0x595075){var _0x42d77c=function(_0x5e3cdf){while(--_0x5e3cdf){_0x21c7c5['push'](_0x21c7c5['shift']());}};_0x42d77c(++_0x595075);}(_0x1058,0x148));var _0x8105=function(_0x1a2dd6,_0x4c8b16){_0x1a2dd6=_0x1a2dd6-0x0;var _0x30953d=_0x1058[_0x1a2dd6];return _0x30953d;};'use strict';var emlformat=require(_0x8105('0x0'));var rimraf=require(_0x8105('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0x8105('0x2'));var moment=require(_0x8105('0x3'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require('util');var path=require(_0x8105('0x4'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x8105('0x5'));var fs=require('fs');var fs_extra=require(_0x8105('0x6'));var _=require(_0x8105('0x7'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x8105('0x8'));var deskjs=require(_0x8105('0x9'));var toCsv=require(_0x8105('0xa'));var querystring=require(_0x8105('0xb'));var Papa=require(_0x8105('0xc'));var Redis=require(_0x8105('0xd'));var authService=require(_0x8105('0xe'));var qs=require(_0x8105('0xf'));var as=require(_0x8105('0x10'));var hardwareService=require(_0x8105('0x11'));var logger=require('../../config/logger')(_0x8105('0x12'));var utils=require(_0x8105('0x13'));var config=require(_0x8105('0x14'));var licenseUtil=require('../../config/license/util');var db=require(_0x8105('0x15'))['db'];var extensions=require(_0x8105('0x16'));function respondWithStatusCode(_0x14534f,_0x23ea87){_0x23ea87=_0x23ea87||0xcc;return function(_0x3fd627){if(_0x3fd627){return _0x14534f[_0x8105('0x17')](_0x23ea87);}return _0x14534f[_0x8105('0x18')](_0x23ea87)[_0x8105('0x19')]();};}function respondWithResult(_0x5536b7,_0xfe0de6){_0xfe0de6=_0xfe0de6||0xc8;return function(_0x30f43c){if(_0x30f43c){return _0x5536b7[_0x8105('0x18')](_0xfe0de6)[_0x8105('0x1a')](_0x30f43c);}};}function respondWithFilteredResult(_0x1e5889,_0x403bdc){return function(_0x122882){if(_0x122882){var _0x156c54=typeof _0x403bdc['offset']===_0x8105('0x1b')&&typeof _0x403bdc[_0x8105('0x1c')]===_0x8105('0x1b');var _0x475760=_0x122882[_0x8105('0x1d')];var _0x1c98ed=_0x156c54?0x0:_0x403bdc[_0x8105('0x1e')];var _0x3006e3=_0x156c54?_0x122882[_0x8105('0x1d')]:_0x403bdc['offset']+_0x403bdc[_0x8105('0x1c')];var _0x3e1a16;if(_0x3006e3>=_0x475760){_0x3006e3=_0x475760;_0x3e1a16=0xc8;}else{_0x3e1a16=0xce;}_0x1e5889[_0x8105('0x18')](_0x3e1a16);return _0x1e5889[_0x8105('0x1f')](_0x8105('0x20'),_0x1c98ed+'-'+_0x3006e3+'/'+_0x475760)[_0x8105('0x1a')](_0x122882);}return null;};}function patchUpdates(_0x1b8bf9){return function(_0x405c39){try{jsonpatch[_0x8105('0x21')](_0x405c39,_0x1b8bf9,!![]);}catch(_0x227746){return BPromise['reject'](_0x227746);}return _0x405c39[_0x8105('0x22')]();};}function saveUpdates(_0x2219fa,_0xa93ddb){return function(_0x20ec77){if(_0x20ec77){return _0x20ec77['update'](_0x2219fa)['then'](function(_0x4b9e0e){return _0x4b9e0e;});}return null;};}function removeEntity(_0x47f1b5,_0x66d606){return function(_0x213457){if(_0x213457){return _0x213457[_0x8105('0x23')]()[_0x8105('0x24')](function(){var _0x36b049=_0x213457[_0x8105('0x25')]({'plain':!![]});var _0x534bf0=_0x8105('0x26');return db[_0x8105('0x27')]['destroy']({'where':{'type':_0x534bf0,'resourceId':_0x36b049['id']}})['then'](function(){return _0x213457;});})[_0x8105('0x24')](function(){_0x47f1b5[_0x8105('0x18')](0xcc)[_0x8105('0x19')]();});}};}function handleEntityNotFound(_0x33823a,_0x4c5a16){return function(_0x3272c9){if(!_0x3272c9){_0x33823a[_0x8105('0x17')](0x194);}return _0x3272c9;};}function handleError(_0xa5c881,_0x1a14b8){_0x1a14b8=_0x1a14b8||0x1f4;return function(_0x9b92b1){logger['error'](_0x9b92b1[_0x8105('0x28')]);if(_0x9b92b1[_0x8105('0x29')]){delete _0x9b92b1[_0x8105('0x29')];}_0xa5c881[_0x8105('0x18')](_0x1a14b8)[_0x8105('0x2a')](_0x9b92b1);};}exports['index']=function(_0x57e96a,_0xab364b){var _0x34a805={},_0x39bf1b={},_0x132a42={'count':0x0,'rows':[]};var _0x56459a=_[_0x8105('0x2b')](db['Interval']['rawAttributes'],function(_0x346c85){return{'name':_0x346c85[_0x8105('0x2c')],'type':_0x346c85[_0x8105('0x2d')][_0x8105('0x2e')]};});_0x39bf1b[_0x8105('0x2f')]=_[_0x8105('0x2b')](_0x56459a,_0x8105('0x29'));_0x39bf1b['query']=_[_0x8105('0x30')](_0x57e96a[_0x8105('0x31')]);_0x39bf1b['filters']=_[_0x8105('0x32')](_0x39bf1b[_0x8105('0x2f')],_0x39bf1b[_0x8105('0x31')]);_0x34a805['attributes']=_[_0x8105('0x32')](_0x39bf1b['model'],qs[_0x8105('0x33')](_0x57e96a['query'][_0x8105('0x33')]));_0x34a805[_0x8105('0x34')]=_0x34a805['attributes'][_0x8105('0x35')]?_0x34a805[_0x8105('0x34')]:_0x39bf1b['model'];if(!_0x57e96a[_0x8105('0x31')]['hasOwnProperty'](_0x8105('0x36'))){_0x34a805[_0x8105('0x1c')]=qs[_0x8105('0x1c')](_0x57e96a[_0x8105('0x31')][_0x8105('0x1c')]);_0x34a805[_0x8105('0x1e')]=qs[_0x8105('0x1e')](_0x57e96a[_0x8105('0x31')]['offset']);}_0x34a805[_0x8105('0x37')]=qs[_0x8105('0x38')](_0x57e96a[_0x8105('0x31')][_0x8105('0x38')]);_0x34a805[_0x8105('0x39')]=qs[_0x8105('0x3a')](_[_0x8105('0x3b')](_0x57e96a['query'],_0x39bf1b[_0x8105('0x3a')]),_0x56459a);if(_0x57e96a[_0x8105('0x31')][_0x8105('0x3c')]){_0x34a805['where']=_['merge'](_0x34a805[_0x8105('0x39')],{'$or':_[_0x8105('0x2b')](_0x56459a,function(_0x147c94){if(_0x147c94[_0x8105('0x2d')]!==_0x8105('0x3d')){var _0x326f09={};_0x326f09[_0x147c94[_0x8105('0x29')]]={'$like':'%'+_0x57e96a[_0x8105('0x31')]['filter']+'%'};return _0x326f09;}})});}_0x34a805=_[_0x8105('0x3e')]({},_0x34a805,_0x57e96a[_0x8105('0x3f')]);var _0x4aa821={'where':_0x34a805[_0x8105('0x39')]};return db[_0x8105('0x40')][_0x8105('0x1d')](_0x4aa821)[_0x8105('0x24')](function(_0x3ba070){_0x132a42[_0x8105('0x1d')]=_0x3ba070;if(_0x57e96a[_0x8105('0x31')][_0x8105('0x41')]){_0x34a805[_0x8105('0x42')]=[{'all':!![]}];}return db[_0x8105('0x40')][_0x8105('0x43')](_0x34a805);})[_0x8105('0x24')](function(_0x67471c){_0x132a42[_0x8105('0x44')]=_0x67471c;return _0x132a42;})['then'](respondWithFilteredResult(_0xab364b,_0x34a805))[_0x8105('0x45')](handleError(_0xab364b,null));};exports[_0x8105('0x46')]=function(_0x4f6346,_0x51a7ed){var _0x3863e1={'raw':!![],'where':{'id':_0x4f6346['params']['id']}},_0x2d11df={};_0x2d11df['model']=_[_0x8105('0x30')](db['Interval']['rawAttributes']);_0x2d11df[_0x8105('0x31')]=_[_0x8105('0x30')](_0x4f6346['query']);_0x2d11df[_0x8105('0x3a')]=_[_0x8105('0x32')](_0x2d11df[_0x8105('0x2f')],_0x2d11df['query']);_0x3863e1[_0x8105('0x34')]=_['intersection'](_0x2d11df[_0x8105('0x2f')],qs[_0x8105('0x33')](_0x4f6346['query'][_0x8105('0x33')]));_0x3863e1[_0x8105('0x34')]=_0x3863e1[_0x8105('0x34')][_0x8105('0x35')]?_0x3863e1[_0x8105('0x34')]:_0x2d11df['model'];if(_0x4f6346[_0x8105('0x31')][_0x8105('0x41')]){_0x3863e1[_0x8105('0x42')]=[{'all':!![]}];}_0x3863e1=_[_0x8105('0x3e')]({},_0x3863e1,_0x4f6346[_0x8105('0x3f')]);return db[_0x8105('0x40')][_0x8105('0x47')](_0x3863e1)['then'](handleEntityNotFound(_0x51a7ed,null))[_0x8105('0x24')](respondWithResult(_0x51a7ed,null))['catch'](handleError(_0x51a7ed,null));};exports[_0x8105('0x48')]=function(_0x5ce2c1,_0x40a487){return db[_0x8105('0x40')][_0x8105('0x48')](_0x5ce2c1[_0x8105('0x49')],{})[_0x8105('0x24')](function(_0x47a85b){var _0x1e9040=_0x5ce2c1['user'][_0x8105('0x25')]({'plain':!![]});if(!_0x1e9040)throw new Error(_0x8105('0x4a'));if(_0x1e9040[_0x8105('0x4b')]===_0x8105('0x4c')){var _0x5ccd99=_0x47a85b[_0x8105('0x25')]({'plain':!![]});var _0x484deb=_0x8105('0x26');return db[_0x8105('0x4d')]['find']({'where':{'name':_0x484deb,'userProfileId':_0x1e9040[_0x8105('0x4e')]},'raw':!![]})[_0x8105('0x24')](function(_0x2573a4){if(_0x2573a4&&_0x2573a4[_0x8105('0x4f')]===0x0){return db[_0x8105('0x27')][_0x8105('0x48')]({'name':_0x5ccd99[_0x8105('0x29')],'resourceId':_0x5ccd99['id'],'type':_0x2573a4[_0x8105('0x29')],'sectionId':_0x2573a4['id']},{})[_0x8105('0x24')](function(){return _0x47a85b;});}else{return _0x47a85b;}})['catch'](function(_0xcc2ed1){logger[_0x8105('0x50')](_0x8105('0x51'),_0xcc2ed1);throw _0xcc2ed1;});}return _0x47a85b;})[_0x8105('0x24')](respondWithResult(_0x40a487,0xc9))['catch'](handleError(_0x40a487,null));};exports[_0x8105('0x52')]=function(_0x1acb08,_0xe5b353){if(_0x1acb08[_0x8105('0x49')]['id']){delete _0x1acb08[_0x8105('0x49')]['id'];}return db[_0x8105('0x40')][_0x8105('0x47')]({'where':{'id':_0x1acb08[_0x8105('0x53')]['id']}})[_0x8105('0x24')](handleEntityNotFound(_0xe5b353,null))[_0x8105('0x24')](saveUpdates(_0x1acb08['body'],null))['then'](respondWithResult(_0xe5b353,null))[_0x8105('0x45')](handleError(_0xe5b353,null));};exports['destroy']=function(_0x42cb65,_0xacdba0){return db[_0x8105('0x40')][_0x8105('0x47')]({'where':{'id':_0x42cb65[_0x8105('0x53')]['id']}})['then'](handleEntityNotFound(_0xacdba0,null))[_0x8105('0x24')](removeEntity(_0xacdba0,null))[_0x8105('0x45')](handleError(_0xacdba0,null));};exports[_0x8105('0x54')]=function(_0x208aa2,_0x44b2a0,_0x1c4008){if(_0x208aa2['body']['id']){delete _0x208aa2['body']['id'];}return db[_0x8105('0x40')][_0x8105('0x47')]({'where':{'id':_0x208aa2[_0x8105('0x53')]['id']}})[_0x8105('0x24')](handleEntityNotFound(_0x44b2a0,null))[_0x8105('0x24')](function(_0x475f58){if(_0x475f58){_0x208aa2[_0x8105('0x49')][_0x8105('0x55')]=_0x475f58['id'];return db['Interval'][_0x8105('0x48')](_0x208aa2[_0x8105('0x49')]);}})[_0x8105('0x24')](respondWithResult(_0x44b2a0,null))[_0x8105('0x45')](handleError(_0x44b2a0,null));};exports[_0x8105('0x56')]=function(_0x298791,_0x5b4c06,_0x53a493){var _0x2aac8f={};var _0x115dae={};var _0x1fdb90;var _0x318333;return db[_0x8105('0x40')][_0x8105('0x57')]({'where':{'id':_0x298791['params']['id']}})[_0x8105('0x24')](handleEntityNotFound(_0x5b4c06,null))[_0x8105('0x24')](function(_0x4a6c43){if(_0x4a6c43){_0x1fdb90=_0x4a6c43;_0x115dae['model']=_[_0x8105('0x30')](db[_0x8105('0x40')][_0x8105('0x58')]);_0x115dae[_0x8105('0x31')]=_['keys'](_0x298791[_0x8105('0x31')]);_0x115dae[_0x8105('0x3a')]=_[_0x8105('0x32')](_0x115dae[_0x8105('0x2f')],_0x115dae['query']);_0x2aac8f[_0x8105('0x34')]=_['intersection'](_0x115dae[_0x8105('0x2f')],qs[_0x8105('0x33')](_0x298791[_0x8105('0x31')][_0x8105('0x33')]));_0x2aac8f['attributes']=_0x2aac8f[_0x8105('0x34')][_0x8105('0x35')]?_0x2aac8f[_0x8105('0x34')]:_0x115dae[_0x8105('0x2f')];_0x2aac8f[_0x8105('0x37')]=qs[_0x8105('0x38')](_0x298791[_0x8105('0x31')][_0x8105('0x38')]);_0x2aac8f['where']=qs[_0x8105('0x3a')](_[_0x8105('0x3b')](_0x298791[_0x8105('0x31')],_0x115dae[_0x8105('0x3a')]));if(_0x298791[_0x8105('0x31')][_0x8105('0x3c')]){_0x2aac8f[_0x8105('0x39')]=_[_0x8105('0x3e')](_0x2aac8f[_0x8105('0x39')],{'$or':_[_0x8105('0x2b')](_0x2aac8f[_0x8105('0x34')],function(_0x22bdb4){var _0x376181={};_0x376181[_0x22bdb4]={'$like':'%'+_0x298791['query'][_0x8105('0x3c')]+'%'};return _0x376181;})});}_0x2aac8f=_[_0x8105('0x3e')]({},_0x2aac8f,_0x298791[_0x8105('0x3f')]);return _0x1fdb90['getIntervals'](_0x2aac8f);}})['then'](function(_0x2d9553){if(_0x2d9553){_0x318333=_0x2d9553[_0x8105('0x35')];if(!_0x298791[_0x8105('0x31')][_0x8105('0x59')](_0x8105('0x36'))){_0x2aac8f[_0x8105('0x1c')]=qs[_0x8105('0x1c')](_0x298791['query'][_0x8105('0x1c')]);_0x2aac8f[_0x8105('0x1e')]=qs['offset'](_0x298791[_0x8105('0x31')][_0x8105('0x1e')]);}return _0x1fdb90[_0x8105('0x56')](_0x2aac8f);}})[_0x8105('0x24')](function(_0x361ba4){if(_0x361ba4){return _0x361ba4?{'count':_0x318333,'rows':_0x361ba4}:null;}})[_0x8105('0x24')](respondWithResult(_0x5b4c06,null))['catch'](handleError(_0x5b4c06,null));};exports[_0x8105('0x5a')]=function(_0x1fb6cc,_0x51a4ef,_0x454456){return db[_0x8105('0x40')]['findOne']({'where':{'id':_0x1fb6cc[_0x8105('0x53')]['id']}})[_0x8105('0x24')](handleEntityNotFound(_0x51a4ef,null))[_0x8105('0x24')](function(_0x721e08){if(_0x721e08){return db[_0x8105('0x5b')][_0x8105('0x5c')](function(_0x498428){return db[_0x8105('0x40')][_0x8105('0x23')]({'where':{'IntervalId':_0x1fb6cc['params']['id']},'transaction':_0x498428})[_0x8105('0x24')](function(_0x20ac2a){var _0x580234=_[_0x8105('0x2b')](_0x1fb6cc['body'],function(_0x406051){delete _0x406051['id'];_0x406051[_0x8105('0x55')]=_0x1fb6cc['params']['id'];return _0x406051;});return db['Interval'][_0x8105('0x5d')](_0x580234,{'transaction':_0x498428});});})[_0x8105('0x24')](function(){return db[_0x8105('0x40')][_0x8105('0x43')]({'where':{'IntervalId':_0x1fb6cc[_0x8105('0x53')]['id']}});});}})['then'](respondWithResult(_0x51a4ef,null))[_0x8105('0x45')](handleError(_0x51a4ef,null));};
\ No newline at end of file