9fd07e69e8e87491e2127f73ec9aff2039dbe4b4
[motion-next.git] / server / api / intFreshsalesField / intFreshsalesField.controller.js
1 const a277_0x4ac0=['sequelize','filter','query','error','key','nolimit','filters','include','then','length','params','index','create','model','rawAttributes','FreshsalesField','undefined','name','status','VIRTUAL','count','json','end','../../components/parsers/qs','sort','../../mysqldb','intersection','merge','options','fieldName','lodash','pick','catch','stack','set','rows','includeAll','body','api','order','attributes','map','fields','update','Content-Range','like','keys','type','where','findOne','limit','findAll','offset'];(function(_0x465f33,_0x4ac03d){const _0x1ff3f0=function(_0x2dd090){while(--_0x2dd090){_0x465f33['push'](_0x465f33['shift']());}};_0x1ff3f0(++_0x4ac03d);}(a277_0x4ac0,0x18b));const a277_0x1ff3=function(_0x465f33,_0x4ac03d){_0x465f33=_0x465f33-0x0;let _0x1ff3f0=a277_0x4ac0[_0x465f33];return _0x1ff3f0;};const _0x1d337e=a277_0x1ff3;'use strict';const _=require(_0x1d337e('0x6')),qs=require(_0x1d337e('0x34')),logger=require('../../config/logger')(_0x1d337e('0xe')),db=require(_0x1d337e('0x1'))['db'],{Op}=require(_0x1d337e('0x1d'));function respondWithResult(_0x2dd090,_0x1a2e27){return _0x1a2e27=_0x1a2e27||0xc8,function(_0x2deed9){const _0x1844e0=a277_0x1ff3;if(_0x2deed9)return _0x2dd090[_0x1844e0('0x2f')](_0x1a2e27)[_0x1844e0('0x32')](_0x2deed9);};}function respondWithFilteredResult(_0x351979,_0x485064){return function(_0x388079){const _0x3e2e6a=a277_0x1ff3;if(_0x388079){const _0x22426d=_0x388079[_0x3e2e6a('0x31')],_0x5cdf7c=_0x485064[_0x3e2e6a('0x1c')];let _0x5d5c48=_0x485064[_0x3e2e6a('0x1c')]+_0x485064[_0x3e2e6a('0x1a')],_0x5c9273;return _0x5d5c48>=_0x22426d?(_0x5d5c48=_0x22426d,_0x5c9273=0xc8):_0x5c9273=0xce,_0x351979[_0x3e2e6a('0x2f')](_0x5c9273),_0x351979[_0x3e2e6a('0xa')](_0x3e2e6a('0x14'),_0x5cdf7c+'-'+_0x5d5c48+'/'+_0x22426d)['json'](_0x388079);}return null;};}function saveUpdates(_0x5afd29){return function(_0x2b13f2){const _0x5dd315=a277_0x1ff3;if(_0x2b13f2)return _0x2b13f2['update'](_0x5afd29)[_0x5dd315('0x25')](function(_0x36cb2f){return _0x36cb2f;});return null;};}function removeEntity(_0x5a914b){return function(_0x3d2fb3){const _0x4da8ac=a277_0x1ff3;if(_0x3d2fb3)return _0x3d2fb3['destroy']()[_0x4da8ac('0x25')](function(){const _0xeaa73e=_0x4da8ac;_0x5a914b['status'](0xcc)[_0xeaa73e('0x33')]();});};}function handleEntityNotFound(_0x4e1907){return function(_0x489838){return!_0x489838&&_0x4e1907['sendStatus'](0x194),_0x489838;};}function handleError(_0x5cca4b,_0x31971b){return _0x31971b=_0x31971b||0x1f4,function(_0x377b51){const _0x5bfb08=a277_0x1ff3;logger[_0x5bfb08('0x20')](_0x377b51[_0x5bfb08('0x9')]),_0x377b51['name']&&delete _0x377b51['name'],_0x5cca4b[_0x5bfb08('0x2f')](_0x31971b)['send'](_0x377b51);};}exports[_0x1d337e('0x28')]=function(_0x40a569,_0x20dfe6){const _0x25dff2=_0x1d337e;let _0x12d7ba={};const _0x4e68ec={},_0x302789={'count':0x0,'rows':[]},_0x28a47f=_[_0x25dff2('0x11')](db[_0x25dff2('0x2c')][_0x25dff2('0x2b')],function(_0x3090ef){const _0x4b1faa=_0x25dff2;return{'name':_0x3090ef[_0x4b1faa('0x5')],'type':_0x3090ef[_0x4b1faa('0x17')][_0x4b1faa('0x21')]};});_0x4e68ec[_0x25dff2('0x2a')]=_['map'](_0x28a47f,_0x25dff2('0x2e')),_0x4e68ec[_0x25dff2('0x1f')]=_['keys'](_0x40a569[_0x25dff2('0x1f')]),_0x4e68ec[_0x25dff2('0x23')]=_['intersection'](_0x4e68ec['model'],_0x4e68ec[_0x25dff2('0x1f')]),_0x12d7ba[_0x25dff2('0x10')]=_[_0x25dff2('0x2')](_0x4e68ec[_0x25dff2('0x2a')],qs[_0x25dff2('0x12')](_0x40a569[_0x25dff2('0x1f')][_0x25dff2('0x12')])),_0x12d7ba[_0x25dff2('0x10')]=_0x12d7ba[_0x25dff2('0x10')][_0x25dff2('0x26')]?_0x12d7ba['attributes']:_0x4e68ec[_0x25dff2('0x2a')];typeof _0x40a569['query'][_0x25dff2('0x22')]===_0x25dff2('0x2d')&&(_0x12d7ba[_0x25dff2('0x1a')]=qs[_0x25dff2('0x1a')](_0x40a569[_0x25dff2('0x1f')][_0x25dff2('0x1a')]),_0x12d7ba[_0x25dff2('0x1c')]=qs[_0x25dff2('0x1c')](_0x40a569[_0x25dff2('0x1f')][_0x25dff2('0x1c')]));_0x12d7ba[_0x25dff2('0xf')]=qs[_0x25dff2('0x0')](_0x40a569['query'][_0x25dff2('0x0')]),_0x12d7ba['where']=qs[_0x25dff2('0x23')](_[_0x25dff2('0x7')](_0x40a569[_0x25dff2('0x1f')],_0x4e68ec[_0x25dff2('0x23')]),_0x28a47f);_0x40a569['query'][_0x25dff2('0x1e')]&&(_0x12d7ba[_0x25dff2('0x18')]=_['merge'](_0x12d7ba['where'],{[Op['or']]:_['map'](_0x28a47f,function(_0x2fee0c){const _0x42b4af=_0x25dff2;if(_0x2fee0c['type']!==_0x42b4af('0x30')){const _0x587952={};return _0x587952[_0x2fee0c[_0x42b4af('0x2e')]]={[Op[_0x42b4af('0x15')]]:'%'+_0x40a569[_0x42b4af('0x1f')][_0x42b4af('0x1e')]+'%'},_0x587952;}})}));_0x12d7ba=_[_0x25dff2('0x3')]({},_0x12d7ba,_0x40a569['options']);const _0x101c1f={'where':_0x12d7ba[_0x25dff2('0x18')]};return db[_0x25dff2('0x2c')][_0x25dff2('0x31')](_0x101c1f)[_0x25dff2('0x25')](function(_0x1df0c5){const _0x26d399=_0x25dff2;return _0x302789[_0x26d399('0x31')]=_0x1df0c5,_0x40a569[_0x26d399('0x1f')][_0x26d399('0xc')]&&(_0x12d7ba[_0x26d399('0x24')]=[{'all':!![]}]),db['FreshsalesField'][_0x26d399('0x1b')](_0x12d7ba);})['then'](function(_0x5bcede){const _0x2fa94d=_0x25dff2;return _0x302789[_0x2fa94d('0xb')]=_0x5bcede,_0x302789;})[_0x25dff2('0x25')](respondWithFilteredResult(_0x20dfe6,_0x12d7ba))[_0x25dff2('0x8')](handleError(_0x20dfe6,null));},exports['show']=function(_0x49777f,_0x1dc4fc){const _0x2e1470=_0x1d337e;let _0x241a32={'raw':!![],'where':{'id':_0x49777f[_0x2e1470('0x27')]['id']}};const _0x4948e7={};return _0x4948e7['model']=_[_0x2e1470('0x16')](db[_0x2e1470('0x2c')][_0x2e1470('0x2b')]),_0x4948e7[_0x2e1470('0x1f')]=_[_0x2e1470('0x16')](_0x49777f['query']),_0x4948e7['filters']=_[_0x2e1470('0x2')](_0x4948e7[_0x2e1470('0x2a')],_0x4948e7[_0x2e1470('0x1f')]),_0x241a32['attributes']=_[_0x2e1470('0x2')](_0x4948e7[_0x2e1470('0x2a')],qs['fields'](_0x49777f[_0x2e1470('0x1f')][_0x2e1470('0x12')])),_0x241a32[_0x2e1470('0x10')]=_0x241a32[_0x2e1470('0x10')]['length']?_0x241a32[_0x2e1470('0x10')]:_0x4948e7[_0x2e1470('0x2a')],_0x49777f[_0x2e1470('0x1f')]['includeAll']&&(_0x241a32['include']=[{'all':!![]}]),_0x241a32=_[_0x2e1470('0x3')]({},_0x241a32,_0x49777f[_0x2e1470('0x4')]),db[_0x2e1470('0x2c')][_0x2e1470('0x19')](_0x241a32)[_0x2e1470('0x25')](handleEntityNotFound(_0x1dc4fc,null))['then'](respondWithResult(_0x1dc4fc,null))[_0x2e1470('0x8')](handleError(_0x1dc4fc,null));},exports[_0x1d337e('0x29')]=function(_0x2c4736,_0x1816b4){const _0x1e78ae=_0x1d337e;return db[_0x1e78ae('0x2c')]['create'](_0x2c4736[_0x1e78ae('0xd')],{})[_0x1e78ae('0x25')](respondWithResult(_0x1816b4,0xc9))['catch'](handleError(_0x1816b4,null));},exports[_0x1d337e('0x13')]=function(_0x3df7d9,_0x2e1545){const _0x478f05=_0x1d337e;return _0x3df7d9[_0x478f05('0xd')]['id']&&delete _0x3df7d9['body']['id'],db[_0x478f05('0x2c')][_0x478f05('0x19')]({'where':{'id':_0x3df7d9['params']['id']}})[_0x478f05('0x25')](handleEntityNotFound(_0x2e1545,null))[_0x478f05('0x25')](saveUpdates(_0x3df7d9[_0x478f05('0xd')],null))[_0x478f05('0x25')](respondWithResult(_0x2e1545,null))[_0x478f05('0x8')](handleError(_0x2e1545,null));},exports['destroy']=function(_0x1d97fe,_0x29fda5){const _0x354167=_0x1d337e;return db[_0x354167('0x2c')][_0x354167('0x19')]({'where':{'id':_0x1d97fe[_0x354167('0x27')]['id']}})[_0x354167('0x25')](handleEntityNotFound(_0x29fda5,null))[_0x354167('0x25')](removeEntity(_0x29fda5,null))[_0x354167('0x8')](handleError(_0x29fda5,null));};