Built motion from commit 459747fdfe53bbf13fbede61eeaffea1f1438f86. Version 3.0.0...
[motion-next.git] / server / api / squareReport / squareReport.controller.js
1 const a610_0x2385=['fields','params','catch','includeAll','query','nolimit','map','status','options','index','../../components/parsers/qs','type','model','rows','json','../../mysqldb','key','where','set','count','like','send','stack','VIRTUAL','findAll','include','limit','SquareReport','sendStatus','keys','intersection','show','length','fieldName','offset','../../config/logger','lodash','merge','filters','body','destroy','attributes','describe','error','then','undefined','findOne','filter','sequelize','sort','pick','name','create','Content-Range'];(function(_0x97acc6,_0x2385a2){const _0x23331a=function(_0x4746cb){while(--_0x4746cb){_0x97acc6['push'](_0x97acc6['shift']());}};_0x23331a(++_0x2385a2);}(a610_0x2385,0xb5));const a610_0x2333=function(_0x97acc6,_0x2385a2){_0x97acc6=_0x97acc6-0x0;let _0x23331a=a610_0x2385[_0x97acc6];return _0x23331a;};const _0x3fac27=a610_0x2333;'use strict';const _=require(_0x3fac27('0x11')),qs=require(_0x3fac27('0x2d')),logger=require(_0x3fac27('0x10'))('api'),db=require(_0x3fac27('0x32'))['db'],{Op}=require(_0x3fac27('0x1d'));function respondWithResult(_0x4746cb,_0x53c390){return _0x53c390=_0x53c390||0xc8,function(_0x51f0d2){const _0x234b7c=a610_0x2333;if(_0x51f0d2)return _0x4746cb[_0x234b7c('0x2a')](_0x53c390)['json'](_0x51f0d2);};}function respondWithFilteredResult(_0x35155c,_0x181e04){return function(_0x4c977f){const _0x4941f0=a610_0x2333;if(_0x4c977f){const _0x47d4b9=_0x4c977f[_0x4941f0('0x0')],_0x4a93cf=_0x181e04[_0x4941f0('0xf')];let _0x1b35f9=_0x181e04[_0x4941f0('0xf')]+_0x181e04[_0x4941f0('0x7')],_0x33759e;return _0x1b35f9>=_0x47d4b9?(_0x1b35f9=_0x47d4b9,_0x33759e=0xc8):_0x33759e=0xce,_0x35155c[_0x4941f0('0x2a')](_0x33759e),_0x35155c[_0x4941f0('0x35')](_0x4941f0('0x22'),_0x4a93cf+'-'+_0x1b35f9+'/'+_0x47d4b9)[_0x4941f0('0x31')](_0x4c977f);}return null;};}function saveUpdates(_0x41365b){return function(_0x558f7a){const _0x4ac3d9=a610_0x2333;if(_0x558f7a)return _0x558f7a['update'](_0x41365b)[_0x4ac3d9('0x19')](function(_0x5a7672){return _0x5a7672;});return null;};}function removeEntity(_0x25cdb3){return function(_0x394e32){const _0x5c868b=a610_0x2333;if(_0x394e32)return _0x394e32[_0x5c868b('0x15')]()[_0x5c868b('0x19')](function(){const _0x5cc450=_0x5c868b;_0x25cdb3[_0x5cc450('0x2a')](0xcc)['end']();});};}function handleEntityNotFound(_0x4e98ce){return function(_0x5969b7){const _0x2ec230=a610_0x2333;return!_0x5969b7&&_0x4e98ce[_0x2ec230('0x9')](0x194),_0x5969b7;};}function handleError(_0x31cf50,_0x16056d){return _0x16056d=_0x16056d||0x1f4,function(_0x359f8f){const _0x335d85=a610_0x2333;logger[_0x335d85('0x18')](_0x359f8f[_0x335d85('0x3')]),_0x359f8f[_0x335d85('0x20')]&&delete _0x359f8f[_0x335d85('0x20')],_0x31cf50[_0x335d85('0x2a')](_0x16056d)[_0x335d85('0x2')](_0x359f8f);};}exports[_0x3fac27('0x2c')]=function(_0x5c8b75,_0x1ae033){const _0x221af9=_0x3fac27;let _0x4707bf={};const _0x28a719={},_0x4efabc={'count':0x0,'rows':[]},_0x57b2ca=_[_0x221af9('0x29')](db[_0x221af9('0x8')]['rawAttributes'],function(_0x5cbc75){const _0x490edb=_0x221af9;return{'name':_0x5cbc75[_0x490edb('0xe')],'type':_0x5cbc75[_0x490edb('0x2e')][_0x490edb('0x33')]};});_0x28a719[_0x221af9('0x2f')]=_[_0x221af9('0x29')](_0x57b2ca,_0x221af9('0x20')),_0x28a719['query']=_[_0x221af9('0xa')](_0x5c8b75[_0x221af9('0x27')]),_0x28a719[_0x221af9('0x13')]=_[_0x221af9('0xb')](_0x28a719['model'],_0x28a719[_0x221af9('0x27')]),_0x4707bf[_0x221af9('0x16')]=_[_0x221af9('0xb')](_0x28a719[_0x221af9('0x2f')],qs[_0x221af9('0x23')](_0x5c8b75[_0x221af9('0x27')]['fields'])),_0x4707bf[_0x221af9('0x16')]=_0x4707bf[_0x221af9('0x16')][_0x221af9('0xd')]?_0x4707bf[_0x221af9('0x16')]:_0x28a719[_0x221af9('0x2f')];typeof _0x5c8b75['query'][_0x221af9('0x28')]===_0x221af9('0x1a')&&(_0x4707bf[_0x221af9('0x7')]=qs[_0x221af9('0x7')](_0x5c8b75[_0x221af9('0x27')][_0x221af9('0x7')]),_0x4707bf['offset']=qs['offset'](_0x5c8b75[_0x221af9('0x27')]['offset']));_0x4707bf['order']=qs[_0x221af9('0x1e')](_0x5c8b75[_0x221af9('0x27')][_0x221af9('0x1e')]),_0x4707bf[_0x221af9('0x34')]=qs[_0x221af9('0x13')](_[_0x221af9('0x1f')](_0x5c8b75[_0x221af9('0x27')],_0x28a719[_0x221af9('0x13')]),_0x57b2ca);_0x5c8b75[_0x221af9('0x27')][_0x221af9('0x1c')]&&(_0x4707bf[_0x221af9('0x34')]=_[_0x221af9('0x12')](_0x4707bf[_0x221af9('0x34')],{[Op['or']]:_[_0x221af9('0x29')](_0x57b2ca,function(_0x3362e7){const _0x251c7a=_0x221af9;if(_0x3362e7[_0x251c7a('0x2e')]!==_0x251c7a('0x4')){const _0x1c09ac={};return _0x1c09ac[_0x3362e7[_0x251c7a('0x20')]]={[Op[_0x251c7a('0x1')]]:'%'+_0x5c8b75[_0x251c7a('0x27')][_0x251c7a('0x1c')]+'%'},_0x1c09ac;}})}));_0x4707bf=_[_0x221af9('0x12')]({},_0x4707bf,_0x5c8b75[_0x221af9('0x2b')]);const _0x222860={'where':_0x4707bf[_0x221af9('0x34')]};return db['SquareReport']['count'](_0x222860)['then'](function(_0x1b0616){const _0x858153=_0x221af9;return _0x4efabc[_0x858153('0x0')]=_0x1b0616,_0x5c8b75['query'][_0x858153('0x26')]&&(_0x4707bf[_0x858153('0x6')]=[{'all':!![]}]),db[_0x858153('0x8')][_0x858153('0x5')](_0x4707bf);})[_0x221af9('0x19')](function(_0x189788){const _0x961201=_0x221af9;return _0x4efabc[_0x961201('0x30')]=_0x189788,_0x4efabc;})[_0x221af9('0x19')](respondWithFilteredResult(_0x1ae033,_0x4707bf))[_0x221af9('0x25')](handleError(_0x1ae033,null));},exports[_0x3fac27('0xc')]=function(_0x47eda4,_0x19c073){const _0x3c5650=_0x3fac27;let _0x362e30={'raw':!![],'where':{'id':_0x47eda4[_0x3c5650('0x24')]['id']}};const _0x1c0bf6={};return _0x1c0bf6[_0x3c5650('0x2f')]=_['keys'](db[_0x3c5650('0x8')]['rawAttributes']),_0x1c0bf6['query']=_[_0x3c5650('0xa')](_0x47eda4[_0x3c5650('0x27')]),_0x1c0bf6[_0x3c5650('0x13')]=_[_0x3c5650('0xb')](_0x1c0bf6[_0x3c5650('0x2f')],_0x1c0bf6[_0x3c5650('0x27')]),_0x362e30[_0x3c5650('0x16')]=_[_0x3c5650('0xb')](_0x1c0bf6['model'],qs['fields'](_0x47eda4[_0x3c5650('0x27')][_0x3c5650('0x23')])),_0x362e30[_0x3c5650('0x16')]=_0x362e30['attributes'][_0x3c5650('0xd')]?_0x362e30[_0x3c5650('0x16')]:_0x1c0bf6[_0x3c5650('0x2f')],_0x47eda4['query'][_0x3c5650('0x26')]&&(_0x362e30['include']=[{'all':!![]}]),_0x362e30=_['merge']({},_0x362e30,_0x47eda4['options']),db[_0x3c5650('0x8')][_0x3c5650('0x1b')](_0x362e30)[_0x3c5650('0x19')](handleEntityNotFound(_0x19c073,null))[_0x3c5650('0x19')](respondWithResult(_0x19c073,null))[_0x3c5650('0x25')](handleError(_0x19c073,null));},exports[_0x3fac27('0x21')]=function(_0x420afe,_0xb55393){const _0x503187=_0x3fac27;return db['SquareReport'][_0x503187('0x21')](_0x420afe[_0x503187('0x14')],{})[_0x503187('0x19')](respondWithResult(_0xb55393,0xc9))[_0x503187('0x25')](handleError(_0xb55393,null));},exports['update']=function(_0x527e10,_0x318227){const _0x1505c7=_0x3fac27;return _0x527e10['body']['id']&&delete _0x527e10[_0x1505c7('0x14')]['id'],db[_0x1505c7('0x8')][_0x1505c7('0x1b')]({'where':{'id':_0x527e10[_0x1505c7('0x24')]['id']}})[_0x1505c7('0x19')](handleEntityNotFound(_0x318227,null))[_0x1505c7('0x19')](saveUpdates(_0x527e10[_0x1505c7('0x14')],null))[_0x1505c7('0x19')](respondWithResult(_0x318227,null))['catch'](handleError(_0x318227,null));},exports['destroy']=function(_0x3bf892,_0x1abce9){const _0x43d75b=_0x3fac27;return db[_0x43d75b('0x8')][_0x43d75b('0x1b')]({'where':{'id':_0x3bf892[_0x43d75b('0x24')]['id']}})[_0x43d75b('0x19')](handleEntityNotFound(_0x1abce9,null))['then'](removeEntity(_0x1abce9,null))[_0x43d75b('0x25')](handleError(_0x1abce9,null));},exports['describe']=function(_0x45997b,_0x44c734){const _0x515adc=_0x3fac27;return db['SquareReport'][_0x515adc('0x17')]()[_0x515adc('0x19')](respondWithResult(_0x44c734,null))['catch'](handleError(_0x44c734,null));};