59095d42ad0a3138062639f79dbe13e40a90138f
[motion-next.git] / server / api / voiceDialReport / voiceDialReport.controller.js
1 const a722_0x5a8e=['VIRTUAL','json','describe','send','findOne','type','params','set','count','fieldName','error','destroy','VoiceDialReport','options','body','query','status','Content-Range','map','findAll','catch','create','filters','attributes','offset','name','rows','include','key','sequelize','where','merge','fields','api','update','keys','filter','like','order','length','lodash','model','rawAttributes','show','index','includeAll','stack','then','limit','nolimit','intersection'];(function(_0xb8e5d4,_0x5a8e04){const _0x4cb2c9=function(_0x313b22){while(--_0x313b22){_0xb8e5d4['push'](_0xb8e5d4['shift']());}};_0x4cb2c9(++_0x5a8e04);}(a722_0x5a8e,0x71));const a722_0x4cb2=function(_0xb8e5d4,_0x5a8e04){_0xb8e5d4=_0xb8e5d4-0x0;let _0x4cb2c9=a722_0x5a8e[_0xb8e5d4];return _0x4cb2c9;};const _0x83ca68=a722_0x4cb2;'use strict';const _=require(_0x83ca68('0x1d')),qs=require('../../components/parsers/qs'),logger=require('../../config/logger')(_0x83ca68('0x16')),db=require('../../mysqldb')['db'],{Op}=require(_0x83ca68('0x12'));function respondWithResult(_0x313b22,_0x13a6b3){return _0x13a6b3=_0x13a6b3||0xc8,function(_0x26ad98){const _0x2ac2d5=a722_0x4cb2;if(_0x26ad98)return _0x313b22[_0x2ac2d5('0x5')](_0x13a6b3)[_0x2ac2d5('0x29')](_0x26ad98);};}function respondWithFilteredResult(_0x3f7197,_0x2ae4a5){return function(_0x2c9cec){const _0x2f4b4a=a722_0x4cb2;if(_0x2c9cec){const _0x238316=_0x2c9cec['count'],_0x28b495=_0x2ae4a5[_0x2f4b4a('0xd')];let _0xad4ac4=_0x2ae4a5[_0x2f4b4a('0xd')]+_0x2ae4a5['limit'],_0x12162a;return _0xad4ac4>=_0x238316?(_0xad4ac4=_0x238316,_0x12162a=0xc8):_0x12162a=0xce,_0x3f7197[_0x2f4b4a('0x5')](_0x12162a),_0x3f7197[_0x2f4b4a('0x2f')](_0x2f4b4a('0x6'),_0x28b495+'-'+_0xad4ac4+'/'+_0x238316)[_0x2f4b4a('0x29')](_0x2c9cec);}return null;};}function saveUpdates(_0x4a5362){return function(_0x5ef691){const _0x30dc64=a722_0x4cb2;if(_0x5ef691)return _0x5ef691[_0x30dc64('0x17')](_0x4a5362)[_0x30dc64('0x24')](function(_0x5694ba){return _0x5694ba;});return null;};}function removeEntity(_0x50c697){return function(_0xa3a443){const _0x4c5c68=a722_0x4cb2;if(_0xa3a443)return _0xa3a443['destroy']()[_0x4c5c68('0x24')](function(){const _0x58ce17=_0x4c5c68;_0x50c697[_0x58ce17('0x5')](0xcc)['end']();});};}function handleEntityNotFound(_0x2f7627){return function(_0x1e5941){return!_0x1e5941&&_0x2f7627['sendStatus'](0x194),_0x1e5941;};}function handleError(_0x420f12,_0x77a57d){return _0x77a57d=_0x77a57d||0x1f4,function(_0x185c10){const _0x423026=a722_0x4cb2;logger[_0x423026('0x32')](_0x185c10[_0x423026('0x23')]),_0x185c10[_0x423026('0xe')]&&delete _0x185c10[_0x423026('0xe')],_0x420f12[_0x423026('0x5')](_0x77a57d)[_0x423026('0x2b')](_0x185c10);};}exports[_0x83ca68('0x21')]=function(_0x453c3c,_0x40f534){const _0x28fdca=_0x83ca68;let _0x21c699={};const _0x202236={},_0x10fd0b={'count':0x0,'rows':[]},_0x1f24b1=_['map'](db['VoiceDialReport'][_0x28fdca('0x1f')],function(_0x545719){const _0x4d5379=_0x28fdca;return{'name':_0x545719[_0x4d5379('0x31')],'type':_0x545719[_0x4d5379('0x2d')][_0x4d5379('0x11')]};});_0x202236['model']=_[_0x28fdca('0x7')](_0x1f24b1,_0x28fdca('0xe')),_0x202236[_0x28fdca('0x4')]=_[_0x28fdca('0x18')](_0x453c3c['query']),_0x202236[_0x28fdca('0xb')]=_[_0x28fdca('0x27')](_0x202236[_0x28fdca('0x1e')],_0x202236[_0x28fdca('0x4')]),_0x21c699[_0x28fdca('0xc')]=_[_0x28fdca('0x27')](_0x202236['model'],qs[_0x28fdca('0x15')](_0x453c3c['query'][_0x28fdca('0x15')])),_0x21c699['attributes']=_0x21c699['attributes']['length']?_0x21c699['attributes']:_0x202236[_0x28fdca('0x1e')];typeof _0x453c3c[_0x28fdca('0x4')][_0x28fdca('0x26')]==='undefined'&&(_0x21c699[_0x28fdca('0x25')]=qs[_0x28fdca('0x25')](_0x453c3c[_0x28fdca('0x4')]['limit']),_0x21c699[_0x28fdca('0xd')]=qs[_0x28fdca('0xd')](_0x453c3c[_0x28fdca('0x4')][_0x28fdca('0xd')]));_0x21c699[_0x28fdca('0x1b')]=qs['sort'](_0x453c3c[_0x28fdca('0x4')]['sort']),_0x21c699[_0x28fdca('0x13')]=qs[_0x28fdca('0xb')](_['pick'](_0x453c3c['query'],_0x202236[_0x28fdca('0xb')]),_0x1f24b1);_0x453c3c[_0x28fdca('0x4')][_0x28fdca('0x19')]&&(_0x21c699[_0x28fdca('0x13')]=_[_0x28fdca('0x14')](_0x21c699['where'],{[Op['or']]:_[_0x28fdca('0x7')](_0x1f24b1,function(_0x543e5e){const _0x7ed33f=_0x28fdca;if(_0x543e5e[_0x7ed33f('0x2d')]!==_0x7ed33f('0x28')){const _0x4f397a={};return _0x4f397a[_0x543e5e[_0x7ed33f('0xe')]]={[Op[_0x7ed33f('0x1a')]]:'%'+_0x453c3c[_0x7ed33f('0x4')][_0x7ed33f('0x19')]+'%'},_0x4f397a;}})}));_0x21c699=_[_0x28fdca('0x14')]({},_0x21c699,_0x453c3c['options']);const _0x3f0500={'where':_0x21c699[_0x28fdca('0x13')]};return db[_0x28fdca('0x1')][_0x28fdca('0x30')](_0x3f0500)['then'](function(_0x454e41){const _0x2738d8=_0x28fdca;return _0x10fd0b[_0x2738d8('0x30')]=_0x454e41,_0x453c3c[_0x2738d8('0x4')][_0x2738d8('0x22')]&&(_0x21c699['include']=[{'all':!![]}]),db[_0x2738d8('0x1')][_0x2738d8('0x8')](_0x21c699);})[_0x28fdca('0x24')](function(_0x2e7470){const _0x541a31=_0x28fdca;return _0x10fd0b[_0x541a31('0xf')]=_0x2e7470,_0x10fd0b;})[_0x28fdca('0x24')](respondWithFilteredResult(_0x40f534,_0x21c699))['catch'](handleError(_0x40f534,null));},exports[_0x83ca68('0x20')]=function(_0x4860de,_0x424b97){const _0x1b111b=_0x83ca68;let _0xcda1b5={'raw':!![],'where':{'id':_0x4860de['params']['id']}};const _0x55b5a7={};return _0x55b5a7['model']=_[_0x1b111b('0x18')](db[_0x1b111b('0x1')]['rawAttributes']),_0x55b5a7[_0x1b111b('0x4')]=_[_0x1b111b('0x18')](_0x4860de[_0x1b111b('0x4')]),_0x55b5a7[_0x1b111b('0xb')]=_['intersection'](_0x55b5a7[_0x1b111b('0x1e')],_0x55b5a7[_0x1b111b('0x4')]),_0xcda1b5['attributes']=_['intersection'](_0x55b5a7[_0x1b111b('0x1e')],qs[_0x1b111b('0x15')](_0x4860de[_0x1b111b('0x4')][_0x1b111b('0x15')])),_0xcda1b5[_0x1b111b('0xc')]=_0xcda1b5['attributes'][_0x1b111b('0x1c')]?_0xcda1b5[_0x1b111b('0xc')]:_0x55b5a7[_0x1b111b('0x1e')],_0x4860de['query'][_0x1b111b('0x22')]&&(_0xcda1b5[_0x1b111b('0x10')]=[{'all':!![]}]),_0xcda1b5=_[_0x1b111b('0x14')]({},_0xcda1b5,_0x4860de[_0x1b111b('0x2')]),db[_0x1b111b('0x1')][_0x1b111b('0x2c')](_0xcda1b5)[_0x1b111b('0x24')](handleEntityNotFound(_0x424b97,null))['then'](respondWithResult(_0x424b97,null))['catch'](handleError(_0x424b97,null));},exports[_0x83ca68('0xa')]=function(_0x548a9d,_0x16deeb){const _0x1f0d83=_0x83ca68;return db[_0x1f0d83('0x1')][_0x1f0d83('0xa')](_0x548a9d[_0x1f0d83('0x3')],{})[_0x1f0d83('0x24')](respondWithResult(_0x16deeb,0xc9))[_0x1f0d83('0x9')](handleError(_0x16deeb,null));},exports[_0x83ca68('0x17')]=function(_0x27022e,_0x1b55e0){const _0x2bea57=_0x83ca68;return _0x27022e[_0x2bea57('0x3')]['id']&&delete _0x27022e[_0x2bea57('0x3')]['id'],db['VoiceDialReport']['findOne']({'where':{'id':_0x27022e[_0x2bea57('0x2e')]['id']}})[_0x2bea57('0x24')](handleEntityNotFound(_0x1b55e0,null))[_0x2bea57('0x24')](saveUpdates(_0x27022e[_0x2bea57('0x3')],null))[_0x2bea57('0x24')](respondWithResult(_0x1b55e0,null))[_0x2bea57('0x9')](handleError(_0x1b55e0,null));},exports[_0x83ca68('0x0')]=function(_0x35b764,_0x2b2ebd){const _0x973c91=_0x83ca68;return db[_0x973c91('0x1')][_0x973c91('0x2c')]({'where':{'id':_0x35b764[_0x973c91('0x2e')]['id']}})[_0x973c91('0x24')](handleEntityNotFound(_0x2b2ebd,null))['then'](removeEntity(_0x2b2ebd,null))[_0x973c91('0x9')](handleError(_0x2b2ebd,null));},exports[_0x83ca68('0x2a')]=function(_0x4cfd5e,_0x1e6c62){const _0xa66ecf=_0x83ca68;return db[_0xa66ecf('0x1')][_0xa66ecf('0x2a')]()['then'](respondWithResult(_0x1e6c62,null))['catch'](handleError(_0x1e6c62,null));};