cb51e77e99c5a17f7d76b83332a1b6874e152927
[motion-next.git] / server / api / cloudProvider / cloudProvider.controller.js
1 const a118_0x3491=['set','sendStatus','rows','where','json','options','keys','findAll','rawAttributes','../../mysqldb','fieldName','nolimit','count','show','undefined','pick','sequelize','model','name','attributes','update','../../components/parsers/qs','offset','status','length','type','api','../../config/logger','stack','filter','body','sort','catch','destroy','filters','CloudProvider','params','end','limit','merge','fields','create','Content-Range','send','findOne','index','intersection','then','query','includeAll','map','include','like'];(function(_0x21a2c6,_0x3491b0){const _0x81ed4e=function(_0xa93e2c){while(--_0xa93e2c){_0x21a2c6['push'](_0x21a2c6['shift']());}};_0x81ed4e(++_0x3491b0);}(a118_0x3491,0x1a3));const a118_0x81ed=function(_0x21a2c6,_0x3491b0){_0x21a2c6=_0x21a2c6-0x0;let _0x81ed4e=a118_0x3491[_0x21a2c6];return _0x81ed4e;};const _0x2691e6=a118_0x81ed;'use strict';const _=require('lodash'),qs=require(_0x2691e6('0x1a')),logger=require(_0x2691e6('0x20'))(_0x2691e6('0x1f')),db=require(_0x2691e6('0xe'))['db'],{Op}=require(_0x2691e6('0x15'));function respondWithResult(_0xa93e2c,_0x3906e1){return _0x3906e1=_0x3906e1||0xc8,function(_0x35a22e){const _0x209260=a118_0x81ed;if(_0x35a22e)return _0xa93e2c['status'](_0x3906e1)[_0x209260('0x9')](_0x35a22e);};}function respondWithFilteredResult(_0x5d3f2e,_0x3bd772){return function(_0x531dde){const _0x1df06c=a118_0x81ed;if(_0x531dde){const _0x149699=_0x531dde[_0x1df06c('0x11')],_0xa44adc=_0x3bd772[_0x1df06c('0x1b')];let _0x4f19cd=_0x3bd772['offset']+_0x3bd772[_0x1df06c('0x2b')],_0x5be82a;return _0x4f19cd>=_0x149699?(_0x4f19cd=_0x149699,_0x5be82a=0xc8):_0x5be82a=0xce,_0x5d3f2e[_0x1df06c('0x1c')](_0x5be82a),_0x5d3f2e[_0x1df06c('0x5')](_0x1df06c('0x2f'),_0xa44adc+'-'+_0x4f19cd+'/'+_0x149699)[_0x1df06c('0x9')](_0x531dde);}return null;};}function saveUpdates(_0x1970d7){return function(_0x443b80){const _0x485623=a118_0x81ed;if(_0x443b80)return _0x443b80[_0x485623('0x19')](_0x1970d7)[_0x485623('0x34')](function(_0x8a04e6){return _0x8a04e6;});return null;};}function removeEntity(_0x2b819d){return function(_0x372371){const _0x4e258d=a118_0x81ed;if(_0x372371)return _0x372371[_0x4e258d('0x26')]()[_0x4e258d('0x34')](function(){const _0x44473a=_0x4e258d;_0x2b819d['status'](0xcc)[_0x44473a('0x2a')]();});};}function handleEntityNotFound(_0x31167c){return function(_0x3520ab){const _0x1bd21a=a118_0x81ed;return!_0x3520ab&&_0x31167c[_0x1bd21a('0x6')](0x194),_0x3520ab;};}function handleError(_0x14a608,_0x13f6eb){return _0x13f6eb=_0x13f6eb||0x1f4,function(_0x55f13d){const _0x2c284a=a118_0x81ed;logger['error'](_0x55f13d[_0x2c284a('0x21')]),_0x55f13d['name']&&delete _0x55f13d[_0x2c284a('0x17')],_0x14a608[_0x2c284a('0x1c')](_0x13f6eb)[_0x2c284a('0x30')](_0x55f13d);};}exports[_0x2691e6('0x32')]=function(_0x70637,_0x110190){const _0x1eb7f1=_0x2691e6;let _0x13d413={};const _0x84f9df={},_0x5c709b={'count':0x0,'rows':[]},_0x58951b=_[_0x1eb7f1('0x2')](db[_0x1eb7f1('0x28')][_0x1eb7f1('0xd')],function(_0x5d2990){const _0x3cc8db=_0x1eb7f1;return{'name':_0x5d2990[_0x3cc8db('0xf')],'type':_0x5d2990[_0x3cc8db('0x1e')]['key']};});_0x84f9df['model']=_[_0x1eb7f1('0x2')](_0x58951b,_0x1eb7f1('0x17')),_0x84f9df[_0x1eb7f1('0x0')]=_['keys'](_0x70637[_0x1eb7f1('0x0')]),_0x84f9df['filters']=_[_0x1eb7f1('0x33')](_0x84f9df['model'],_0x84f9df[_0x1eb7f1('0x0')]),_0x13d413['attributes']=_['intersection'](_0x84f9df[_0x1eb7f1('0x16')],qs[_0x1eb7f1('0x2d')](_0x70637[_0x1eb7f1('0x0')][_0x1eb7f1('0x2d')])),_0x13d413[_0x1eb7f1('0x18')]=_0x13d413[_0x1eb7f1('0x18')][_0x1eb7f1('0x1d')]?_0x13d413[_0x1eb7f1('0x18')]:_0x84f9df[_0x1eb7f1('0x16')];typeof _0x70637['query'][_0x1eb7f1('0x10')]===_0x1eb7f1('0x13')&&(_0x13d413['limit']=qs[_0x1eb7f1('0x2b')](_0x70637[_0x1eb7f1('0x0')][_0x1eb7f1('0x2b')]),_0x13d413[_0x1eb7f1('0x1b')]=qs[_0x1eb7f1('0x1b')](_0x70637[_0x1eb7f1('0x0')]['offset']));_0x13d413['order']=qs[_0x1eb7f1('0x24')](_0x70637[_0x1eb7f1('0x0')][_0x1eb7f1('0x24')]),_0x13d413[_0x1eb7f1('0x8')]=qs[_0x1eb7f1('0x27')](_[_0x1eb7f1('0x14')](_0x70637[_0x1eb7f1('0x0')],_0x84f9df[_0x1eb7f1('0x27')]),_0x58951b);_0x70637[_0x1eb7f1('0x0')][_0x1eb7f1('0x22')]&&(_0x13d413[_0x1eb7f1('0x8')]=_[_0x1eb7f1('0x2c')](_0x13d413[_0x1eb7f1('0x8')],{[Op['or']]:_[_0x1eb7f1('0x2')](_0x58951b,function(_0x30ddd6){const _0x585d27=_0x1eb7f1;if(_0x30ddd6[_0x585d27('0x1e')]!=='VIRTUAL'){const _0x5af522={};return _0x5af522[_0x30ddd6[_0x585d27('0x17')]]={[Op[_0x585d27('0x4')]]:'%'+_0x70637[_0x585d27('0x0')][_0x585d27('0x22')]+'%'},_0x5af522;}})}));_0x13d413=_[_0x1eb7f1('0x2c')]({},_0x13d413,_0x70637[_0x1eb7f1('0xa')]);const _0x1184a4={'where':_0x13d413[_0x1eb7f1('0x8')]};return db[_0x1eb7f1('0x28')][_0x1eb7f1('0x11')](_0x1184a4)[_0x1eb7f1('0x34')](function(_0x39a46a){const _0x23329d=_0x1eb7f1;return _0x5c709b['count']=_0x39a46a,_0x70637[_0x23329d('0x0')][_0x23329d('0x1')]&&(_0x13d413['include']=[{'all':!![]}]),db['CloudProvider'][_0x23329d('0xc')](_0x13d413);})[_0x1eb7f1('0x34')](function(_0x404375){const _0x108bbc=_0x1eb7f1;return _0x5c709b[_0x108bbc('0x7')]=_0x404375,_0x5c709b;})['then'](respondWithFilteredResult(_0x110190,_0x13d413))[_0x1eb7f1('0x25')](handleError(_0x110190,null));},exports[_0x2691e6('0x12')]=function(_0x2ad789,_0x431c93){const _0x2d20fc=_0x2691e6;let _0x17c83e={'raw':!![],'where':{'id':_0x2ad789['params']['id']}};const _0x453835={};return _0x453835[_0x2d20fc('0x16')]=_[_0x2d20fc('0xb')](db[_0x2d20fc('0x28')][_0x2d20fc('0xd')]),_0x453835[_0x2d20fc('0x0')]=_[_0x2d20fc('0xb')](_0x2ad789['query']),_0x453835[_0x2d20fc('0x27')]=_[_0x2d20fc('0x33')](_0x453835[_0x2d20fc('0x16')],_0x453835[_0x2d20fc('0x0')]),_0x17c83e[_0x2d20fc('0x18')]=_[_0x2d20fc('0x33')](_0x453835['model'],qs[_0x2d20fc('0x2d')](_0x2ad789[_0x2d20fc('0x0')][_0x2d20fc('0x2d')])),_0x17c83e[_0x2d20fc('0x18')]=_0x17c83e[_0x2d20fc('0x18')][_0x2d20fc('0x1d')]?_0x17c83e[_0x2d20fc('0x18')]:_0x453835[_0x2d20fc('0x16')],_0x2ad789['query']['includeAll']&&(_0x17c83e[_0x2d20fc('0x3')]=[{'all':!![]}]),_0x17c83e=_['merge']({},_0x17c83e,_0x2ad789[_0x2d20fc('0xa')]),db[_0x2d20fc('0x28')][_0x2d20fc('0x31')](_0x17c83e)[_0x2d20fc('0x34')](handleEntityNotFound(_0x431c93,null))['then'](respondWithResult(_0x431c93,null))['catch'](handleError(_0x431c93,null));},exports[_0x2691e6('0x2e')]=function(_0x5a1d9c,_0x14f009){const _0x47278c=_0x2691e6;return db[_0x47278c('0x28')][_0x47278c('0x2e')](_0x5a1d9c[_0x47278c('0x23')],{})[_0x47278c('0x34')](respondWithResult(_0x14f009,0xc9))[_0x47278c('0x25')](handleError(_0x14f009,null));},exports[_0x2691e6('0x19')]=function(_0x28bdac,_0x50346a){const _0x58c701=_0x2691e6;return _0x28bdac[_0x58c701('0x23')]['id']&&delete _0x28bdac[_0x58c701('0x23')]['id'],db[_0x58c701('0x28')][_0x58c701('0x31')]({'where':{'id':_0x28bdac[_0x58c701('0x29')]['id']}})[_0x58c701('0x34')](handleEntityNotFound(_0x50346a,null))[_0x58c701('0x34')](saveUpdates(_0x28bdac[_0x58c701('0x23')],null))[_0x58c701('0x34')](respondWithResult(_0x50346a,null))['catch'](handleError(_0x50346a,null));},exports[_0x2691e6('0x26')]=function(_0x78932b,_0x5515ac){const _0x570aaa=_0x2691e6;return db[_0x570aaa('0x28')]['findOne']({'where':{'id':_0x78932b[_0x570aaa('0x29')]['id']}})[_0x570aaa('0x34')](handleEntityNotFound(_0x5515ac,null))[_0x570aaa('0x34')](removeEntity(_0x5515ac,null))[_0x570aaa('0x25')](handleError(_0x5515ac,null));};