54092cc368f14ea59548277cdf08d24efca84d0d
[motion-next.git] / server / api / smsQueueReport / smsQueueReport.controller.js
1 const a574_0xf4c5=['VIRTUAL','sequelize','options','sendStatus','stack','end','count','filter','name','fields','show','lodash','json','../../config/logger','api','set','describe','send','SmsQueueReport','includeAll','params','findAll','query','include','sort','map','type','destroy','attributes','filters','then','where','rawAttributes','status','rows','catch','limit','model','update','pick','length','merge','create','keys','fieldName','intersection','../../mysqldb','body','findOne','error','offset','Content-Range','nolimit'];(function(_0x126de0,_0xf4c5c6){const _0x3650b0=function(_0x25d463){while(--_0x25d463){_0x126de0['push'](_0x126de0['shift']());}};_0x3650b0(++_0xf4c5c6);}(a574_0xf4c5,0x130));const a574_0x3650=function(_0x126de0,_0xf4c5c6){_0x126de0=_0x126de0-0x0;let _0x3650b0=a574_0xf4c5[_0x126de0];return _0x3650b0;};const _0x34c1ca=a574_0x3650;'use strict';const _=require(_0x34c1ca('0x19')),qs=require('../../components/parsers/qs'),logger=require(_0x34c1ca('0x1b'))(_0x34c1ca('0x1c')),db=require(_0x34c1ca('0x7'))['db'],{Op}=require(_0x34c1ca('0xf'));function respondWithResult(_0x25d463,_0x49b8f7){return _0x49b8f7=_0x49b8f7||0xc8,function(_0x139ad9){const _0x2e7a15=a574_0x3650;if(_0x139ad9)return _0x25d463[_0x2e7a15('0x2f')](_0x49b8f7)[_0x2e7a15('0x1a')](_0x139ad9);};}function respondWithFilteredResult(_0x327d00,_0x287609){return function(_0x430629){const _0xe65d97=a574_0x3650;if(_0x430629){const _0x7c6657=_0x430629[_0xe65d97('0x14')],_0x1eb0ec=_0x287609[_0xe65d97('0xb')];let _0x3cd1f5=_0x287609['offset']+_0x287609[_0xe65d97('0x32')],_0x238b0e;return _0x3cd1f5>=_0x7c6657?(_0x3cd1f5=_0x7c6657,_0x238b0e=0xc8):_0x238b0e=0xce,_0x327d00[_0xe65d97('0x2f')](_0x238b0e),_0x327d00[_0xe65d97('0x1d')](_0xe65d97('0xc'),_0x1eb0ec+'-'+_0x3cd1f5+'/'+_0x7c6657)[_0xe65d97('0x1a')](_0x430629);}return null;};}function saveUpdates(_0x4f890f){return function(_0x2b6ad7){const _0x315719=a574_0x3650;if(_0x2b6ad7)return _0x2b6ad7[_0x315719('0x34')](_0x4f890f)[_0x315719('0x2c')](function(_0x31c2cb){return _0x31c2cb;});return null;};}function removeEntity(_0x137a20){return function(_0x25024e){const _0xc86b71=a574_0x3650;if(_0x25024e)return _0x25024e['destroy']()[_0xc86b71('0x2c')](function(){const _0x1faad9=_0xc86b71;_0x137a20[_0x1faad9('0x2f')](0xcc)[_0x1faad9('0x13')]();});};}function handleEntityNotFound(_0x11b0e1){return function(_0x228038){const _0x349153=a574_0x3650;return!_0x228038&&_0x11b0e1[_0x349153('0x11')](0x194),_0x228038;};}function handleError(_0x193431,_0x2c4ba8){return _0x2c4ba8=_0x2c4ba8||0x1f4,function(_0xf57212){const _0x2f16ca=a574_0x3650;logger[_0x2f16ca('0xa')](_0xf57212[_0x2f16ca('0x12')]),_0xf57212[_0x2f16ca('0x16')]&&delete _0xf57212[_0x2f16ca('0x16')],_0x193431[_0x2f16ca('0x2f')](_0x2c4ba8)[_0x2f16ca('0x1f')](_0xf57212);};}exports['index']=function(_0x3dc1fb,_0xbe3ea){const _0x364f93=_0x34c1ca;let _0x5d0b2e={};const _0x4f6b19={},_0x27e1f7={'count':0x0,'rows':[]},_0x5e2781=_[_0x364f93('0x27')](db['SmsQueueReport'][_0x364f93('0x2e')],function(_0x4c1b52){const _0x8a58c5=_0x364f93;return{'name':_0x4c1b52[_0x8a58c5('0x5')],'type':_0x4c1b52[_0x8a58c5('0x28')]['key']};});_0x4f6b19['model']=_[_0x364f93('0x27')](_0x5e2781,_0x364f93('0x16')),_0x4f6b19[_0x364f93('0x24')]=_[_0x364f93('0x4')](_0x3dc1fb['query']),_0x4f6b19[_0x364f93('0x2b')]=_[_0x364f93('0x6')](_0x4f6b19[_0x364f93('0x33')],_0x4f6b19[_0x364f93('0x24')]),_0x5d0b2e['attributes']=_['intersection'](_0x4f6b19[_0x364f93('0x33')],qs['fields'](_0x3dc1fb[_0x364f93('0x24')][_0x364f93('0x17')])),_0x5d0b2e['attributes']=_0x5d0b2e[_0x364f93('0x2a')][_0x364f93('0x1')]?_0x5d0b2e[_0x364f93('0x2a')]:_0x4f6b19[_0x364f93('0x33')];typeof _0x3dc1fb[_0x364f93('0x24')][_0x364f93('0xd')]==='undefined'&&(_0x5d0b2e[_0x364f93('0x32')]=qs[_0x364f93('0x32')](_0x3dc1fb[_0x364f93('0x24')]['limit']),_0x5d0b2e[_0x364f93('0xb')]=qs[_0x364f93('0xb')](_0x3dc1fb[_0x364f93('0x24')]['offset']));_0x5d0b2e['order']=qs[_0x364f93('0x26')](_0x3dc1fb[_0x364f93('0x24')]['sort']),_0x5d0b2e[_0x364f93('0x2d')]=qs[_0x364f93('0x2b')](_[_0x364f93('0x0')](_0x3dc1fb[_0x364f93('0x24')],_0x4f6b19[_0x364f93('0x2b')]),_0x5e2781);_0x3dc1fb[_0x364f93('0x24')][_0x364f93('0x15')]&&(_0x5d0b2e[_0x364f93('0x2d')]=_[_0x364f93('0x2')](_0x5d0b2e[_0x364f93('0x2d')],{[Op['or']]:_['map'](_0x5e2781,function(_0x162def){const _0x759599=_0x364f93;if(_0x162def['type']!==_0x759599('0xe')){const _0x5cb445={};return _0x5cb445[_0x162def[_0x759599('0x16')]]={[Op['like']]:'%'+_0x3dc1fb[_0x759599('0x24')][_0x759599('0x15')]+'%'},_0x5cb445;}})}));_0x5d0b2e=_[_0x364f93('0x2')]({},_0x5d0b2e,_0x3dc1fb[_0x364f93('0x10')]);const _0x465e30={'where':_0x5d0b2e[_0x364f93('0x2d')]};return db[_0x364f93('0x20')][_0x364f93('0x14')](_0x465e30)['then'](function(_0x4f3480){const _0x12fdc5=_0x364f93;return _0x27e1f7['count']=_0x4f3480,_0x3dc1fb[_0x12fdc5('0x24')]['includeAll']&&(_0x5d0b2e[_0x12fdc5('0x25')]=[{'all':!![]}]),db[_0x12fdc5('0x20')][_0x12fdc5('0x23')](_0x5d0b2e);})[_0x364f93('0x2c')](function(_0x33d161){const _0x41ad5e=_0x364f93;return _0x27e1f7[_0x41ad5e('0x30')]=_0x33d161,_0x27e1f7;})[_0x364f93('0x2c')](respondWithFilteredResult(_0xbe3ea,_0x5d0b2e))['catch'](handleError(_0xbe3ea,null));},exports[_0x34c1ca('0x18')]=function(_0xb91bcc,_0x3d7cac){const _0x120289=_0x34c1ca;let _0x23a251={'raw':!![],'where':{'id':_0xb91bcc[_0x120289('0x22')]['id']}};const _0x40df08={};return _0x40df08['model']=_[_0x120289('0x4')](db['SmsQueueReport'][_0x120289('0x2e')]),_0x40df08[_0x120289('0x24')]=_['keys'](_0xb91bcc[_0x120289('0x24')]),_0x40df08[_0x120289('0x2b')]=_[_0x120289('0x6')](_0x40df08[_0x120289('0x33')],_0x40df08[_0x120289('0x24')]),_0x23a251['attributes']=_[_0x120289('0x6')](_0x40df08[_0x120289('0x33')],qs[_0x120289('0x17')](_0xb91bcc[_0x120289('0x24')][_0x120289('0x17')])),_0x23a251[_0x120289('0x2a')]=_0x23a251[_0x120289('0x2a')][_0x120289('0x1')]?_0x23a251[_0x120289('0x2a')]:_0x40df08[_0x120289('0x33')],_0xb91bcc[_0x120289('0x24')][_0x120289('0x21')]&&(_0x23a251[_0x120289('0x25')]=[{'all':!![]}]),_0x23a251=_[_0x120289('0x2')]({},_0x23a251,_0xb91bcc[_0x120289('0x10')]),db['SmsQueueReport'][_0x120289('0x9')](_0x23a251)[_0x120289('0x2c')](handleEntityNotFound(_0x3d7cac,null))[_0x120289('0x2c')](respondWithResult(_0x3d7cac,null))[_0x120289('0x31')](handleError(_0x3d7cac,null));},exports[_0x34c1ca('0x3')]=function(_0x5c9065,_0x3d5c00){const _0xb1f2b=_0x34c1ca;return db[_0xb1f2b('0x20')][_0xb1f2b('0x3')](_0x5c9065['body'],{})[_0xb1f2b('0x2c')](respondWithResult(_0x3d5c00,0xc9))[_0xb1f2b('0x31')](handleError(_0x3d5c00,null));},exports[_0x34c1ca('0x34')]=function(_0x44ccf9,_0x15e384){const _0x5b8f0d=_0x34c1ca;return _0x44ccf9[_0x5b8f0d('0x8')]['id']&&delete _0x44ccf9[_0x5b8f0d('0x8')]['id'],db['SmsQueueReport'][_0x5b8f0d('0x9')]({'where':{'id':_0x44ccf9[_0x5b8f0d('0x22')]['id']}})[_0x5b8f0d('0x2c')](handleEntityNotFound(_0x15e384,null))[_0x5b8f0d('0x2c')](saveUpdates(_0x44ccf9[_0x5b8f0d('0x8')],null))[_0x5b8f0d('0x2c')](respondWithResult(_0x15e384,null))[_0x5b8f0d('0x31')](handleError(_0x15e384,null));},exports[_0x34c1ca('0x29')]=function(_0x4295e1,_0xf5dae4){const _0x48efc1=_0x34c1ca;return db[_0x48efc1('0x20')]['findOne']({'where':{'id':_0x4295e1[_0x48efc1('0x22')]['id']}})[_0x48efc1('0x2c')](handleEntityNotFound(_0xf5dae4,null))[_0x48efc1('0x2c')](removeEntity(_0xf5dae4,null))['catch'](handleError(_0xf5dae4,null));},exports[_0x34c1ca('0x1e')]=function(_0x47317c,_0x2c7826){const _0x39bf76=_0x34c1ca;return db[_0x39bf76('0x20')][_0x39bf76('0x1e')]()[_0x39bf76('0x2c')](respondWithResult(_0x2c7826,null))[_0x39bf76('0x31')](handleError(_0x2c7826,null));};