8cb1da8b7aee874ba8dd5e92a8ed278810b73c10
[motion-next.git] / server / api / schedule / schedule.controller.js
1 const a530_0x34f8=['keys','error','include','json','limit','rawAttributes','like','run','query','attributes','../../config/logger','where','userProfileId','options','send','order','UserProfileResource','sendStatus','name','Scheduler','body','Schedule','role','catch','Content-Range','../../config/schedule','nolimit','count','filter','api','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','status','user','offset','params','end','length','../../mysqldb','index','type','then','get','intersection','sort','findOne','create','rows','map','merge','destroy','model','Unable\x20to\x20retrieve\x20the\x20current\x20user','../../components/parsers/qs','lodash','filters','findAll','key','fields','update'];(function(_0x2bbcee,_0x34f88e){const _0x17c4c4=function(_0x2d8aa9){while(--_0x2d8aa9){_0x2bbcee['push'](_0x2bbcee['shift']());}};_0x17c4c4(++_0x34f88e);}(a530_0x34f8,0x1ae));const a530_0x17c4=function(_0x2bbcee,_0x34f88e){_0x2bbcee=_0x2bbcee-0x0;let _0x17c4c4=a530_0x34f8[_0x2bbcee];return _0x17c4c4;};const _0x45aca9=a530_0x17c4;'use strict';const _=require(_0x45aca9('0x24')),qs=require(_0x45aca9('0x23')),logger=require(_0x45aca9('0x34'))(_0x45aca9('0xc')),db=require(_0x45aca9('0x14'))['db'],{Op}=require('sequelize');function respondWithStatusCode(_0x2d8aa9,_0x21dd39){return _0x21dd39=_0x21dd39||0xcc,function(_0x3564cc){const _0x1cc0b2=a530_0x17c4;if(_0x3564cc)return _0x2d8aa9[_0x1cc0b2('0x0')](_0x21dd39);return _0x2d8aa9[_0x1cc0b2('0xe')](_0x21dd39)[_0x1cc0b2('0x12')]();};}function respondWithResult(_0x448f77,_0x981eea){return _0x981eea=_0x981eea||0xc8,function(_0x4a03ec){const _0x5be461=a530_0x17c4;if(_0x4a03ec)return _0x448f77[_0x5be461('0xe')](_0x981eea)[_0x5be461('0x2d')](_0x4a03ec);};}function respondWithFilteredResult(_0x184d92,_0x1dcb34){return function(_0x4f3ba0){const _0x396fe8=a530_0x17c4;if(_0x4f3ba0){const _0x2273dc=_0x4f3ba0['count'],_0x59ee0a=_0x1dcb34[_0x396fe8('0x10')];let _0x2393d6=_0x1dcb34[_0x396fe8('0x10')]+_0x1dcb34[_0x396fe8('0x2e')],_0x35e6ce;return _0x2393d6>=_0x2273dc?(_0x2393d6=_0x2273dc,_0x35e6ce=0xc8):_0x35e6ce=0xce,_0x184d92[_0x396fe8('0xe')](_0x35e6ce),_0x184d92['set'](_0x396fe8('0x7'),_0x59ee0a+'-'+_0x2393d6+'/'+_0x2273dc)[_0x396fe8('0x2d')](_0x4f3ba0);}return null;};}function saveUpdates(_0x449607){return function(_0x1b54ef){const _0x3b6fcc=a530_0x17c4;if(_0x1b54ef)return _0x1b54ef[_0x3b6fcc('0x29')](_0x449607)[_0x3b6fcc('0x17')](function(_0x208c5c){return _0x208c5c;});return null;};}function removeEntity(_0xfde3e8){return function(_0x170179){const _0x4368d4=a530_0x17c4;if(_0x170179)return _0x170179[_0x4368d4('0x20')]()[_0x4368d4('0x17')](function(){const _0x4d622a=_0x4368d4,_0x2c3938=_0x170179[_0x4d622a('0x18')]({'plain':!![]}),_0xd071f4=_0x4d622a('0x2');return db[_0x4d622a('0x3a')]['destroy']({'where':{'type':_0xd071f4,'resourceId':_0x2c3938['id']}})['then'](function(){return _0x170179;});})['then'](function(){const _0x1457f8=_0x4368d4;_0xfde3e8['status'](0xcc)[_0x1457f8('0x12')]();});};}function handleEntityNotFound(_0x46b3df){return function(_0x1616e6){const _0x34a64b=a530_0x17c4;return!_0x1616e6&&_0x46b3df[_0x34a64b('0x0')](0x194),_0x1616e6;};}function handleError(_0x1a53af,_0x237122){return _0x237122=_0x237122||0x1f4,function(_0x48607d){const _0x2ab2f6=a530_0x17c4;logger['error'](_0x48607d['stack']),_0x48607d[_0x2ab2f6('0x1')]&&delete _0x48607d[_0x2ab2f6('0x1')],_0x1a53af[_0x2ab2f6('0xe')](_0x237122)[_0x2ab2f6('0x38')](_0x48607d);};}exports[_0x45aca9('0x15')]=function(_0x1c7f86,_0x24e880){const _0x4f6ec8=_0x45aca9;let _0x5098eb={};const _0x53cfe3={},_0x6e1bd7={'count':0x0,'rows':[]},_0x105889=_[_0x4f6ec8('0x1e')](db[_0x4f6ec8('0x4')][_0x4f6ec8('0x2f')],function(_0x5dac1b){const _0x49b069=_0x4f6ec8;return{'name':_0x5dac1b['fieldName'],'type':_0x5dac1b[_0x49b069('0x16')][_0x49b069('0x27')]};});_0x53cfe3['model']=_['map'](_0x105889,'name'),_0x53cfe3[_0x4f6ec8('0x32')]=_[_0x4f6ec8('0x2a')](_0x1c7f86[_0x4f6ec8('0x32')]),_0x53cfe3[_0x4f6ec8('0x25')]=_[_0x4f6ec8('0x19')](_0x53cfe3[_0x4f6ec8('0x21')],_0x53cfe3[_0x4f6ec8('0x32')]),_0x5098eb[_0x4f6ec8('0x33')]=_[_0x4f6ec8('0x19')](_0x53cfe3[_0x4f6ec8('0x21')],qs[_0x4f6ec8('0x28')](_0x1c7f86[_0x4f6ec8('0x32')][_0x4f6ec8('0x28')])),_0x5098eb[_0x4f6ec8('0x33')]=_0x5098eb[_0x4f6ec8('0x33')][_0x4f6ec8('0x13')]?_0x5098eb[_0x4f6ec8('0x33')]:_0x53cfe3[_0x4f6ec8('0x21')];typeof _0x1c7f86['query'][_0x4f6ec8('0x9')]==='undefined'&&(_0x5098eb[_0x4f6ec8('0x2e')]=qs[_0x4f6ec8('0x2e')](_0x1c7f86[_0x4f6ec8('0x32')][_0x4f6ec8('0x2e')]),_0x5098eb[_0x4f6ec8('0x10')]=qs[_0x4f6ec8('0x10')](_0x1c7f86[_0x4f6ec8('0x32')][_0x4f6ec8('0x10')]));_0x5098eb[_0x4f6ec8('0x39')]=qs['sort'](_0x1c7f86[_0x4f6ec8('0x32')][_0x4f6ec8('0x1a')]),_0x5098eb['where']=qs[_0x4f6ec8('0x25')](_['pick'](_0x1c7f86[_0x4f6ec8('0x32')],_0x53cfe3['filters']),_0x105889);_0x1c7f86[_0x4f6ec8('0x32')][_0x4f6ec8('0xb')]&&(_0x5098eb['where']=_[_0x4f6ec8('0x1f')](_0x5098eb[_0x4f6ec8('0x35')],{[Op['or']]:_['map'](_0x105889,function(_0x409add){const _0x46caea=_0x4f6ec8;if(_0x409add[_0x46caea('0x16')]!=='VIRTUAL'){const _0x1bb649={};return _0x1bb649[_0x409add['name']]={[Op[_0x46caea('0x30')]]:'%'+_0x1c7f86['query']['filter']+'%'},_0x1bb649;}})}));_0x5098eb=_[_0x4f6ec8('0x1f')]({},_0x5098eb,_0x1c7f86['options']);const _0x549b28={'where':_0x5098eb['where']};return db[_0x4f6ec8('0x4')][_0x4f6ec8('0xa')](_0x549b28)[_0x4f6ec8('0x17')](function(_0x22d137){const _0x40703c=_0x4f6ec8;return _0x6e1bd7[_0x40703c('0xa')]=_0x22d137,_0x1c7f86['query']['includeAll']&&(_0x5098eb[_0x40703c('0x2c')]=[{'all':!![]}]),db[_0x40703c('0x4')][_0x40703c('0x26')](_0x5098eb);})[_0x4f6ec8('0x17')](function(_0x36e25d){const _0x2ddc3f=_0x4f6ec8;return _0x6e1bd7[_0x2ddc3f('0x1d')]=_0x36e25d,_0x6e1bd7;})[_0x4f6ec8('0x17')](respondWithFilteredResult(_0x24e880,_0x5098eb))[_0x4f6ec8('0x6')](handleError(_0x24e880,null));},exports['show']=function(_0x50cedd,_0xbdf9fc){const _0x1d2e09=_0x45aca9;let _0x291b43={'raw':![],'where':{'id':_0x50cedd[_0x1d2e09('0x11')]['id']}};const _0x5a0301={};return _0x5a0301[_0x1d2e09('0x21')]=_[_0x1d2e09('0x2a')](db[_0x1d2e09('0x4')][_0x1d2e09('0x2f')]),_0x5a0301[_0x1d2e09('0x32')]=_['keys'](_0x50cedd[_0x1d2e09('0x32')]),_0x5a0301[_0x1d2e09('0x25')]=_[_0x1d2e09('0x19')](_0x5a0301[_0x1d2e09('0x21')],_0x5a0301[_0x1d2e09('0x32')]),_0x291b43['attributes']=_[_0x1d2e09('0x19')](_0x5a0301[_0x1d2e09('0x21')],qs[_0x1d2e09('0x28')](_0x50cedd[_0x1d2e09('0x32')][_0x1d2e09('0x28')])),_0x291b43['attributes']=_0x291b43[_0x1d2e09('0x33')][_0x1d2e09('0x13')]?_0x291b43[_0x1d2e09('0x33')]:_0x5a0301[_0x1d2e09('0x21')],_0x50cedd[_0x1d2e09('0x32')]['includeAll']&&(_0x291b43[_0x1d2e09('0x2c')]=[{'all':!![]}]),_0x291b43=_['merge']({},_0x291b43,_0x50cedd[_0x1d2e09('0x37')]),db[_0x1d2e09('0x4')][_0x1d2e09('0x1b')](_0x291b43)[_0x1d2e09('0x17')](handleEntityNotFound(_0xbdf9fc,null))[_0x1d2e09('0x17')](respondWithResult(_0xbdf9fc,null))[_0x1d2e09('0x6')](handleError(_0xbdf9fc,null));},exports['create']=function(_0x3ad008,_0xbe1195){const _0x29b2fa=_0x45aca9;return db[_0x29b2fa('0x4')][_0x29b2fa('0x1c')](_0x3ad008[_0x29b2fa('0x3')],{})[_0x29b2fa('0x17')](function(_0x22c1bf){const _0x214a72=_0x29b2fa,_0x266e00=_0x3ad008['user'][_0x214a72('0x18')]({'plain':!![]});if(!_0x266e00)throw new Error(_0x214a72('0x22'));if(_0x266e00[_0x214a72('0x5')]===_0x214a72('0xf')){const _0x83dd60=_0x22c1bf[_0x214a72('0x18')]({'plain':!![]}),_0x3595ec=_0x214a72('0x2');return db['UserProfileSection'][_0x214a72('0x1b')]({'where':{'name':_0x3595ec,'userProfileId':_0x266e00[_0x214a72('0x36')]},'raw':!![]})[_0x214a72('0x17')](function(_0x27ed01){const _0x166352=_0x214a72;return _0x27ed01&&_0x27ed01['autoAssociation']===0x0?db['UserProfileResource'][_0x166352('0x1c')]({'name':_0x83dd60[_0x166352('0x1')],'resourceId':_0x83dd60['id'],'type':_0x27ed01[_0x166352('0x1')],'sectionId':_0x27ed01['id']},{})['then'](function(){return _0x22c1bf;}):_0x22c1bf;})[_0x214a72('0x6')](function(_0x4937f5){const _0x11c643=_0x214a72;logger[_0x11c643('0x2b')](_0x11c643('0xd'),_0x4937f5);throw _0x4937f5;});}return _0x22c1bf;})[_0x29b2fa('0x17')](respondWithResult(_0xbe1195,0xc9))[_0x29b2fa('0x6')](handleError(_0xbe1195,null));},exports['update']=function(_0x20def4,_0x36430e){const _0x3598c9=_0x45aca9;return _0x20def4['body']['id']&&delete _0x20def4[_0x3598c9('0x3')]['id'],db['Schedule'][_0x3598c9('0x1b')]({'where':{'id':_0x20def4[_0x3598c9('0x11')]['id']}})[_0x3598c9('0x17')](handleEntityNotFound(_0x36430e,null))[_0x3598c9('0x17')](saveUpdates(_0x20def4['body'],null))['then'](respondWithResult(_0x36430e,null))[_0x3598c9('0x6')](handleError(_0x36430e,null));},exports['destroy']=function(_0x26898c,_0x128170){const _0x32d9b5=_0x45aca9;return db[_0x32d9b5('0x4')]['findOne']({'where':{'id':_0x26898c[_0x32d9b5('0x11')]['id']}})[_0x32d9b5('0x17')](handleEntityNotFound(_0x128170,null))[_0x32d9b5('0x17')](removeEntity(_0x128170,null))['catch'](handleError(_0x128170,null));},exports[_0x45aca9('0x31')]=function(_0x4e86d2,_0x1d2bc5){const _0x2c9fca=_0x45aca9,_0x3bbff9=require(_0x2c9fca('0x8'));return db[_0x2c9fca('0x4')][_0x2c9fca('0x1b')]({'where':{'id':_0x4e86d2[_0x2c9fca('0x11')]['id']},'raw':!![]})['then'](handleEntityNotFound(_0x1d2bc5,null))[_0x2c9fca('0x17')](function(){const _0x27361d=_0x2c9fca;_0x3bbff9[_0x27361d('0x31')](_0x4e86d2[_0x27361d('0x11')]['id']);})[_0x2c9fca('0x17')](respondWithStatusCode(_0x1d2bc5,null))['catch'](handleError(_0x1d2bc5,null));};