1af18aca441749de5eb1fea77fc67dfacb475c05
[motion-next.git] / server / api / squareMessage / squareMessage.controller.js
1 const a588_0x276a=['create','Content-Range','count','rawAttributes','../../mysqldb','body','json','like','map','options','then','where','attributes','model','include','length','query','type','filter','VIRTUAL','sequelize','key','index','sort','error','send','status','fieldName','nolimit','../../components/parsers/qs','catch','destroy','offset','fields','end','name','../../config/logger','filters','undefined','SquareMessage','findOne','api','params','intersection','merge','sendStatus','rows','keys','show','set','update','includeAll','limit'];(function(_0x3bcfd2,_0x276af8){const _0x5421c1=function(_0x260096){while(--_0x260096){_0x3bcfd2['push'](_0x3bcfd2['shift']());}};_0x5421c1(++_0x276af8);}(a588_0x276a,0x1d8));const a588_0x5421=function(_0x3bcfd2,_0x276af8){_0x3bcfd2=_0x3bcfd2-0x0;let _0x5421c1=a588_0x276a[_0x3bcfd2];return _0x5421c1;};const _0x5e129a=a588_0x5421;'use strict';const _=require('lodash'),qs=require(_0x5e129a('0x22')),logger=require(_0x5e129a('0x29'))(_0x5e129a('0x2e')),db=require(_0x5e129a('0x9'))['db'],{Op}=require(_0x5e129a('0x19'));function respondWithResult(_0x260096,_0xe5c691){return _0xe5c691=_0xe5c691||0xc8,function(_0x3c34f3){const _0x217175=a588_0x5421;if(_0x3c34f3)return _0x260096[_0x217175('0x1f')](_0xe5c691)[_0x217175('0xb')](_0x3c34f3);};}function respondWithFilteredResult(_0x1ba8ac,_0x456dba){return function(_0x2b20ea){const _0x56202c=a588_0x5421;if(_0x2b20ea){const _0x17b322=_0x2b20ea[_0x56202c('0x7')],_0x369e53=_0x456dba[_0x56202c('0x25')];let _0x388516=_0x456dba[_0x56202c('0x25')]+_0x456dba[_0x56202c('0x4')],_0xb8654c;return _0x388516>=_0x17b322?(_0x388516=_0x17b322,_0xb8654c=0xc8):_0xb8654c=0xce,_0x1ba8ac[_0x56202c('0x1f')](_0xb8654c),_0x1ba8ac[_0x56202c('0x1')](_0x56202c('0x6'),_0x369e53+'-'+_0x388516+'/'+_0x17b322)['json'](_0x2b20ea);}return null;};}function saveUpdates(_0xe726e0){return function(_0x1d4e14){if(_0x1d4e14)return _0x1d4e14['update'](_0xe726e0)['then'](function(_0x3fa480){return _0x3fa480;});return null;};}function removeEntity(_0x75f50e){return function(_0x501e62){const _0x5343fc=a588_0x5421;if(_0x501e62)return _0x501e62[_0x5343fc('0x24')]()[_0x5343fc('0xf')](function(){const _0x1c1adb=_0x5343fc;_0x75f50e[_0x1c1adb('0x1f')](0xcc)[_0x1c1adb('0x27')]();});};}function handleEntityNotFound(_0x1ea217){return function(_0x360c13){const _0x2228f4=a588_0x5421;return!_0x360c13&&_0x1ea217[_0x2228f4('0x32')](0x194),_0x360c13;};}function handleError(_0x150e1a,_0x40483b){return _0x40483b=_0x40483b||0x1f4,function(_0x27aad6){const _0x415ca6=a588_0x5421;logger[_0x415ca6('0x1d')](_0x27aad6['stack']),_0x27aad6[_0x415ca6('0x28')]&&delete _0x27aad6[_0x415ca6('0x28')],_0x150e1a[_0x415ca6('0x1f')](_0x40483b)[_0x415ca6('0x1e')](_0x27aad6);};}exports[_0x5e129a('0x1b')]=function(_0x192bb7,_0x20fd5e){const _0x4acc0=_0x5e129a;let _0x47d9ae={};const _0x4eabad={},_0x46638c={'count':0x0,'rows':[]},_0xa31da6=_['map'](db[_0x4acc0('0x2c')][_0x4acc0('0x8')],function(_0x4db9c8){const _0x594ba8=_0x4acc0;return{'name':_0x4db9c8[_0x594ba8('0x20')],'type':_0x4db9c8[_0x594ba8('0x16')][_0x594ba8('0x1a')]};});_0x4eabad[_0x4acc0('0x12')]=_[_0x4acc0('0xd')](_0xa31da6,_0x4acc0('0x28')),_0x4eabad[_0x4acc0('0x15')]=_[_0x4acc0('0x34')](_0x192bb7[_0x4acc0('0x15')]),_0x4eabad[_0x4acc0('0x2a')]=_[_0x4acc0('0x30')](_0x4eabad[_0x4acc0('0x12')],_0x4eabad[_0x4acc0('0x15')]),_0x47d9ae['attributes']=_[_0x4acc0('0x30')](_0x4eabad[_0x4acc0('0x12')],qs[_0x4acc0('0x26')](_0x192bb7[_0x4acc0('0x15')][_0x4acc0('0x26')])),_0x47d9ae[_0x4acc0('0x11')]=_0x47d9ae['attributes'][_0x4acc0('0x14')]?_0x47d9ae[_0x4acc0('0x11')]:_0x4eabad[_0x4acc0('0x12')];typeof _0x192bb7[_0x4acc0('0x15')][_0x4acc0('0x21')]===_0x4acc0('0x2b')&&(_0x47d9ae[_0x4acc0('0x4')]=qs[_0x4acc0('0x4')](_0x192bb7['query'][_0x4acc0('0x4')]),_0x47d9ae[_0x4acc0('0x25')]=qs['offset'](_0x192bb7['query'][_0x4acc0('0x25')]));_0x47d9ae['order']=qs['sort'](_0x192bb7[_0x4acc0('0x15')][_0x4acc0('0x1c')]),_0x47d9ae[_0x4acc0('0x10')]=qs['filters'](_['pick'](_0x192bb7[_0x4acc0('0x15')],_0x4eabad[_0x4acc0('0x2a')]),_0xa31da6);_0x192bb7['query'][_0x4acc0('0x17')]&&(_0x47d9ae[_0x4acc0('0x10')]=_[_0x4acc0('0x31')](_0x47d9ae['where'],{[Op['or']]:_['map'](_0xa31da6,function(_0x3a8333){const _0x5c5847=_0x4acc0;if(_0x3a8333[_0x5c5847('0x16')]!==_0x5c5847('0x18')){const _0x224b66={};return _0x224b66[_0x3a8333['name']]={[Op[_0x5c5847('0xc')]]:'%'+_0x192bb7[_0x5c5847('0x15')]['filter']+'%'},_0x224b66;}})}));_0x47d9ae=_['merge']({},_0x47d9ae,_0x192bb7['options']);const _0x2c385c={'where':_0x47d9ae[_0x4acc0('0x10')]};return db['SquareMessage'][_0x4acc0('0x7')](_0x2c385c)[_0x4acc0('0xf')](function(_0x111e9a){const _0x32643f=_0x4acc0;return _0x46638c[_0x32643f('0x7')]=_0x111e9a,_0x192bb7['query']['includeAll']&&(_0x47d9ae['include']=[{'all':!![]}]),db[_0x32643f('0x2c')]['findAll'](_0x47d9ae);})[_0x4acc0('0xf')](function(_0x475e3b){const _0xb65b4d=_0x4acc0;return _0x46638c[_0xb65b4d('0x33')]=_0x475e3b,_0x46638c;})[_0x4acc0('0xf')](respondWithFilteredResult(_0x20fd5e,_0x47d9ae))[_0x4acc0('0x23')](handleError(_0x20fd5e,null));},exports[_0x5e129a('0x0')]=function(_0x35b3a8,_0x362be5){const _0x2e9a73=_0x5e129a;let _0x175329={'raw':!![],'where':{'id':_0x35b3a8[_0x2e9a73('0x2f')]['id']}};const _0x1b144c={};return _0x1b144c[_0x2e9a73('0x12')]=_[_0x2e9a73('0x34')](db['SquareMessage']['rawAttributes']),_0x1b144c[_0x2e9a73('0x15')]=_[_0x2e9a73('0x34')](_0x35b3a8['query']),_0x1b144c[_0x2e9a73('0x2a')]=_['intersection'](_0x1b144c[_0x2e9a73('0x12')],_0x1b144c[_0x2e9a73('0x15')]),_0x175329[_0x2e9a73('0x11')]=_[_0x2e9a73('0x30')](_0x1b144c[_0x2e9a73('0x12')],qs[_0x2e9a73('0x26')](_0x35b3a8['query'][_0x2e9a73('0x26')])),_0x175329['attributes']=_0x175329['attributes'][_0x2e9a73('0x14')]?_0x175329[_0x2e9a73('0x11')]:_0x1b144c['model'],_0x35b3a8[_0x2e9a73('0x15')][_0x2e9a73('0x3')]&&(_0x175329[_0x2e9a73('0x13')]=[{'all':!![]}]),_0x175329=_['merge']({},_0x175329,_0x35b3a8[_0x2e9a73('0xe')]),db[_0x2e9a73('0x2c')][_0x2e9a73('0x2d')](_0x175329)['then'](handleEntityNotFound(_0x362be5,null))[_0x2e9a73('0xf')](respondWithResult(_0x362be5,null))['catch'](handleError(_0x362be5,null));},exports[_0x5e129a('0x5')]=function(_0x13b53b,_0x4c23be){const _0x18234a=_0x5e129a;return db[_0x18234a('0x2c')]['create'](_0x13b53b['body'],{})[_0x18234a('0xf')](respondWithResult(_0x4c23be,0xc9))[_0x18234a('0x23')](handleError(_0x4c23be,null));},exports[_0x5e129a('0x2')]=function(_0x5b512d,_0x526b26){const _0xb5010e=_0x5e129a;return _0x5b512d[_0xb5010e('0xa')]['id']&&delete _0x5b512d[_0xb5010e('0xa')]['id'],db[_0xb5010e('0x2c')][_0xb5010e('0x2d')]({'where':{'id':_0x5b512d['params']['id']}})['then'](handleEntityNotFound(_0x526b26,null))[_0xb5010e('0xf')](saveUpdates(_0x5b512d['body'],null))[_0xb5010e('0xf')](respondWithResult(_0x526b26,null))[_0xb5010e('0x23')](handleError(_0x526b26,null));},exports['destroy']=function(_0x376cf9,_0x571c1f){const _0x44aad2=_0x5e129a;return db[_0x44aad2('0x2c')][_0x44aad2('0x2d')]({'where':{'id':_0x376cf9[_0x44aad2('0x2f')]['id']}})[_0x44aad2('0xf')](handleEntityNotFound(_0x571c1f,null))[_0x44aad2('0xf')](removeEntity(_0x571c1f,null))[_0x44aad2('0x23')](handleError(_0x571c1f,null));};