a21ab8128811f80ace05d0e6ceba1e97489be749
[motion-next.git] / server / api / squareMessage / squareMessage.controller.js
1 const a588_0x37a1=['merge','findOne','options','json','show','params','offset','type','sendStatus','attributes','model','pick','include','filter','send','length','filters','where','api','then','like','lodash','destroy','rawAttributes','limit','map','update','stack','rows','Content-Range','set','../../config/logger','undefined','count','query','end','body','name','SquareMessage','includeAll','index','nolimit','create','status','error','keys','fields','intersection','fieldName','sort','catch','order'];(function(_0x5aa056,_0x37a174){const _0x5cc05d=function(_0x38ad7c){while(--_0x38ad7c){_0x5aa056['push'](_0x5aa056['shift']());}};_0x5cc05d(++_0x37a174);}(a588_0x37a1,0x1e1));const a588_0x5cc0=function(_0x5aa056,_0x37a174){_0x5aa056=_0x5aa056-0x0;let _0x5cc05d=a588_0x37a1[_0x5aa056];return _0x5cc05d;};const _0x5abc88=a588_0x5cc0;'use strict';const _=require(_0x5abc88('0x8')),qs=require('../../components/parsers/qs'),logger=require(_0x5abc88('0x12'))(_0x5abc88('0x5')),db=require('../../mysqldb')['db'],{Op}=require('sequelize');function respondWithResult(_0x38ad7c,_0xdd6ef2){return _0xdd6ef2=_0xdd6ef2||0xc8,function(_0x5aad7d){const _0x5588b3=a588_0x5cc0;if(_0x5aad7d)return _0x38ad7c['status'](_0xdd6ef2)[_0x5588b3('0x2a')](_0x5aad7d);};}function respondWithFilteredResult(_0x2f8f5f,_0x59ed26){return function(_0x29fbed){const _0x58126d=a588_0x5cc0;if(_0x29fbed){const _0x43214b=_0x29fbed[_0x58126d('0x14')],_0x5b4f60=_0x59ed26[_0x58126d('0x2d')];let _0x1473ea=_0x59ed26[_0x58126d('0x2d')]+_0x59ed26[_0x58126d('0xb')],_0x26c8f7;return _0x1473ea>=_0x43214b?(_0x1473ea=_0x43214b,_0x26c8f7=0xc8):_0x26c8f7=0xce,_0x2f8f5f[_0x58126d('0x1e')](_0x26c8f7),_0x2f8f5f[_0x58126d('0x11')](_0x58126d('0x10'),_0x5b4f60+'-'+_0x1473ea+'/'+_0x43214b)[_0x58126d('0x2a')](_0x29fbed);}return null;};}function saveUpdates(_0x7c32c5){return function(_0x44b53b){const _0x471c66=a588_0x5cc0;if(_0x44b53b)return _0x44b53b['update'](_0x7c32c5)[_0x471c66('0x6')](function(_0x2f7262){return _0x2f7262;});return null;};}function removeEntity(_0xf02e83){return function(_0x11795c){const _0xe0379b=a588_0x5cc0;if(_0x11795c)return _0x11795c[_0xe0379b('0x9')]()[_0xe0379b('0x6')](function(){const _0x523315=_0xe0379b;_0xf02e83[_0x523315('0x1e')](0xcc)[_0x523315('0x16')]();});};}function handleEntityNotFound(_0x4113a8){return function(_0x19d78d){const _0x56fdf9=a588_0x5cc0;return!_0x19d78d&&_0x4113a8[_0x56fdf9('0x2f')](0x194),_0x19d78d;};}function handleError(_0x4422cf,_0xaf562c){return _0xaf562c=_0xaf562c||0x1f4,function(_0x5644c8){const _0x1a987f=a588_0x5cc0;logger[_0x1a987f('0x1f')](_0x5644c8[_0x1a987f('0xe')]),_0x5644c8[_0x1a987f('0x18')]&&delete _0x5644c8[_0x1a987f('0x18')],_0x4422cf['status'](_0xaf562c)[_0x1a987f('0x1')](_0x5644c8);};}exports[_0x5abc88('0x1b')]=function(_0xa3cbe6,_0xbc3f4){const _0x3b71c1=_0x5abc88;let _0x11b673={};const _0x21a671={},_0x485c23={'count':0x0,'rows':[]},_0x5d02f8=_['map'](db[_0x3b71c1('0x19')][_0x3b71c1('0xa')],function(_0x1ae1e7){const _0x46d090=_0x3b71c1;return{'name':_0x1ae1e7[_0x46d090('0x23')],'type':_0x1ae1e7[_0x46d090('0x2e')]['key']};});_0x21a671[_0x3b71c1('0x31')]=_[_0x3b71c1('0xc')](_0x5d02f8,'name'),_0x21a671['query']=_[_0x3b71c1('0x20')](_0xa3cbe6[_0x3b71c1('0x15')]),_0x21a671['filters']=_[_0x3b71c1('0x22')](_0x21a671[_0x3b71c1('0x31')],_0x21a671['query']),_0x11b673[_0x3b71c1('0x30')]=_['intersection'](_0x21a671['model'],qs[_0x3b71c1('0x21')](_0xa3cbe6[_0x3b71c1('0x15')][_0x3b71c1('0x21')])),_0x11b673['attributes']=_0x11b673['attributes'][_0x3b71c1('0x2')]?_0x11b673[_0x3b71c1('0x30')]:_0x21a671['model'];typeof _0xa3cbe6[_0x3b71c1('0x15')][_0x3b71c1('0x1c')]===_0x3b71c1('0x13')&&(_0x11b673[_0x3b71c1('0xb')]=qs[_0x3b71c1('0xb')](_0xa3cbe6[_0x3b71c1('0x15')]['limit']),_0x11b673[_0x3b71c1('0x2d')]=qs[_0x3b71c1('0x2d')](_0xa3cbe6[_0x3b71c1('0x15')][_0x3b71c1('0x2d')]));_0x11b673[_0x3b71c1('0x26')]=qs[_0x3b71c1('0x24')](_0xa3cbe6[_0x3b71c1('0x15')]['sort']),_0x11b673['where']=qs['filters'](_[_0x3b71c1('0x32')](_0xa3cbe6[_0x3b71c1('0x15')],_0x21a671['filters']),_0x5d02f8);_0xa3cbe6[_0x3b71c1('0x15')]['filter']&&(_0x11b673[_0x3b71c1('0x4')]=_[_0x3b71c1('0x27')](_0x11b673[_0x3b71c1('0x4')],{[Op['or']]:_['map'](_0x5d02f8,function(_0x3797b7){const _0x1fd5c6=_0x3b71c1;if(_0x3797b7[_0x1fd5c6('0x2e')]!=='VIRTUAL'){const _0x3c4f6a={};return _0x3c4f6a[_0x3797b7[_0x1fd5c6('0x18')]]={[Op[_0x1fd5c6('0x7')]]:'%'+_0xa3cbe6['query'][_0x1fd5c6('0x0')]+'%'},_0x3c4f6a;}})}));_0x11b673=_[_0x3b71c1('0x27')]({},_0x11b673,_0xa3cbe6[_0x3b71c1('0x29')]);const _0x44a568={'where':_0x11b673[_0x3b71c1('0x4')]};return db[_0x3b71c1('0x19')][_0x3b71c1('0x14')](_0x44a568)[_0x3b71c1('0x6')](function(_0xace60e){const _0x5ee8c3=_0x3b71c1;return _0x485c23[_0x5ee8c3('0x14')]=_0xace60e,_0xa3cbe6['query'][_0x5ee8c3('0x1a')]&&(_0x11b673[_0x5ee8c3('0x33')]=[{'all':!![]}]),db['SquareMessage']['findAll'](_0x11b673);})['then'](function(_0x44a896){const _0x67c500=_0x3b71c1;return _0x485c23[_0x67c500('0xf')]=_0x44a896,_0x485c23;})['then'](respondWithFilteredResult(_0xbc3f4,_0x11b673))['catch'](handleError(_0xbc3f4,null));},exports[_0x5abc88('0x2b')]=function(_0x5cf185,_0x28cbf6){const _0x69e2f7=_0x5abc88;let _0xd8857a={'raw':!![],'where':{'id':_0x5cf185[_0x69e2f7('0x2c')]['id']}};const _0x1e78bf={};return _0x1e78bf['model']=_[_0x69e2f7('0x20')](db[_0x69e2f7('0x19')][_0x69e2f7('0xa')]),_0x1e78bf[_0x69e2f7('0x15')]=_[_0x69e2f7('0x20')](_0x5cf185[_0x69e2f7('0x15')]),_0x1e78bf[_0x69e2f7('0x3')]=_[_0x69e2f7('0x22')](_0x1e78bf['model'],_0x1e78bf[_0x69e2f7('0x15')]),_0xd8857a['attributes']=_[_0x69e2f7('0x22')](_0x1e78bf[_0x69e2f7('0x31')],qs[_0x69e2f7('0x21')](_0x5cf185[_0x69e2f7('0x15')][_0x69e2f7('0x21')])),_0xd8857a[_0x69e2f7('0x30')]=_0xd8857a['attributes'][_0x69e2f7('0x2')]?_0xd8857a[_0x69e2f7('0x30')]:_0x1e78bf['model'],_0x5cf185[_0x69e2f7('0x15')][_0x69e2f7('0x1a')]&&(_0xd8857a[_0x69e2f7('0x33')]=[{'all':!![]}]),_0xd8857a=_['merge']({},_0xd8857a,_0x5cf185[_0x69e2f7('0x29')]),db['SquareMessage'][_0x69e2f7('0x28')](_0xd8857a)[_0x69e2f7('0x6')](handleEntityNotFound(_0x28cbf6,null))[_0x69e2f7('0x6')](respondWithResult(_0x28cbf6,null))['catch'](handleError(_0x28cbf6,null));},exports['create']=function(_0x258259,_0x28eea8){const _0x354316=_0x5abc88;return db[_0x354316('0x19')][_0x354316('0x1d')](_0x258259[_0x354316('0x17')],{})['then'](respondWithResult(_0x28eea8,0xc9))['catch'](handleError(_0x28eea8,null));},exports[_0x5abc88('0xd')]=function(_0xa6a46f,_0x13ab31){const _0x4ec7a=_0x5abc88;return _0xa6a46f[_0x4ec7a('0x17')]['id']&&delete _0xa6a46f[_0x4ec7a('0x17')]['id'],db[_0x4ec7a('0x19')][_0x4ec7a('0x28')]({'where':{'id':_0xa6a46f['params']['id']}})[_0x4ec7a('0x6')](handleEntityNotFound(_0x13ab31,null))['then'](saveUpdates(_0xa6a46f[_0x4ec7a('0x17')],null))[_0x4ec7a('0x6')](respondWithResult(_0x13ab31,null))[_0x4ec7a('0x25')](handleError(_0x13ab31,null));},exports[_0x5abc88('0x9')]=function(_0x5a2fe9,_0x5c6b76){const _0x1106a2=_0x5abc88;return db['SquareMessage'][_0x1106a2('0x28')]({'where':{'id':_0x5a2fe9[_0x1106a2('0x2c')]['id']}})[_0x1106a2('0x6')](handleEntityNotFound(_0x5c6b76,null))[_0x1106a2('0x6')](removeEntity(_0x5c6b76,null))[_0x1106a2('0x25')](handleError(_0x5c6b76,null));};