Built motion from commit d5e4af8c.|2.6.23
[motion2.git] / server / api / interval / interval.controller.js
index 8f2b685..4f129f8 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x4f66=['../../mysqldb','status','end','json','count','offset','limit','set','Content-Range','reject','save','update','then','destroy','get','Intervals','UserProfileResource','sendStatus','error','send','index','rawAttributes','fieldName','type','model','name','query','filters','attributes','intersection','fields','length','nolimit','order','sort','where','pick','filter','merge','options','Interval','findAll','rows','show','params','keys','includeAll','include','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','find','userProfileId','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','addInterval','IntervalId','getIntervals','map','hasOwnProperty','addIntervals','findOne','sequelize','transaction','bulkCreate','html-pdf','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','util','path','sox','to-csv','lodash','crypto','jsforce','desk.js','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment'];(function(_0x43459b,_0x220fae){var _0x557c66=function(_0xc4fd96){while(--_0xc4fd96){_0x43459b['push'](_0x43459b['shift']());}};_0x557c66(++_0x220fae);}(_0x4f66,0x1b9));var _0x64f6=function(_0x111ce3,_0x5e12aa){_0x111ce3=_0x111ce3-0x0;var _0xd0c223=_0x4f66[_0x111ce3];return _0xd0c223;};'use strict';var pdf=require(_0x64f6('0x0'));var emlformat=require(_0x64f6('0x1'));var rimraf=require(_0x64f6('0x2'));var zipdir=require(_0x64f6('0x3'));var jsonpatch=require(_0x64f6('0x4'));var rp=require(_0x64f6('0x5'));var moment=require(_0x64f6('0x6'));var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0x64f6('0x7'));var path=require(_0x64f6('0x8'));var sox=require(_0x64f6('0x9'));var csv=require(_0x64f6('0xa'));var ejs=require('ejs');var fs=require('fs');var _=require(_0x64f6('0xb'));var squel=require('squel');var crypto=require(_0x64f6('0xc'));var jsforce=require(_0x64f6('0xd'));var deskjs=require(_0x64f6('0xe'));var toCsv=require(_0x64f6('0xa'));var querystring=require(_0x64f6('0xf'));var Papa=require(_0x64f6('0x10'));var Redis=require(_0x64f6('0x11'));var authService=require(_0x64f6('0x12'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0x64f6('0x13'));var logger=require(_0x64f6('0x14'))(_0x64f6('0x15'));var utils=require(_0x64f6('0x16'));var config=require(_0x64f6('0x17'));var db=require(_0x64f6('0x18'))['db'];var extensions=require('../../components/extensions/rewrite');function respondWithStatusCode(_0x38776f,_0x54c587){_0x54c587=_0x54c587||0xcc;return function(_0x3a24fd){if(_0x3a24fd){return _0x38776f['sendStatus'](_0x54c587);}return _0x38776f[_0x64f6('0x19')](_0x54c587)[_0x64f6('0x1a')]();};}function respondWithResult(_0x1e2e34,_0x20c973){_0x20c973=_0x20c973||0xc8;return function(_0x3b23d0){if(_0x3b23d0){return _0x1e2e34[_0x64f6('0x19')](_0x20c973)[_0x64f6('0x1b')](_0x3b23d0);}};}function respondWithFilteredResult(_0x316597,_0x3a8883){return function(_0x13c658){if(_0x13c658){var _0x18515f=_0x13c658[_0x64f6('0x1c')],_0x36cd81=_0x3a8883[_0x64f6('0x1d')],_0x576aeb=_0x3a8883[_0x64f6('0x1d')]+_0x3a8883[_0x64f6('0x1e')],_0x545d2a;if(_0x576aeb>=_0x18515f){_0x576aeb=_0x18515f;_0x545d2a=0xc8;}else{_0x545d2a=0xce;}_0x316597[_0x64f6('0x19')](_0x545d2a);return _0x316597[_0x64f6('0x1f')](_0x64f6('0x20'),_0x36cd81+'-'+_0x576aeb+'/'+_0x18515f)['json'](_0x13c658);}return null;};}function patchUpdates(_0x238e88){return function(_0x534bfe){try{jsonpatch['apply'](_0x534bfe,_0x238e88,!![]);}catch(_0x4b627a){return BPromise[_0x64f6('0x21')](_0x4b627a);}return _0x534bfe[_0x64f6('0x22')]();};}function saveUpdates(_0x773318,_0x3566d4){return function(_0x385d0f){if(_0x385d0f){return _0x385d0f[_0x64f6('0x23')](_0x773318)[_0x64f6('0x24')](function(_0x2fd208){return _0x2fd208;});}return null;};}function removeEntity(_0x28b974,_0x4eff98){return function(_0x9c950c){if(_0x9c950c){return _0x9c950c[_0x64f6('0x25')]()[_0x64f6('0x24')](function(){var _0x5cd616=_0x9c950c[_0x64f6('0x26')]({'plain':!![]});var _0x391483=_0x64f6('0x27');return db[_0x64f6('0x28')][_0x64f6('0x25')]({'where':{'type':_0x391483,'resourceId':_0x5cd616['id']}})['then'](function(){return _0x9c950c;});})['then'](function(){_0x28b974[_0x64f6('0x19')](0xcc)[_0x64f6('0x1a')]();});}};}function handleEntityNotFound(_0x24359f,_0x160255){return function(_0xea95a3){if(!_0xea95a3){_0x24359f[_0x64f6('0x29')](0x194);}return _0xea95a3;};}function handleError(_0x6952ea,_0x1774bb){_0x1774bb=_0x1774bb||0x1f4;return function(_0x5daf28){logger[_0x64f6('0x2a')](_0x5daf28['stack']);if(_0x5daf28['name']){delete _0x5daf28['name'];}_0x6952ea['status'](_0x1774bb)[_0x64f6('0x2b')](_0x5daf28);};}exports[_0x64f6('0x2c')]=function(_0x58dcbc,_0xc80291){var _0x23df17={},_0x45f0cb={},_0x348b97={'count':0x0,'rows':[]};var _0x147b38=_['map'](db['Interval'][_0x64f6('0x2d')],function(_0xaca904){return{'name':_0xaca904[_0x64f6('0x2e')],'type':_0xaca904[_0x64f6('0x2f')]['key']};});_0x45f0cb[_0x64f6('0x30')]=_['map'](_0x147b38,_0x64f6('0x31'));_0x45f0cb['query']=_['keys'](_0x58dcbc[_0x64f6('0x32')]);_0x45f0cb[_0x64f6('0x33')]=_['intersection'](_0x45f0cb[_0x64f6('0x30')],_0x45f0cb[_0x64f6('0x32')]);_0x23df17[_0x64f6('0x34')]=_[_0x64f6('0x35')](_0x45f0cb[_0x64f6('0x30')],qs[_0x64f6('0x36')](_0x58dcbc[_0x64f6('0x32')][_0x64f6('0x36')]));_0x23df17[_0x64f6('0x34')]=_0x23df17[_0x64f6('0x34')][_0x64f6('0x37')]?_0x23df17[_0x64f6('0x34')]:_0x45f0cb['model'];if(!_0x58dcbc[_0x64f6('0x32')]['hasOwnProperty'](_0x64f6('0x38'))){_0x23df17['limit']=qs[_0x64f6('0x1e')](_0x58dcbc[_0x64f6('0x32')]['limit']);_0x23df17[_0x64f6('0x1d')]=qs[_0x64f6('0x1d')](_0x58dcbc[_0x64f6('0x32')][_0x64f6('0x1d')]);}_0x23df17[_0x64f6('0x39')]=qs[_0x64f6('0x3a')](_0x58dcbc[_0x64f6('0x32')][_0x64f6('0x3a')]);_0x23df17[_0x64f6('0x3b')]=qs[_0x64f6('0x33')](_[_0x64f6('0x3c')](_0x58dcbc[_0x64f6('0x32')],_0x45f0cb[_0x64f6('0x33')]),_0x147b38);if(_0x58dcbc['query'][_0x64f6('0x3d')]){_0x23df17[_0x64f6('0x3b')]=_[_0x64f6('0x3e')](_0x23df17[_0x64f6('0x3b')],{'$or':_['map'](_0x147b38,function(_0x36693b){if(_0x36693b[_0x64f6('0x2f')]!=='VIRTUAL'){var _0x2a6131={};_0x2a6131[_0x36693b[_0x64f6('0x31')]]={'$like':'%'+_0x58dcbc[_0x64f6('0x32')]['filter']+'%'};return _0x2a6131;}})});}_0x23df17=_[_0x64f6('0x3e')]({},_0x23df17,_0x58dcbc[_0x64f6('0x3f')]);var _0x246c76={'where':_0x23df17[_0x64f6('0x3b')]};return db['Interval']['count'](_0x246c76)[_0x64f6('0x24')](function(_0x3cda9d){_0x348b97[_0x64f6('0x1c')]=_0x3cda9d;if(_0x58dcbc[_0x64f6('0x32')]['includeAll']){_0x23df17['include']=[{'all':!![]}];}return db[_0x64f6('0x40')][_0x64f6('0x41')](_0x23df17);})[_0x64f6('0x24')](function(_0x491266){_0x348b97[_0x64f6('0x42')]=_0x491266;return _0x348b97;})[_0x64f6('0x24')](respondWithFilteredResult(_0xc80291,_0x23df17))['catch'](handleError(_0xc80291,null));};exports[_0x64f6('0x43')]=function(_0x24a7e9,_0x3c81e7){var _0x3d45ad={'raw':!![],'where':{'id':_0x24a7e9[_0x64f6('0x44')]['id']}},_0x24d2a0={};_0x24d2a0['model']=_[_0x64f6('0x45')](db[_0x64f6('0x40')][_0x64f6('0x2d')]);_0x24d2a0['query']=_[_0x64f6('0x45')](_0x24a7e9[_0x64f6('0x32')]);_0x24d2a0[_0x64f6('0x33')]=_['intersection'](_0x24d2a0[_0x64f6('0x30')],_0x24d2a0[_0x64f6('0x32')]);_0x3d45ad[_0x64f6('0x34')]=_[_0x64f6('0x35')](_0x24d2a0[_0x64f6('0x30')],qs['fields'](_0x24a7e9[_0x64f6('0x32')]['fields']));_0x3d45ad[_0x64f6('0x34')]=_0x3d45ad[_0x64f6('0x34')][_0x64f6('0x37')]?_0x3d45ad['attributes']:_0x24d2a0[_0x64f6('0x30')];if(_0x24a7e9[_0x64f6('0x32')][_0x64f6('0x46')]){_0x3d45ad[_0x64f6('0x47')]=[{'all':!![]}];}_0x3d45ad=_[_0x64f6('0x3e')]({},_0x3d45ad,_0x24a7e9[_0x64f6('0x3f')]);return db[_0x64f6('0x40')]['find'](_0x3d45ad)[_0x64f6('0x24')](handleEntityNotFound(_0x3c81e7,null))[_0x64f6('0x24')](respondWithResult(_0x3c81e7,null))[_0x64f6('0x48')](handleError(_0x3c81e7,null));};exports[_0x64f6('0x49')]=function(_0x5c3b35,_0xa0126e){return db['Interval']['create'](_0x5c3b35[_0x64f6('0x4a')],{})[_0x64f6('0x24')](function(_0x967f71){var _0x5d53b3=_0x5c3b35[_0x64f6('0x4b')][_0x64f6('0x26')]({'plain':!![]});if(!_0x5d53b3)throw new Error(_0x64f6('0x4c'));if(_0x5d53b3[_0x64f6('0x4d')]==='user'){var _0x8b7298=_0x967f71['get']({'plain':!![]});var _0x5dda07='Intervals';return db[_0x64f6('0x4e')][_0x64f6('0x4f')]({'where':{'name':_0x5dda07,'userProfileId':_0x5d53b3[_0x64f6('0x50')]},'raw':!![]})[_0x64f6('0x24')](function(_0x5a5a53){if(_0x5a5a53&&_0x5a5a53[_0x64f6('0x51')]===0x0){return db[_0x64f6('0x28')][_0x64f6('0x49')]({'name':_0x8b7298[_0x64f6('0x31')],'resourceId':_0x8b7298['id'],'type':_0x5a5a53[_0x64f6('0x31')],'sectionId':_0x5a5a53['id']},{})[_0x64f6('0x24')](function(){return _0x967f71;});}else{return _0x967f71;}})[_0x64f6('0x48')](function(_0x549621){logger[_0x64f6('0x2a')](_0x64f6('0x52'),_0x549621);throw _0x549621;});}return _0x967f71;})[_0x64f6('0x24')](respondWithResult(_0xa0126e,0xc9))[_0x64f6('0x48')](handleError(_0xa0126e,null));};exports[_0x64f6('0x23')]=function(_0x47aa3e,_0x469f23){if(_0x47aa3e['body']['id']){delete _0x47aa3e[_0x64f6('0x4a')]['id'];}return db[_0x64f6('0x40')][_0x64f6('0x4f')]({'where':{'id':_0x47aa3e[_0x64f6('0x44')]['id']}})[_0x64f6('0x24')](handleEntityNotFound(_0x469f23,null))[_0x64f6('0x24')](saveUpdates(_0x47aa3e[_0x64f6('0x4a')],null))[_0x64f6('0x24')](respondWithResult(_0x469f23,null))[_0x64f6('0x48')](handleError(_0x469f23,null));};exports[_0x64f6('0x25')]=function(_0x55f720,_0x6624ce){return db[_0x64f6('0x40')][_0x64f6('0x4f')]({'where':{'id':_0x55f720[_0x64f6('0x44')]['id']}})[_0x64f6('0x24')](handleEntityNotFound(_0x6624ce,null))[_0x64f6('0x24')](removeEntity(_0x6624ce,null))[_0x64f6('0x48')](handleError(_0x6624ce,null));};exports[_0x64f6('0x53')]=function(_0x493b47,_0x15ef12,_0x135ad4){if(_0x493b47[_0x64f6('0x4a')]['id']){delete _0x493b47[_0x64f6('0x4a')]['id'];}return db[_0x64f6('0x40')][_0x64f6('0x4f')]({'where':{'id':_0x493b47[_0x64f6('0x44')]['id']}})[_0x64f6('0x24')](handleEntityNotFound(_0x15ef12,null))[_0x64f6('0x24')](function(_0x2fe582){if(_0x2fe582){_0x493b47[_0x64f6('0x4a')][_0x64f6('0x54')]=_0x2fe582['id'];return db['Interval'][_0x64f6('0x49')](_0x493b47[_0x64f6('0x4a')]);}})[_0x64f6('0x24')](respondWithResult(_0x15ef12,null))['catch'](handleError(_0x15ef12,null));};exports[_0x64f6('0x55')]=function(_0x351802,_0x22f946,_0x76e5a6){var _0x4ecf1f={};var _0x3bd22b={};var _0x5d172d;var _0x39e742;return db[_0x64f6('0x40')]['findOne']({'where':{'id':_0x351802['params']['id']}})[_0x64f6('0x24')](handleEntityNotFound(_0x22f946,null))['then'](function(_0x54c0ec){if(_0x54c0ec){_0x5d172d=_0x54c0ec;_0x3bd22b[_0x64f6('0x30')]=_['keys'](db[_0x64f6('0x40')]['rawAttributes']);_0x3bd22b[_0x64f6('0x32')]=_[_0x64f6('0x45')](_0x351802[_0x64f6('0x32')]);_0x3bd22b[_0x64f6('0x33')]=_[_0x64f6('0x35')](_0x3bd22b['model'],_0x3bd22b[_0x64f6('0x32')]);_0x4ecf1f[_0x64f6('0x34')]=_[_0x64f6('0x35')](_0x3bd22b[_0x64f6('0x30')],qs[_0x64f6('0x36')](_0x351802[_0x64f6('0x32')][_0x64f6('0x36')]));_0x4ecf1f['attributes']=_0x4ecf1f[_0x64f6('0x34')][_0x64f6('0x37')]?_0x4ecf1f[_0x64f6('0x34')]:_0x3bd22b[_0x64f6('0x30')];_0x4ecf1f['order']=qs[_0x64f6('0x3a')](_0x351802[_0x64f6('0x32')][_0x64f6('0x3a')]);_0x4ecf1f['where']=qs[_0x64f6('0x33')](_['pick'](_0x351802[_0x64f6('0x32')],_0x3bd22b[_0x64f6('0x33')]));if(_0x351802[_0x64f6('0x32')][_0x64f6('0x3d')]){_0x4ecf1f['where']=_[_0x64f6('0x3e')](_0x4ecf1f[_0x64f6('0x3b')],{'$or':_[_0x64f6('0x56')](_0x4ecf1f[_0x64f6('0x34')],function(_0x98bcb){var _0x3fbf34={};_0x3fbf34[_0x98bcb]={'$like':'%'+_0x351802['query'][_0x64f6('0x3d')]+'%'};return _0x3fbf34;})});}_0x4ecf1f=_['merge']({},_0x4ecf1f,_0x351802[_0x64f6('0x3f')]);return _0x5d172d['getIntervals'](_0x4ecf1f);}})[_0x64f6('0x24')](function(_0x382a93){if(_0x382a93){_0x39e742=_0x382a93['length'];if(!_0x351802[_0x64f6('0x32')][_0x64f6('0x57')](_0x64f6('0x38'))){_0x4ecf1f['limit']=qs[_0x64f6('0x1e')](_0x351802[_0x64f6('0x32')][_0x64f6('0x1e')]);_0x4ecf1f[_0x64f6('0x1d')]=qs[_0x64f6('0x1d')](_0x351802[_0x64f6('0x32')][_0x64f6('0x1d')]);}return _0x5d172d[_0x64f6('0x55')](_0x4ecf1f);}})['then'](function(_0x2d0bf9){if(_0x2d0bf9){return _0x2d0bf9?{'count':_0x39e742,'rows':_0x2d0bf9}:null;}})['then'](respondWithResult(_0x22f946,null))[_0x64f6('0x48')](handleError(_0x22f946,null));};exports[_0x64f6('0x58')]=function(_0x27fe94,_0x4c6113,_0x561de3){return db['Interval'][_0x64f6('0x59')]({'where':{'id':_0x27fe94['params']['id']}})[_0x64f6('0x24')](handleEntityNotFound(_0x4c6113,null))[_0x64f6('0x24')](function(_0x56fb40){if(_0x56fb40){return db[_0x64f6('0x5a')][_0x64f6('0x5b')](function(_0x50a9c8){return db[_0x64f6('0x40')][_0x64f6('0x25')]({'where':{'IntervalId':_0x27fe94[_0x64f6('0x44')]['id']},'transaction':_0x50a9c8})[_0x64f6('0x24')](function(_0xe41c96){var _0x3c26b5=_['map'](_0x27fe94[_0x64f6('0x4a')],function(_0x1659d5){delete _0x1659d5['id'];_0x1659d5[_0x64f6('0x54')]=_0x27fe94[_0x64f6('0x44')]['id'];return _0x1659d5;});return db['Interval'][_0x64f6('0x5c')](_0x3c26b5,{'transaction':_0x50a9c8});});})[_0x64f6('0x24')](function(){return db[_0x64f6('0x40')][_0x64f6('0x41')]({'where':{'IntervalId':_0x27fe94['params']['id']}});});}})[_0x64f6('0x24')](respondWithResult(_0x4c6113,null))[_0x64f6('0x48')](handleError(_0x4c6113,null));};
\ No newline at end of file
+var _0x0210=['querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/logger','api','../../mysqldb','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','json','apply','reject','save','update','then','destroy','get','Intervals','UserProfileResource','stack','name','send','index','Interval','rawAttributes','fieldName','type','key','model','map','query','keys','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filters','filter','merge','VIRTUAL','options','includeAll','catch','show','params','include','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','find','addInterval','IntervalId','getIntervals','addIntervals','findOne','sequelize','findAll','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','to-csv','fs-extra','squel','crypto','jsforce','desk.js'];(function(_0x391c55,_0x168617){var _0xa434e0=function(_0x51fa5c){while(--_0x51fa5c){_0x391c55['push'](_0x391c55['shift']());}};_0xa434e0(++_0x168617);}(_0x0210,0xa9));var _0x0021=function(_0x52bb0c,_0x26a464){_0x52bb0c=_0x52bb0c-0x0;var _0x40a7ee=_0x0210[_0x52bb0c];return _0x40a7ee;};'use strict';var emlformat=require(_0x0021('0x0'));var rimraf=require(_0x0021('0x1'));var zipdir=require(_0x0021('0x2'));var jsonpatch=require(_0x0021('0x3'));var rp=require(_0x0021('0x4'));var moment=require(_0x0021('0x5'));var BPromise=require(_0x0021('0x6'));var Mustache=require(_0x0021('0x7'));var util=require(_0x0021('0x8'));var path=require('path');var sox=require('sox');var csv=require(_0x0021('0x9'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x0021('0xa'));var _=require('lodash');var squel=require(_0x0021('0xb'));var crypto=require(_0x0021('0xc'));var jsforce=require(_0x0021('0xd'));var deskjs=require(_0x0021('0xe'));var toCsv=require('to-csv');var querystring=require(_0x0021('0xf'));var Papa=require(_0x0021('0x10'));var Redis=require(_0x0021('0x11'));var authService=require(_0x0021('0x12'));var qs=require(_0x0021('0x13'));var as=require(_0x0021('0x14'));var hardwareService=require('../../config/license/hardware');var logger=require(_0x0021('0x15'))(_0x0021('0x16'));var utils=require('../../config/utils');var config=require('../../config/environment');var licenseUtil=require('../../config/license/util');var db=require(_0x0021('0x17'))['db'];var extensions=require('../../components/extensions/rewrite');function respondWithStatusCode(_0x50b061,_0x3da42c){_0x3da42c=_0x3da42c||0xcc;return function(_0x26748a){if(_0x26748a){return _0x50b061[_0x0021('0x18')](_0x3da42c);}return _0x50b061[_0x0021('0x19')](_0x3da42c)[_0x0021('0x1a')]();};}function respondWithResult(_0x25f155,_0x4f2059){_0x4f2059=_0x4f2059||0xc8;return function(_0x3245e7){if(_0x3245e7){return _0x25f155[_0x0021('0x19')](_0x4f2059)['json'](_0x3245e7);}};}function respondWithFilteredResult(_0x63ca17,_0x58e815){return function(_0x529ce3){if(_0x529ce3){var _0x44d3d9=typeof _0x58e815[_0x0021('0x1b')]===_0x0021('0x1c')&&typeof _0x58e815[_0x0021('0x1d')]===_0x0021('0x1c');var _0x2d7247=_0x529ce3[_0x0021('0x1e')];var _0x2f8775=_0x44d3d9?0x0:_0x58e815[_0x0021('0x1b')];var _0x4c389a=_0x44d3d9?_0x529ce3[_0x0021('0x1e')]:_0x58e815[_0x0021('0x1b')]+_0x58e815['limit'];var _0x3541fc;if(_0x4c389a>=_0x2d7247){_0x4c389a=_0x2d7247;_0x3541fc=0xc8;}else{_0x3541fc=0xce;}_0x63ca17['status'](_0x3541fc);return _0x63ca17[_0x0021('0x1f')](_0x0021('0x20'),_0x2f8775+'-'+_0x4c389a+'/'+_0x2d7247)[_0x0021('0x21')](_0x529ce3);}return null;};}function patchUpdates(_0x2a99aa){return function(_0x48a6f2){try{jsonpatch[_0x0021('0x22')](_0x48a6f2,_0x2a99aa,!![]);}catch(_0xdc4943){return BPromise[_0x0021('0x23')](_0xdc4943);}return _0x48a6f2[_0x0021('0x24')]();};}function saveUpdates(_0x2c01a0,_0x4fa6b1){return function(_0x1e4161){if(_0x1e4161){return _0x1e4161[_0x0021('0x25')](_0x2c01a0)[_0x0021('0x26')](function(_0x515ae3){return _0x515ae3;});}return null;};}function removeEntity(_0x164795,_0x3643b9){return function(_0x37cd07){if(_0x37cd07){return _0x37cd07[_0x0021('0x27')]()[_0x0021('0x26')](function(){var _0x58a381=_0x37cd07[_0x0021('0x28')]({'plain':!![]});var _0x1a0a21=_0x0021('0x29');return db[_0x0021('0x2a')]['destroy']({'where':{'type':_0x1a0a21,'resourceId':_0x58a381['id']}})[_0x0021('0x26')](function(){return _0x37cd07;});})['then'](function(){_0x164795[_0x0021('0x19')](0xcc)[_0x0021('0x1a')]();});}};}function handleEntityNotFound(_0x50040b,_0x5c4313){return function(_0x5f4328){if(!_0x5f4328){_0x50040b[_0x0021('0x18')](0x194);}return _0x5f4328;};}function handleError(_0x124c45,_0x1e67db){_0x1e67db=_0x1e67db||0x1f4;return function(_0x24441e){logger['error'](_0x24441e[_0x0021('0x2b')]);if(_0x24441e[_0x0021('0x2c')]){delete _0x24441e['name'];}_0x124c45[_0x0021('0x19')](_0x1e67db)[_0x0021('0x2d')](_0x24441e);};}exports[_0x0021('0x2e')]=function(_0x27a43a,_0x1e9f3a){var _0xc5b85b={},_0x5331cf={},_0x41b512={'count':0x0,'rows':[]};var _0x4ecb7a=_['map'](db[_0x0021('0x2f')][_0x0021('0x30')],function(_0x3e867b){return{'name':_0x3e867b[_0x0021('0x31')],'type':_0x3e867b[_0x0021('0x32')][_0x0021('0x33')]};});_0x5331cf[_0x0021('0x34')]=_[_0x0021('0x35')](_0x4ecb7a,_0x0021('0x2c'));_0x5331cf[_0x0021('0x36')]=_[_0x0021('0x37')](_0x27a43a[_0x0021('0x36')]);_0x5331cf['filters']=_[_0x0021('0x38')](_0x5331cf[_0x0021('0x34')],_0x5331cf[_0x0021('0x36')]);_0xc5b85b[_0x0021('0x39')]=_['intersection'](_0x5331cf[_0x0021('0x34')],qs[_0x0021('0x3a')](_0x27a43a[_0x0021('0x36')]['fields']));_0xc5b85b['attributes']=_0xc5b85b[_0x0021('0x39')][_0x0021('0x3b')]?_0xc5b85b[_0x0021('0x39')]:_0x5331cf[_0x0021('0x34')];if(!_0x27a43a['query'][_0x0021('0x3c')](_0x0021('0x3d'))){_0xc5b85b[_0x0021('0x1d')]=qs[_0x0021('0x1d')](_0x27a43a['query'][_0x0021('0x1d')]);_0xc5b85b[_0x0021('0x1b')]=qs[_0x0021('0x1b')](_0x27a43a[_0x0021('0x36')][_0x0021('0x1b')]);}_0xc5b85b[_0x0021('0x3e')]=qs['sort'](_0x27a43a[_0x0021('0x36')][_0x0021('0x3f')]);_0xc5b85b[_0x0021('0x40')]=qs['filters'](_[_0x0021('0x41')](_0x27a43a['query'],_0x5331cf[_0x0021('0x42')]),_0x4ecb7a);if(_0x27a43a[_0x0021('0x36')][_0x0021('0x43')]){_0xc5b85b[_0x0021('0x40')]=_[_0x0021('0x44')](_0xc5b85b['where'],{'$or':_['map'](_0x4ecb7a,function(_0x53e756){if(_0x53e756['type']!==_0x0021('0x45')){var _0x897bc={};_0x897bc[_0x53e756['name']]={'$like':'%'+_0x27a43a['query'][_0x0021('0x43')]+'%'};return _0x897bc;}})});}_0xc5b85b=_[_0x0021('0x44')]({},_0xc5b85b,_0x27a43a[_0x0021('0x46')]);var _0xf22674={'where':_0xc5b85b[_0x0021('0x40')]};return db[_0x0021('0x2f')][_0x0021('0x1e')](_0xf22674)['then'](function(_0x38a844){_0x41b512[_0x0021('0x1e')]=_0x38a844;if(_0x27a43a[_0x0021('0x36')][_0x0021('0x47')]){_0xc5b85b['include']=[{'all':!![]}];}return db[_0x0021('0x2f')]['findAll'](_0xc5b85b);})[_0x0021('0x26')](function(_0x31b2a2){_0x41b512['rows']=_0x31b2a2;return _0x41b512;})[_0x0021('0x26')](respondWithFilteredResult(_0x1e9f3a,_0xc5b85b))[_0x0021('0x48')](handleError(_0x1e9f3a,null));};exports[_0x0021('0x49')]=function(_0x4e75e4,_0x5b2811){var _0x83e1e7={'raw':!![],'where':{'id':_0x4e75e4[_0x0021('0x4a')]['id']}},_0x3195f9={};_0x3195f9[_0x0021('0x34')]=_[_0x0021('0x37')](db[_0x0021('0x2f')]['rawAttributes']);_0x3195f9[_0x0021('0x36')]=_[_0x0021('0x37')](_0x4e75e4[_0x0021('0x36')]);_0x3195f9[_0x0021('0x42')]=_[_0x0021('0x38')](_0x3195f9[_0x0021('0x34')],_0x3195f9['query']);_0x83e1e7['attributes']=_[_0x0021('0x38')](_0x3195f9[_0x0021('0x34')],qs[_0x0021('0x3a')](_0x4e75e4[_0x0021('0x36')][_0x0021('0x3a')]));_0x83e1e7[_0x0021('0x39')]=_0x83e1e7['attributes'][_0x0021('0x3b')]?_0x83e1e7[_0x0021('0x39')]:_0x3195f9[_0x0021('0x34')];if(_0x4e75e4[_0x0021('0x36')][_0x0021('0x47')]){_0x83e1e7[_0x0021('0x4b')]=[{'all':!![]}];}_0x83e1e7=_['merge']({},_0x83e1e7,_0x4e75e4[_0x0021('0x46')]);return db[_0x0021('0x2f')]['find'](_0x83e1e7)[_0x0021('0x26')](handleEntityNotFound(_0x5b2811,null))[_0x0021('0x26')](respondWithResult(_0x5b2811,null))['catch'](handleError(_0x5b2811,null));};exports[_0x0021('0x4c')]=function(_0x2808f9,_0x378fd9){return db[_0x0021('0x2f')][_0x0021('0x4c')](_0x2808f9[_0x0021('0x4d')],{})['then'](function(_0x4ad1f2){var _0x3194f9=_0x2808f9[_0x0021('0x4e')][_0x0021('0x28')]({'plain':!![]});if(!_0x3194f9)throw new Error(_0x0021('0x4f'));if(_0x3194f9[_0x0021('0x50')]===_0x0021('0x4e')){var _0x5712e7=_0x4ad1f2[_0x0021('0x28')]({'plain':!![]});var _0xd7d20c=_0x0021('0x29');return db[_0x0021('0x51')]['find']({'where':{'name':_0xd7d20c,'userProfileId':_0x3194f9[_0x0021('0x52')]},'raw':!![]})[_0x0021('0x26')](function(_0x301288){if(_0x301288&&_0x301288['autoAssociation']===0x0){return db[_0x0021('0x2a')][_0x0021('0x4c')]({'name':_0x5712e7[_0x0021('0x2c')],'resourceId':_0x5712e7['id'],'type':_0x301288[_0x0021('0x2c')],'sectionId':_0x301288['id']},{})[_0x0021('0x26')](function(){return _0x4ad1f2;});}else{return _0x4ad1f2;}})[_0x0021('0x48')](function(_0x49446d){logger['error'](_0x0021('0x53'),_0x49446d);throw _0x49446d;});}return _0x4ad1f2;})[_0x0021('0x26')](respondWithResult(_0x378fd9,0xc9))['catch'](handleError(_0x378fd9,null));};exports['update']=function(_0xf16ecc,_0x53576){if(_0xf16ecc['body']['id']){delete _0xf16ecc[_0x0021('0x4d')]['id'];}return db['Interval'][_0x0021('0x54')]({'where':{'id':_0xf16ecc[_0x0021('0x4a')]['id']}})[_0x0021('0x26')](handleEntityNotFound(_0x53576,null))[_0x0021('0x26')](saveUpdates(_0xf16ecc[_0x0021('0x4d')],null))[_0x0021('0x26')](respondWithResult(_0x53576,null))[_0x0021('0x48')](handleError(_0x53576,null));};exports[_0x0021('0x27')]=function(_0x52f69,_0x50c9f5){return db[_0x0021('0x2f')][_0x0021('0x54')]({'where':{'id':_0x52f69[_0x0021('0x4a')]['id']}})[_0x0021('0x26')](handleEntityNotFound(_0x50c9f5,null))['then'](removeEntity(_0x50c9f5,null))['catch'](handleError(_0x50c9f5,null));};exports[_0x0021('0x55')]=function(_0xa68178,_0x499fd1,_0x5ddf84){if(_0xa68178[_0x0021('0x4d')]['id']){delete _0xa68178['body']['id'];}return db[_0x0021('0x2f')][_0x0021('0x54')]({'where':{'id':_0xa68178[_0x0021('0x4a')]['id']}})['then'](handleEntityNotFound(_0x499fd1,null))[_0x0021('0x26')](function(_0x390f82){if(_0x390f82){_0xa68178[_0x0021('0x4d')][_0x0021('0x56')]=_0x390f82['id'];return db[_0x0021('0x2f')]['create'](_0xa68178[_0x0021('0x4d')]);}})[_0x0021('0x26')](respondWithResult(_0x499fd1,null))[_0x0021('0x48')](handleError(_0x499fd1,null));};exports[_0x0021('0x57')]=function(_0x51302c,_0x1dc48c,_0x5ef3b6){var _0xc03f1e={};var _0x145bb0={};var _0xb536e8;var _0x505951;return db[_0x0021('0x2f')]['findOne']({'where':{'id':_0x51302c[_0x0021('0x4a')]['id']}})[_0x0021('0x26')](handleEntityNotFound(_0x1dc48c,null))[_0x0021('0x26')](function(_0x5ec1b4){if(_0x5ec1b4){_0xb536e8=_0x5ec1b4;_0x145bb0[_0x0021('0x34')]=_[_0x0021('0x37')](db[_0x0021('0x2f')]['rawAttributes']);_0x145bb0[_0x0021('0x36')]=_[_0x0021('0x37')](_0x51302c[_0x0021('0x36')]);_0x145bb0[_0x0021('0x42')]=_[_0x0021('0x38')](_0x145bb0[_0x0021('0x34')],_0x145bb0['query']);_0xc03f1e[_0x0021('0x39')]=_[_0x0021('0x38')](_0x145bb0[_0x0021('0x34')],qs[_0x0021('0x3a')](_0x51302c['query'][_0x0021('0x3a')]));_0xc03f1e['attributes']=_0xc03f1e[_0x0021('0x39')][_0x0021('0x3b')]?_0xc03f1e[_0x0021('0x39')]:_0x145bb0[_0x0021('0x34')];_0xc03f1e[_0x0021('0x3e')]=qs[_0x0021('0x3f')](_0x51302c[_0x0021('0x36')][_0x0021('0x3f')]);_0xc03f1e['where']=qs['filters'](_[_0x0021('0x41')](_0x51302c[_0x0021('0x36')],_0x145bb0['filters']));if(_0x51302c['query'][_0x0021('0x43')]){_0xc03f1e[_0x0021('0x40')]=_[_0x0021('0x44')](_0xc03f1e[_0x0021('0x40')],{'$or':_[_0x0021('0x35')](_0xc03f1e['attributes'],function(_0x29c505){var _0x2c14e3={};_0x2c14e3[_0x29c505]={'$like':'%'+_0x51302c[_0x0021('0x36')][_0x0021('0x43')]+'%'};return _0x2c14e3;})});}_0xc03f1e=_[_0x0021('0x44')]({},_0xc03f1e,_0x51302c['options']);return _0xb536e8[_0x0021('0x57')](_0xc03f1e);}})[_0x0021('0x26')](function(_0x1059a5){if(_0x1059a5){_0x505951=_0x1059a5[_0x0021('0x3b')];if(!_0x51302c[_0x0021('0x36')]['hasOwnProperty'](_0x0021('0x3d'))){_0xc03f1e[_0x0021('0x1d')]=qs[_0x0021('0x1d')](_0x51302c[_0x0021('0x36')][_0x0021('0x1d')]);_0xc03f1e[_0x0021('0x1b')]=qs['offset'](_0x51302c[_0x0021('0x36')][_0x0021('0x1b')]);}return _0xb536e8['getIntervals'](_0xc03f1e);}})['then'](function(_0x26b3da){if(_0x26b3da){return _0x26b3da?{'count':_0x505951,'rows':_0x26b3da}:null;}})[_0x0021('0x26')](respondWithResult(_0x1dc48c,null))[_0x0021('0x48')](handleError(_0x1dc48c,null));};exports[_0x0021('0x58')]=function(_0x269eb1,_0x1380d6,_0x51f176){return db[_0x0021('0x2f')][_0x0021('0x59')]({'where':{'id':_0x269eb1[_0x0021('0x4a')]['id']}})['then'](handleEntityNotFound(_0x1380d6,null))['then'](function(_0x353e52){if(_0x353e52){return db[_0x0021('0x5a')]['transaction'](function(_0x104e80){return db[_0x0021('0x2f')][_0x0021('0x27')]({'where':{'IntervalId':_0x269eb1[_0x0021('0x4a')]['id']},'transaction':_0x104e80})[_0x0021('0x26')](function(_0x5d216f){var _0x38fccd=_['map'](_0x269eb1[_0x0021('0x4d')],function(_0x46d6c5){delete _0x46d6c5['id'];_0x46d6c5[_0x0021('0x56')]=_0x269eb1[_0x0021('0x4a')]['id'];return _0x46d6c5;});return db[_0x0021('0x2f')]['bulkCreate'](_0x38fccd,{'transaction':_0x104e80});});})[_0x0021('0x26')](function(){return db[_0x0021('0x2f')][_0x0021('0x5b')]({'where':{'IntervalId':_0x269eb1[_0x0021('0x4a')]['id']}});});}})[_0x0021('0x26')](respondWithResult(_0x1380d6,null))['catch'](handleError(_0x1380d6,null));};
\ No newline at end of file