Built motion from commit da24aabd.|2.6.20
[motion2.git] / server / api / interval / interval.controller.js
index 903131b..8c2744c 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x0615=['save','update','then','destroy','get','Intervals','UserProfileResource','end','error','stack','name','index','map','rawAttributes','type','key','model','keys','query','filters','fields','attributes','nolimit','order','where','pick','merge','VIRTUAL','filter','options','Interval','includeAll','findAll','catch','show','params','intersection','length','include','create','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','user','UserProfileSection','find','userProfileId','autoAssociation','body','addInterval','IntervalId','getIntervals','findOne','sort','addIntervals','bulkCreate','eml-format','rimraf','zip-dir','request-promise','mustache','util','sox','to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/extensions/rewrite','sendStatus','status','json','offset','undefined','limit','count','set','Content-Range','apply','reject'];(function(_0x3a6b9b,_0x5ab620){var _0x415b8b=function(_0x4c565c){while(--_0x4c565c){_0x3a6b9b['push'](_0x3a6b9b['shift']());}};_0x415b8b(++_0x5ab620);}(_0x0615,0x92));var _0x5061=function(_0x126558,_0x143c9a){_0x126558=_0x126558-0x0;var _0x1f6d14=_0x0615[_0x126558];return _0x1f6d14;};'use strict';var emlformat=require(_0x5061('0x0'));var rimraf=require(_0x5061('0x1'));var zipdir=require(_0x5061('0x2'));var jsonpatch=require('fast-json-patch');var rp=require(_0x5061('0x3'));var moment=require('moment');var BPromise=require('bluebird');var Mustache=require(_0x5061('0x4'));var util=require(_0x5061('0x5'));var path=require('path');var sox=require(_0x5061('0x6'));var csv=require(_0x5061('0x7'));var ejs=require(_0x5061('0x8'));var fs=require('fs');var fs_extra=require(_0x5061('0x9'));var _=require('lodash');var squel=require(_0x5061('0xa'));var crypto=require(_0x5061('0xb'));var jsforce=require(_0x5061('0xc'));var deskjs=require(_0x5061('0xd'));var toCsv=require(_0x5061('0x7'));var querystring=require(_0x5061('0xe'));var Papa=require('papaparse');var Redis=require('ioredis');var authService=require('../../components/auth/service');var qs=require(_0x5061('0xf'));var as=require(_0x5061('0x10'));var hardwareService=require(_0x5061('0x11'));var logger=require(_0x5061('0x12'))(_0x5061('0x13'));var utils=require(_0x5061('0x14'));var config=require(_0x5061('0x15'));var licenseUtil=require(_0x5061('0x16'));var db=require(_0x5061('0x17'))['db'];var extensions=require(_0x5061('0x18'));function respondWithStatusCode(_0x3a5ba2,_0x2d0037){_0x2d0037=_0x2d0037||0xcc;return function(_0x580ed9){if(_0x580ed9){return _0x3a5ba2[_0x5061('0x19')](_0x2d0037);}return _0x3a5ba2[_0x5061('0x1a')](_0x2d0037)['end']();};}function respondWithResult(_0x228733,_0x565867){_0x565867=_0x565867||0xc8;return function(_0x1adba5){if(_0x1adba5){return _0x228733['status'](_0x565867)[_0x5061('0x1b')](_0x1adba5);}};}function respondWithFilteredResult(_0x3941a4,_0x1d7e7b){return function(_0x4c60cc){if(_0x4c60cc){var _0x1d9a03=typeof _0x1d7e7b[_0x5061('0x1c')]===_0x5061('0x1d')&&typeof _0x1d7e7b[_0x5061('0x1e')]===_0x5061('0x1d');var _0x10fb21=_0x4c60cc[_0x5061('0x1f')];var _0x20948c=_0x1d9a03?0x0:_0x1d7e7b[_0x5061('0x1c')];var _0x55428f=_0x1d9a03?_0x4c60cc[_0x5061('0x1f')]:_0x1d7e7b['offset']+_0x1d7e7b[_0x5061('0x1e')];var _0xeb5d59;if(_0x55428f>=_0x10fb21){_0x55428f=_0x10fb21;_0xeb5d59=0xc8;}else{_0xeb5d59=0xce;}_0x3941a4[_0x5061('0x1a')](_0xeb5d59);return _0x3941a4[_0x5061('0x20')](_0x5061('0x21'),_0x20948c+'-'+_0x55428f+'/'+_0x10fb21)[_0x5061('0x1b')](_0x4c60cc);}return null;};}function patchUpdates(_0x3d51e5){return function(_0x1e6931){try{jsonpatch[_0x5061('0x22')](_0x1e6931,_0x3d51e5,!![]);}catch(_0x2fc780){return BPromise[_0x5061('0x23')](_0x2fc780);}return _0x1e6931[_0x5061('0x24')]();};}function saveUpdates(_0x7b4043,_0x44cb59){return function(_0x534f6e){if(_0x534f6e){return _0x534f6e[_0x5061('0x25')](_0x7b4043)[_0x5061('0x26')](function(_0x3acc49){return _0x3acc49;});}return null;};}function removeEntity(_0x3e0962,_0x5245f5){return function(_0x179be0){if(_0x179be0){return _0x179be0[_0x5061('0x27')]()[_0x5061('0x26')](function(){var _0x5bed32=_0x179be0[_0x5061('0x28')]({'plain':!![]});var _0xbe7709=_0x5061('0x29');return db[_0x5061('0x2a')]['destroy']({'where':{'type':_0xbe7709,'resourceId':_0x5bed32['id']}})[_0x5061('0x26')](function(){return _0x179be0;});})[_0x5061('0x26')](function(){_0x3e0962['status'](0xcc)[_0x5061('0x2b')]();});}};}function handleEntityNotFound(_0x316b74,_0x4ffac6){return function(_0x3c6864){if(!_0x3c6864){_0x316b74['sendStatus'](0x194);}return _0x3c6864;};}function handleError(_0x2f44b5,_0x45da87){_0x45da87=_0x45da87||0x1f4;return function(_0x5ce2eb){logger[_0x5061('0x2c')](_0x5ce2eb[_0x5061('0x2d')]);if(_0x5ce2eb[_0x5061('0x2e')]){delete _0x5ce2eb[_0x5061('0x2e')];}_0x2f44b5[_0x5061('0x1a')](_0x45da87)['send'](_0x5ce2eb);};}exports[_0x5061('0x2f')]=function(_0x5d2fb5,_0x115c26){var _0x48481c={},_0x3e8cfc={},_0x57c34e={'count':0x0,'rows':[]};var _0x57f3d0=_[_0x5061('0x30')](db['Interval'][_0x5061('0x31')],function(_0x42bd3f){return{'name':_0x42bd3f['fieldName'],'type':_0x42bd3f[_0x5061('0x32')][_0x5061('0x33')]};});_0x3e8cfc[_0x5061('0x34')]=_[_0x5061('0x30')](_0x57f3d0,_0x5061('0x2e'));_0x3e8cfc['query']=_[_0x5061('0x35')](_0x5d2fb5[_0x5061('0x36')]);_0x3e8cfc[_0x5061('0x37')]=_['intersection'](_0x3e8cfc['model'],_0x3e8cfc['query']);_0x48481c['attributes']=_['intersection'](_0x3e8cfc[_0x5061('0x34')],qs[_0x5061('0x38')](_0x5d2fb5['query'][_0x5061('0x38')]));_0x48481c[_0x5061('0x39')]=_0x48481c[_0x5061('0x39')]['length']?_0x48481c['attributes']:_0x3e8cfc[_0x5061('0x34')];if(!_0x5d2fb5[_0x5061('0x36')]['hasOwnProperty'](_0x5061('0x3a'))){_0x48481c[_0x5061('0x1e')]=qs[_0x5061('0x1e')](_0x5d2fb5[_0x5061('0x36')]['limit']);_0x48481c[_0x5061('0x1c')]=qs['offset'](_0x5d2fb5[_0x5061('0x36')][_0x5061('0x1c')]);}_0x48481c[_0x5061('0x3b')]=qs['sort'](_0x5d2fb5[_0x5061('0x36')]['sort']);_0x48481c[_0x5061('0x3c')]=qs['filters'](_[_0x5061('0x3d')](_0x5d2fb5[_0x5061('0x36')],_0x3e8cfc[_0x5061('0x37')]),_0x57f3d0);if(_0x5d2fb5[_0x5061('0x36')]['filter']){_0x48481c[_0x5061('0x3c')]=_[_0x5061('0x3e')](_0x48481c[_0x5061('0x3c')],{'$or':_['map'](_0x57f3d0,function(_0x8fb08f){if(_0x8fb08f['type']!==_0x5061('0x3f')){var _0x2c3add={};_0x2c3add[_0x8fb08f[_0x5061('0x2e')]]={'$like':'%'+_0x5d2fb5[_0x5061('0x36')][_0x5061('0x40')]+'%'};return _0x2c3add;}})});}_0x48481c=_[_0x5061('0x3e')]({},_0x48481c,_0x5d2fb5[_0x5061('0x41')]);var _0x2a123b={'where':_0x48481c[_0x5061('0x3c')]};return db[_0x5061('0x42')]['count'](_0x2a123b)[_0x5061('0x26')](function(_0x19faaa){_0x57c34e[_0x5061('0x1f')]=_0x19faaa;if(_0x5d2fb5[_0x5061('0x36')][_0x5061('0x43')]){_0x48481c['include']=[{'all':!![]}];}return db[_0x5061('0x42')][_0x5061('0x44')](_0x48481c);})[_0x5061('0x26')](function(_0x305aad){_0x57c34e['rows']=_0x305aad;return _0x57c34e;})[_0x5061('0x26')](respondWithFilteredResult(_0x115c26,_0x48481c))[_0x5061('0x45')](handleError(_0x115c26,null));};exports[_0x5061('0x46')]=function(_0x15948e,_0x65be21){var _0x3bf84e={'raw':!![],'where':{'id':_0x15948e[_0x5061('0x47')]['id']}},_0x300970={};_0x300970[_0x5061('0x34')]=_[_0x5061('0x35')](db[_0x5061('0x42')]['rawAttributes']);_0x300970[_0x5061('0x36')]=_[_0x5061('0x35')](_0x15948e[_0x5061('0x36')]);_0x300970['filters']=_[_0x5061('0x48')](_0x300970['model'],_0x300970[_0x5061('0x36')]);_0x3bf84e[_0x5061('0x39')]=_[_0x5061('0x48')](_0x300970[_0x5061('0x34')],qs[_0x5061('0x38')](_0x15948e['query'][_0x5061('0x38')]));_0x3bf84e[_0x5061('0x39')]=_0x3bf84e[_0x5061('0x39')][_0x5061('0x49')]?_0x3bf84e['attributes']:_0x300970['model'];if(_0x15948e[_0x5061('0x36')][_0x5061('0x43')]){_0x3bf84e[_0x5061('0x4a')]=[{'all':!![]}];}_0x3bf84e=_[_0x5061('0x3e')]({},_0x3bf84e,_0x15948e[_0x5061('0x41')]);return db[_0x5061('0x42')]['find'](_0x3bf84e)[_0x5061('0x26')](handleEntityNotFound(_0x65be21,null))[_0x5061('0x26')](respondWithResult(_0x65be21,null))[_0x5061('0x45')](handleError(_0x65be21,null));};exports[_0x5061('0x4b')]=function(_0x5f205a,_0x4215af){return db[_0x5061('0x42')][_0x5061('0x4b')](_0x5f205a['body'],{})[_0x5061('0x26')](function(_0x59657c){var _0x1e91a7=_0x5f205a['user']['get']({'plain':!![]});if(!_0x1e91a7)throw new Error(_0x5061('0x4c'));if(_0x1e91a7[_0x5061('0x4d')]===_0x5061('0x4e')){var _0x2fd031=_0x59657c[_0x5061('0x28')]({'plain':!![]});var _0x5232bb='Intervals';return db[_0x5061('0x4f')][_0x5061('0x50')]({'where':{'name':_0x5232bb,'userProfileId':_0x1e91a7[_0x5061('0x51')]},'raw':!![]})['then'](function(_0x450753){if(_0x450753&&_0x450753[_0x5061('0x52')]===0x0){return db[_0x5061('0x2a')][_0x5061('0x4b')]({'name':_0x2fd031[_0x5061('0x2e')],'resourceId':_0x2fd031['id'],'type':_0x450753[_0x5061('0x2e')],'sectionId':_0x450753['id']},{})['then'](function(){return _0x59657c;});}else{return _0x59657c;}})[_0x5061('0x45')](function(_0x36395f){logger[_0x5061('0x2c')]('Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s',_0x36395f);throw _0x36395f;});}return _0x59657c;})[_0x5061('0x26')](respondWithResult(_0x4215af,0xc9))[_0x5061('0x45')](handleError(_0x4215af,null));};exports[_0x5061('0x25')]=function(_0x93a0bf,_0x3bd898){if(_0x93a0bf[_0x5061('0x53')]['id']){delete _0x93a0bf[_0x5061('0x53')]['id'];}return db['Interval'][_0x5061('0x50')]({'where':{'id':_0x93a0bf[_0x5061('0x47')]['id']}})[_0x5061('0x26')](handleEntityNotFound(_0x3bd898,null))[_0x5061('0x26')](saveUpdates(_0x93a0bf[_0x5061('0x53')],null))['then'](respondWithResult(_0x3bd898,null))[_0x5061('0x45')](handleError(_0x3bd898,null));};exports[_0x5061('0x27')]=function(_0x3a358a,_0x5ad1b5){return db[_0x5061('0x42')][_0x5061('0x50')]({'where':{'id':_0x3a358a[_0x5061('0x47')]['id']}})[_0x5061('0x26')](handleEntityNotFound(_0x5ad1b5,null))[_0x5061('0x26')](removeEntity(_0x5ad1b5,null))['catch'](handleError(_0x5ad1b5,null));};exports[_0x5061('0x54')]=function(_0x572cbe,_0xee89b3,_0x1c248d){if(_0x572cbe['body']['id']){delete _0x572cbe['body']['id'];}return db[_0x5061('0x42')][_0x5061('0x50')]({'where':{'id':_0x572cbe[_0x5061('0x47')]['id']}})[_0x5061('0x26')](handleEntityNotFound(_0xee89b3,null))[_0x5061('0x26')](function(_0x12ab30){if(_0x12ab30){_0x572cbe['body'][_0x5061('0x55')]=_0x12ab30['id'];return db[_0x5061('0x42')][_0x5061('0x4b')](_0x572cbe[_0x5061('0x53')]);}})[_0x5061('0x26')](respondWithResult(_0xee89b3,null))[_0x5061('0x45')](handleError(_0xee89b3,null));};exports[_0x5061('0x56')]=function(_0x3deb7f,_0x1972b5,_0x531b91){var _0x332531={};var _0x4e3d2a={};var _0x235c4c;var _0x518f47;return db[_0x5061('0x42')][_0x5061('0x57')]({'where':{'id':_0x3deb7f[_0x5061('0x47')]['id']}})[_0x5061('0x26')](handleEntityNotFound(_0x1972b5,null))[_0x5061('0x26')](function(_0x3a8450){if(_0x3a8450){_0x235c4c=_0x3a8450;_0x4e3d2a[_0x5061('0x34')]=_['keys'](db['Interval']['rawAttributes']);_0x4e3d2a[_0x5061('0x36')]=_[_0x5061('0x35')](_0x3deb7f['query']);_0x4e3d2a[_0x5061('0x37')]=_[_0x5061('0x48')](_0x4e3d2a[_0x5061('0x34')],_0x4e3d2a['query']);_0x332531[_0x5061('0x39')]=_[_0x5061('0x48')](_0x4e3d2a[_0x5061('0x34')],qs[_0x5061('0x38')](_0x3deb7f[_0x5061('0x36')][_0x5061('0x38')]));_0x332531[_0x5061('0x39')]=_0x332531['attributes'][_0x5061('0x49')]?_0x332531[_0x5061('0x39')]:_0x4e3d2a[_0x5061('0x34')];_0x332531[_0x5061('0x3b')]=qs[_0x5061('0x58')](_0x3deb7f[_0x5061('0x36')][_0x5061('0x58')]);_0x332531['where']=qs[_0x5061('0x37')](_[_0x5061('0x3d')](_0x3deb7f['query'],_0x4e3d2a['filters']));if(_0x3deb7f[_0x5061('0x36')][_0x5061('0x40')]){_0x332531[_0x5061('0x3c')]=_[_0x5061('0x3e')](_0x332531['where'],{'$or':_[_0x5061('0x30')](_0x332531['attributes'],function(_0x49afd4){var _0x41939f={};_0x41939f[_0x49afd4]={'$like':'%'+_0x3deb7f[_0x5061('0x36')][_0x5061('0x40')]+'%'};return _0x41939f;})});}_0x332531=_['merge']({},_0x332531,_0x3deb7f[_0x5061('0x41')]);return _0x235c4c['getIntervals'](_0x332531);}})[_0x5061('0x26')](function(_0x40af19){if(_0x40af19){_0x518f47=_0x40af19[_0x5061('0x49')];if(!_0x3deb7f[_0x5061('0x36')]['hasOwnProperty'](_0x5061('0x3a'))){_0x332531[_0x5061('0x1e')]=qs[_0x5061('0x1e')](_0x3deb7f[_0x5061('0x36')]['limit']);_0x332531[_0x5061('0x1c')]=qs['offset'](_0x3deb7f[_0x5061('0x36')]['offset']);}return _0x235c4c[_0x5061('0x56')](_0x332531);}})[_0x5061('0x26')](function(_0xe395c){if(_0xe395c){return _0xe395c?{'count':_0x518f47,'rows':_0xe395c}:null;}})[_0x5061('0x26')](respondWithResult(_0x1972b5,null))[_0x5061('0x45')](handleError(_0x1972b5,null));};exports[_0x5061('0x59')]=function(_0x27b436,_0x2950df,_0x2214b3){return db[_0x5061('0x42')][_0x5061('0x57')]({'where':{'id':_0x27b436['params']['id']}})[_0x5061('0x26')](handleEntityNotFound(_0x2950df,null))[_0x5061('0x26')](function(_0x5e5f5c){if(_0x5e5f5c){return db['sequelize']['transaction'](function(_0xd0a3fc){return db[_0x5061('0x42')][_0x5061('0x27')]({'where':{'IntervalId':_0x27b436[_0x5061('0x47')]['id']},'transaction':_0xd0a3fc})[_0x5061('0x26')](function(_0x365768){var _0x514cc5=_[_0x5061('0x30')](_0x27b436[_0x5061('0x53')],function(_0x5927d6){delete _0x5927d6['id'];_0x5927d6['IntervalId']=_0x27b436[_0x5061('0x47')]['id'];return _0x5927d6;});return db[_0x5061('0x42')][_0x5061('0x5a')](_0x514cc5,{'transaction':_0xd0a3fc});});})[_0x5061('0x26')](function(){return db[_0x5061('0x42')]['findAll']({'where':{'IntervalId':_0x27b436[_0x5061('0x47')]['id']}});});}})['then'](respondWithResult(_0x2950df,null))[_0x5061('0x45')](handleError(_0x2950df,null));};
\ No newline at end of file
+var _0x8f22=['nolimit','order','sort','filter','where','merge','VIRTUAL','options','include','rows','catch','show','includeAll','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','addInterval','IntervalId','getIntervals','length','addIntervals','findOne','sequelize','transaction','findAll','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','ejs','lodash','squel','crypto','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../mysqldb','../../components/extensions/rewrite','sendStatus','status','end','json','undefined','count','offset','limit','set','Content-Range','update','then','destroy','get','Intervals','UserProfileResource','stack','name','send','map','Interval','rawAttributes','fieldName','type','key','model','query','filters','intersection','attributes','fields','hasOwnProperty'];(function(_0x47cf83,_0x1a543a){var _0xa72a8d=function(_0x2d67de){while(--_0x2d67de){_0x47cf83['push'](_0x47cf83['shift']());}};_0xa72a8d(++_0x1a543a);}(_0x8f22,0x7f));var _0x28f2=function(_0x42cae2,_0x284ef8){_0x42cae2=_0x42cae2-0x0;var _0x5f256f=_0x8f22[_0x42cae2];return _0x5f256f;};'use strict';var emlformat=require(_0x28f2('0x0'));var rimraf=require(_0x28f2('0x1'));var zipdir=require(_0x28f2('0x2'));var jsonpatch=require(_0x28f2('0x3'));var rp=require(_0x28f2('0x4'));var moment=require(_0x28f2('0x5'));var BPromise=require(_0x28f2('0x6'));var Mustache=require(_0x28f2('0x7'));var util=require(_0x28f2('0x8'));var path=require(_0x28f2('0x9'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0x28f2('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0x28f2('0xb'));var squel=require(_0x28f2('0xc'));var crypto=require(_0x28f2('0xd'));var jsforce=require('jsforce');var deskjs=require(_0x28f2('0xe'));var toCsv=require(_0x28f2('0xf'));var querystring=require(_0x28f2('0x10'));var Papa=require(_0x28f2('0x11'));var Redis=require(_0x28f2('0x12'));var authService=require(_0x28f2('0x13'));var qs=require(_0x28f2('0x14'));var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x28f2('0x15'));var logger=require(_0x28f2('0x16'))('api');var utils=require(_0x28f2('0x17'));var config=require(_0x28f2('0x18'));var licenseUtil=require('../../config/license/util');var db=require(_0x28f2('0x19'))['db'];var extensions=require(_0x28f2('0x1a'));function respondWithStatusCode(_0x2a4d14,_0x268740){_0x268740=_0x268740||0xcc;return function(_0x2e4c08){if(_0x2e4c08){return _0x2a4d14[_0x28f2('0x1b')](_0x268740);}return _0x2a4d14[_0x28f2('0x1c')](_0x268740)[_0x28f2('0x1d')]();};}function respondWithResult(_0x4c6f1f,_0xc6565f){_0xc6565f=_0xc6565f||0xc8;return function(_0x42aea7){if(_0x42aea7){return _0x4c6f1f[_0x28f2('0x1c')](_0xc6565f)[_0x28f2('0x1e')](_0x42aea7);}};}function respondWithFilteredResult(_0x5e4f05,_0x594fba){return function(_0x3ddc8c){if(_0x3ddc8c){var _0x85d59d=typeof _0x594fba['offset']===_0x28f2('0x1f')&&typeof _0x594fba['limit']===_0x28f2('0x1f');var _0x4dc07f=_0x3ddc8c[_0x28f2('0x20')];var _0x4c080e=_0x85d59d?0x0:_0x594fba[_0x28f2('0x21')];var _0x64fbb6=_0x85d59d?_0x3ddc8c[_0x28f2('0x20')]:_0x594fba[_0x28f2('0x21')]+_0x594fba[_0x28f2('0x22')];var _0x160a68;if(_0x64fbb6>=_0x4dc07f){_0x64fbb6=_0x4dc07f;_0x160a68=0xc8;}else{_0x160a68=0xce;}_0x5e4f05[_0x28f2('0x1c')](_0x160a68);return _0x5e4f05[_0x28f2('0x23')](_0x28f2('0x24'),_0x4c080e+'-'+_0x64fbb6+'/'+_0x4dc07f)['json'](_0x3ddc8c);}return null;};}function patchUpdates(_0x47846e){return function(_0x4e1d7e){try{jsonpatch['apply'](_0x4e1d7e,_0x47846e,!![]);}catch(_0x27dd54){return BPromise['reject'](_0x27dd54);}return _0x4e1d7e['save']();};}function saveUpdates(_0x5989ad,_0x929569){return function(_0x1242c9){if(_0x1242c9){return _0x1242c9[_0x28f2('0x25')](_0x5989ad)[_0x28f2('0x26')](function(_0xe5a5dd){return _0xe5a5dd;});}return null;};}function removeEntity(_0x2405aa,_0x431875){return function(_0x4a6f71){if(_0x4a6f71){return _0x4a6f71[_0x28f2('0x27')]()['then'](function(){var _0x39dc5d=_0x4a6f71[_0x28f2('0x28')]({'plain':!![]});var _0x3cff60=_0x28f2('0x29');return db[_0x28f2('0x2a')][_0x28f2('0x27')]({'where':{'type':_0x3cff60,'resourceId':_0x39dc5d['id']}})['then'](function(){return _0x4a6f71;});})[_0x28f2('0x26')](function(){_0x2405aa['status'](0xcc)[_0x28f2('0x1d')]();});}};}function handleEntityNotFound(_0x5886ca,_0x5313d1){return function(_0xe4ea88){if(!_0xe4ea88){_0x5886ca[_0x28f2('0x1b')](0x194);}return _0xe4ea88;};}function handleError(_0xf8b431,_0x18cecf){_0x18cecf=_0x18cecf||0x1f4;return function(_0x3ac616){logger['error'](_0x3ac616[_0x28f2('0x2b')]);if(_0x3ac616[_0x28f2('0x2c')]){delete _0x3ac616[_0x28f2('0x2c')];}_0xf8b431[_0x28f2('0x1c')](_0x18cecf)[_0x28f2('0x2d')](_0x3ac616);};}exports['index']=function(_0x5eed50,_0x4eb584){var _0x53b98f={},_0x47db44={},_0x4aca93={'count':0x0,'rows':[]};var _0x3fe261=_[_0x28f2('0x2e')](db[_0x28f2('0x2f')][_0x28f2('0x30')],function(_0x134d46){return{'name':_0x134d46[_0x28f2('0x31')],'type':_0x134d46[_0x28f2('0x32')][_0x28f2('0x33')]};});_0x47db44[_0x28f2('0x34')]=_[_0x28f2('0x2e')](_0x3fe261,_0x28f2('0x2c'));_0x47db44[_0x28f2('0x35')]=_['keys'](_0x5eed50[_0x28f2('0x35')]);_0x47db44[_0x28f2('0x36')]=_[_0x28f2('0x37')](_0x47db44[_0x28f2('0x34')],_0x47db44['query']);_0x53b98f[_0x28f2('0x38')]=_[_0x28f2('0x37')](_0x47db44[_0x28f2('0x34')],qs[_0x28f2('0x39')](_0x5eed50[_0x28f2('0x35')][_0x28f2('0x39')]));_0x53b98f[_0x28f2('0x38')]=_0x53b98f[_0x28f2('0x38')]['length']?_0x53b98f[_0x28f2('0x38')]:_0x47db44[_0x28f2('0x34')];if(!_0x5eed50['query'][_0x28f2('0x3a')](_0x28f2('0x3b'))){_0x53b98f[_0x28f2('0x22')]=qs[_0x28f2('0x22')](_0x5eed50[_0x28f2('0x35')]['limit']);_0x53b98f['offset']=qs[_0x28f2('0x21')](_0x5eed50['query'][_0x28f2('0x21')]);}_0x53b98f[_0x28f2('0x3c')]=qs['sort'](_0x5eed50[_0x28f2('0x35')][_0x28f2('0x3d')]);_0x53b98f['where']=qs[_0x28f2('0x36')](_['pick'](_0x5eed50['query'],_0x47db44[_0x28f2('0x36')]),_0x3fe261);if(_0x5eed50['query'][_0x28f2('0x3e')]){_0x53b98f[_0x28f2('0x3f')]=_[_0x28f2('0x40')](_0x53b98f[_0x28f2('0x3f')],{'$or':_['map'](_0x3fe261,function(_0x4b132d){if(_0x4b132d[_0x28f2('0x32')]!==_0x28f2('0x41')){var _0x1cac9c={};_0x1cac9c[_0x4b132d[_0x28f2('0x2c')]]={'$like':'%'+_0x5eed50[_0x28f2('0x35')][_0x28f2('0x3e')]+'%'};return _0x1cac9c;}})});}_0x53b98f=_['merge']({},_0x53b98f,_0x5eed50[_0x28f2('0x42')]);var _0x1828ac={'where':_0x53b98f[_0x28f2('0x3f')]};return db[_0x28f2('0x2f')]['count'](_0x1828ac)[_0x28f2('0x26')](function(_0x406686){_0x4aca93[_0x28f2('0x20')]=_0x406686;if(_0x5eed50[_0x28f2('0x35')]['includeAll']){_0x53b98f[_0x28f2('0x43')]=[{'all':!![]}];}return db[_0x28f2('0x2f')]['findAll'](_0x53b98f);})[_0x28f2('0x26')](function(_0x4f9d89){_0x4aca93[_0x28f2('0x44')]=_0x4f9d89;return _0x4aca93;})['then'](respondWithFilteredResult(_0x4eb584,_0x53b98f))[_0x28f2('0x45')](handleError(_0x4eb584,null));};exports[_0x28f2('0x46')]=function(_0x3e7420,_0x19be18){var _0x3a78ba={'raw':!![],'where':{'id':_0x3e7420['params']['id']}},_0x2ac45d={};_0x2ac45d[_0x28f2('0x34')]=_['keys'](db[_0x28f2('0x2f')][_0x28f2('0x30')]);_0x2ac45d[_0x28f2('0x35')]=_['keys'](_0x3e7420[_0x28f2('0x35')]);_0x2ac45d['filters']=_[_0x28f2('0x37')](_0x2ac45d[_0x28f2('0x34')],_0x2ac45d[_0x28f2('0x35')]);_0x3a78ba['attributes']=_[_0x28f2('0x37')](_0x2ac45d[_0x28f2('0x34')],qs[_0x28f2('0x39')](_0x3e7420[_0x28f2('0x35')]['fields']));_0x3a78ba[_0x28f2('0x38')]=_0x3a78ba['attributes']['length']?_0x3a78ba[_0x28f2('0x38')]:_0x2ac45d[_0x28f2('0x34')];if(_0x3e7420[_0x28f2('0x35')][_0x28f2('0x47')]){_0x3a78ba[_0x28f2('0x43')]=[{'all':!![]}];}_0x3a78ba=_[_0x28f2('0x40')]({},_0x3a78ba,_0x3e7420[_0x28f2('0x42')]);return db[_0x28f2('0x2f')][_0x28f2('0x48')](_0x3a78ba)[_0x28f2('0x26')](handleEntityNotFound(_0x19be18,null))['then'](respondWithResult(_0x19be18,null))[_0x28f2('0x45')](handleError(_0x19be18,null));};exports['create']=function(_0xa6b9e2,_0x106fb7){return db[_0x28f2('0x2f')][_0x28f2('0x49')](_0xa6b9e2[_0x28f2('0x4a')],{})[_0x28f2('0x26')](function(_0x3fe42c){var _0x3794a7=_0xa6b9e2[_0x28f2('0x4b')][_0x28f2('0x28')]({'plain':!![]});if(!_0x3794a7)throw new Error(_0x28f2('0x4c'));if(_0x3794a7[_0x28f2('0x4d')]===_0x28f2('0x4b')){var _0x73dae2=_0x3fe42c[_0x28f2('0x28')]({'plain':!![]});var _0x5a98de=_0x28f2('0x29');return db[_0x28f2('0x4e')]['find']({'where':{'name':_0x5a98de,'userProfileId':_0x3794a7[_0x28f2('0x4f')]},'raw':!![]})[_0x28f2('0x26')](function(_0x46650c){if(_0x46650c&&_0x46650c[_0x28f2('0x50')]===0x0){return db[_0x28f2('0x2a')][_0x28f2('0x49')]({'name':_0x73dae2[_0x28f2('0x2c')],'resourceId':_0x73dae2['id'],'type':_0x46650c[_0x28f2('0x2c')],'sectionId':_0x46650c['id']},{})[_0x28f2('0x26')](function(){return _0x3fe42c;});}else{return _0x3fe42c;}})[_0x28f2('0x45')](function(_0x114ced){logger[_0x28f2('0x51')](_0x28f2('0x52'),_0x114ced);throw _0x114ced;});}return _0x3fe42c;})[_0x28f2('0x26')](respondWithResult(_0x106fb7,0xc9))['catch'](handleError(_0x106fb7,null));};exports[_0x28f2('0x25')]=function(_0x996ee6,_0x4e099c){if(_0x996ee6[_0x28f2('0x4a')]['id']){delete _0x996ee6[_0x28f2('0x4a')]['id'];}return db[_0x28f2('0x2f')][_0x28f2('0x48')]({'where':{'id':_0x996ee6['params']['id']}})[_0x28f2('0x26')](handleEntityNotFound(_0x4e099c,null))[_0x28f2('0x26')](saveUpdates(_0x996ee6[_0x28f2('0x4a')],null))[_0x28f2('0x26')](respondWithResult(_0x4e099c,null))[_0x28f2('0x45')](handleError(_0x4e099c,null));};exports['destroy']=function(_0x55f2c8,_0x43a5a7){return db[_0x28f2('0x2f')][_0x28f2('0x48')]({'where':{'id':_0x55f2c8[_0x28f2('0x53')]['id']}})['then'](handleEntityNotFound(_0x43a5a7,null))[_0x28f2('0x26')](removeEntity(_0x43a5a7,null))[_0x28f2('0x45')](handleError(_0x43a5a7,null));};exports[_0x28f2('0x54')]=function(_0x30162e,_0x153337,_0x2017db){if(_0x30162e[_0x28f2('0x4a')]['id']){delete _0x30162e[_0x28f2('0x4a')]['id'];}return db['Interval']['find']({'where':{'id':_0x30162e[_0x28f2('0x53')]['id']}})[_0x28f2('0x26')](handleEntityNotFound(_0x153337,null))[_0x28f2('0x26')](function(_0xd1de07){if(_0xd1de07){_0x30162e[_0x28f2('0x4a')][_0x28f2('0x55')]=_0xd1de07['id'];return db[_0x28f2('0x2f')][_0x28f2('0x49')](_0x30162e[_0x28f2('0x4a')]);}})['then'](respondWithResult(_0x153337,null))[_0x28f2('0x45')](handleError(_0x153337,null));};exports[_0x28f2('0x56')]=function(_0x5b6745,_0x1e0f07,_0x41c7fc){var _0x38bff4={};var _0x3c271f={};var _0x28c76c;var _0x13cbd9;return db[_0x28f2('0x2f')]['findOne']({'where':{'id':_0x5b6745[_0x28f2('0x53')]['id']}})['then'](handleEntityNotFound(_0x1e0f07,null))[_0x28f2('0x26')](function(_0x10ebb6){if(_0x10ebb6){_0x28c76c=_0x10ebb6;_0x3c271f[_0x28f2('0x34')]=_['keys'](db[_0x28f2('0x2f')][_0x28f2('0x30')]);_0x3c271f['query']=_['keys'](_0x5b6745['query']);_0x3c271f[_0x28f2('0x36')]=_[_0x28f2('0x37')](_0x3c271f['model'],_0x3c271f[_0x28f2('0x35')]);_0x38bff4['attributes']=_[_0x28f2('0x37')](_0x3c271f['model'],qs[_0x28f2('0x39')](_0x5b6745[_0x28f2('0x35')][_0x28f2('0x39')]));_0x38bff4[_0x28f2('0x38')]=_0x38bff4[_0x28f2('0x38')][_0x28f2('0x57')]?_0x38bff4[_0x28f2('0x38')]:_0x3c271f['model'];_0x38bff4[_0x28f2('0x3c')]=qs[_0x28f2('0x3d')](_0x5b6745[_0x28f2('0x35')]['sort']);_0x38bff4[_0x28f2('0x3f')]=qs['filters'](_['pick'](_0x5b6745[_0x28f2('0x35')],_0x3c271f['filters']));if(_0x5b6745['query'][_0x28f2('0x3e')]){_0x38bff4['where']=_[_0x28f2('0x40')](_0x38bff4[_0x28f2('0x3f')],{'$or':_['map'](_0x38bff4[_0x28f2('0x38')],function(_0x3b5391){var _0x3cff9f={};_0x3cff9f[_0x3b5391]={'$like':'%'+_0x5b6745['query'][_0x28f2('0x3e')]+'%'};return _0x3cff9f;})});}_0x38bff4=_[_0x28f2('0x40')]({},_0x38bff4,_0x5b6745[_0x28f2('0x42')]);return _0x28c76c['getIntervals'](_0x38bff4);}})[_0x28f2('0x26')](function(_0x28e985){if(_0x28e985){_0x13cbd9=_0x28e985[_0x28f2('0x57')];if(!_0x5b6745[_0x28f2('0x35')][_0x28f2('0x3a')](_0x28f2('0x3b'))){_0x38bff4[_0x28f2('0x22')]=qs[_0x28f2('0x22')](_0x5b6745[_0x28f2('0x35')]['limit']);_0x38bff4[_0x28f2('0x21')]=qs[_0x28f2('0x21')](_0x5b6745['query']['offset']);}return _0x28c76c['getIntervals'](_0x38bff4);}})[_0x28f2('0x26')](function(_0x53e85b){if(_0x53e85b){return _0x53e85b?{'count':_0x13cbd9,'rows':_0x53e85b}:null;}})[_0x28f2('0x26')](respondWithResult(_0x1e0f07,null))[_0x28f2('0x45')](handleError(_0x1e0f07,null));};exports[_0x28f2('0x58')]=function(_0x25cc97,_0x5bdceb,_0x18947f){return db[_0x28f2('0x2f')][_0x28f2('0x59')]({'where':{'id':_0x25cc97[_0x28f2('0x53')]['id']}})[_0x28f2('0x26')](handleEntityNotFound(_0x5bdceb,null))[_0x28f2('0x26')](function(_0x198d6f){if(_0x198d6f){return db[_0x28f2('0x5a')][_0x28f2('0x5b')](function(_0x590ec1){return db[_0x28f2('0x2f')][_0x28f2('0x27')]({'where':{'IntervalId':_0x25cc97['params']['id']},'transaction':_0x590ec1})['then'](function(_0x185382){var _0x104640=_[_0x28f2('0x2e')](_0x25cc97[_0x28f2('0x4a')],function(_0x3d53a9){delete _0x3d53a9['id'];_0x3d53a9[_0x28f2('0x55')]=_0x25cc97[_0x28f2('0x53')]['id'];return _0x3d53a9;});return db['Interval']['bulkCreate'](_0x104640,{'transaction':_0x590ec1});});})[_0x28f2('0x26')](function(){return db['Interval'][_0x28f2('0x5c')]({'where':{'IntervalId':_0x25cc97[_0x28f2('0x53')]['id']}});});}})[_0x28f2('0x26')](respondWithResult(_0x5bdceb,null))[_0x28f2('0x45')](handleError(_0x5bdceb,null));};
\ No newline at end of file