84b9a2032ad0278ee04ee072e91ea0cf4ed75dde
[motion-next.git] / server / api / intFreshsalesConfiguration / intFreshsalesConfiguration.controller.js
1 const a273_0x4a16=['nolimit','Content-Range','getDescriptions','api','filter','create','index','send','where','sequelize','include','map','FreshsalesField','undefined','catch','query','fields','limit','lodash','fieldName','set','sendStatus','like','json','../../config/logger','attributes','body','update','getFields','includeAll','intersection','then','name','merge','rawAttributes','filters','length','FreshsalesConfiguration','status','destroy','type','pick','options','offset','stack','findAll','count','model','getSubjects','findOne','keys','params','order','sort'];(function(_0x1c0097,_0x4a16e9){const _0x1f5f56=function(_0x278088){while(--_0x278088){_0x1c0097['push'](_0x1c0097['shift']());}};_0x1f5f56(++_0x4a16e9);}(a273_0x4a16,0xc9));const a273_0x1f5f=function(_0x1c0097,_0x4a16e9){_0x1c0097=_0x1c0097-0x0;let _0x1f5f56=a273_0x4a16[_0x1c0097];return _0x1f5f56;};const _0x5fedfb=a273_0x1f5f;'use strict';const _=require(_0x5fedfb('0x21')),qs=require('../../components/parsers/qs'),logger=require(_0x5fedfb('0x27'))(_0x5fedfb('0x12')),db=require('../../mysqldb')['db'],{Op}=require(_0x5fedfb('0x18'));function respondWithResult(_0x278088,_0x5b94f0){return _0x5b94f0=_0x5b94f0||0xc8,function(_0x1a98f4){const _0x246d15=a273_0x1f5f;if(_0x1a98f4)return _0x278088[_0x246d15('0x35')](_0x5b94f0)[_0x246d15('0x26')](_0x1a98f4);};}function respondWithFilteredResult(_0x24a068,_0x2893ec){return function(_0x454b3c){const _0x5c2e49=a273_0x1f5f;if(_0x454b3c){const _0x5d7785=_0x454b3c[_0x5c2e49('0x7')],_0x15154a=_0x2893ec[_0x5c2e49('0x4')];let _0x58aa79=_0x2893ec['offset']+_0x2893ec[_0x5c2e49('0x20')],_0x10a2e1;return _0x58aa79>=_0x5d7785?(_0x58aa79=_0x5d7785,_0x10a2e1=0xc8):_0x10a2e1=0xce,_0x24a068[_0x5c2e49('0x35')](_0x10a2e1),_0x24a068[_0x5c2e49('0x23')](_0x5c2e49('0x10'),_0x15154a+'-'+_0x58aa79+'/'+_0x5d7785)['json'](_0x454b3c);}return null;};}function saveUpdates(_0x1bc854){return function(_0x35a89c){const _0x456872=a273_0x1f5f;if(_0x35a89c)return _0x35a89c['update'](_0x1bc854)[_0x456872('0x2e')](function(_0x572425){return _0x572425;});return null;};}function removeEntity(_0xba3dcf){return function(_0x2630a4){const _0x48a562=a273_0x1f5f;if(_0x2630a4)return _0x2630a4[_0x48a562('0x0')]()['then'](function(){const _0x221004=_0x48a562;_0xba3dcf[_0x221004('0x35')](0xcc)['end']();});};}function handleEntityNotFound(_0x41236e){return function(_0x45fdd5){const _0x2b12de=a273_0x1f5f;return!_0x45fdd5&&_0x41236e[_0x2b12de('0x24')](0x194),_0x45fdd5;};}function handleError(_0x407980,_0x49648d){return _0x49648d=_0x49648d||0x1f4,function(_0x369106){const _0x2e6203=a273_0x1f5f;logger['error'](_0x369106[_0x2e6203('0x5')]),_0x369106[_0x2e6203('0x2f')]&&delete _0x369106[_0x2e6203('0x2f')],_0x407980[_0x2e6203('0x35')](_0x49648d)[_0x2e6203('0x16')](_0x369106);};}exports[_0x5fedfb('0x15')]=function(_0x1dbd94,_0x5854bd){const _0x3d021f=_0x5fedfb;let _0x37d1d9={};const _0x1448cc={},_0x4fd884={'count':0x0,'rows':[]},_0x4ced72=_[_0x3d021f('0x1a')](db[_0x3d021f('0x34')]['rawAttributes'],function(_0x1aed35){const _0x2440c4=_0x3d021f;return{'name':_0x1aed35[_0x2440c4('0x22')],'type':_0x1aed35[_0x2440c4('0x1')]['key']};});_0x1448cc[_0x3d021f('0x8')]=_[_0x3d021f('0x1a')](_0x4ced72,_0x3d021f('0x2f')),_0x1448cc['query']=_[_0x3d021f('0xb')](_0x1dbd94[_0x3d021f('0x1e')]),_0x1448cc[_0x3d021f('0x32')]=_[_0x3d021f('0x2d')](_0x1448cc[_0x3d021f('0x8')],_0x1448cc[_0x3d021f('0x1e')]),_0x37d1d9[_0x3d021f('0x28')]=_['intersection'](_0x1448cc[_0x3d021f('0x8')],qs[_0x3d021f('0x1f')](_0x1dbd94['query'][_0x3d021f('0x1f')])),_0x37d1d9[_0x3d021f('0x28')]=_0x37d1d9['attributes']['length']?_0x37d1d9[_0x3d021f('0x28')]:_0x1448cc[_0x3d021f('0x8')];typeof _0x1dbd94[_0x3d021f('0x1e')][_0x3d021f('0xf')]===_0x3d021f('0x1c')&&(_0x37d1d9['limit']=qs['limit'](_0x1dbd94[_0x3d021f('0x1e')][_0x3d021f('0x20')]),_0x37d1d9['offset']=qs[_0x3d021f('0x4')](_0x1dbd94[_0x3d021f('0x1e')][_0x3d021f('0x4')]));_0x37d1d9[_0x3d021f('0xd')]=qs[_0x3d021f('0xe')](_0x1dbd94[_0x3d021f('0x1e')][_0x3d021f('0xe')]),_0x37d1d9[_0x3d021f('0x17')]=qs[_0x3d021f('0x32')](_[_0x3d021f('0x2')](_0x1dbd94[_0x3d021f('0x1e')],_0x1448cc[_0x3d021f('0x32')]),_0x4ced72);_0x1dbd94['query'][_0x3d021f('0x13')]&&(_0x37d1d9['where']=_[_0x3d021f('0x30')](_0x37d1d9['where'],{[Op['or']]:_[_0x3d021f('0x1a')](_0x4ced72,function(_0x88cef){const _0x252d45=_0x3d021f;if(_0x88cef[_0x252d45('0x1')]!=='VIRTUAL'){const _0x3b7079={};return _0x3b7079[_0x88cef[_0x252d45('0x2f')]]={[Op[_0x252d45('0x25')]]:'%'+_0x1dbd94[_0x252d45('0x1e')][_0x252d45('0x13')]+'%'},_0x3b7079;}})}));_0x37d1d9=_[_0x3d021f('0x30')]({},_0x37d1d9,_0x1dbd94[_0x3d021f('0x3')]);const _0x3848ef={'where':_0x37d1d9['where']};return db[_0x3d021f('0x34')][_0x3d021f('0x7')](_0x3848ef)[_0x3d021f('0x2e')](function(_0x394651){const _0x1fc685=_0x3d021f;return _0x4fd884['count']=_0x394651,_0x1dbd94[_0x1fc685('0x1e')][_0x1fc685('0x2c')]&&(_0x37d1d9[_0x1fc685('0x19')]=[{'all':!![]}]),db[_0x1fc685('0x34')][_0x1fc685('0x6')](_0x37d1d9);})[_0x3d021f('0x2e')](function(_0x543ab1){return _0x4fd884['rows']=_0x543ab1,_0x4fd884;})['then'](respondWithFilteredResult(_0x5854bd,_0x37d1d9))['catch'](handleError(_0x5854bd,null));},exports['show']=function(_0x1803ec,_0x4edf31){const _0x47d730=_0x5fedfb;let _0x492429={'raw':![],'where':{'id':_0x1803ec[_0x47d730('0xc')]['id']}};const _0x2d1f4f={};return _0x2d1f4f['model']=_[_0x47d730('0xb')](db[_0x47d730('0x34')][_0x47d730('0x31')]),_0x2d1f4f[_0x47d730('0x1e')]=_[_0x47d730('0xb')](_0x1803ec['query']),_0x2d1f4f[_0x47d730('0x32')]=_[_0x47d730('0x2d')](_0x2d1f4f['model'],_0x2d1f4f['query']),_0x492429['attributes']=_['intersection'](_0x2d1f4f['model'],qs[_0x47d730('0x1f')](_0x1803ec[_0x47d730('0x1e')][_0x47d730('0x1f')])),_0x492429[_0x47d730('0x28')]=_0x492429[_0x47d730('0x28')][_0x47d730('0x33')]?_0x492429[_0x47d730('0x28')]:_0x2d1f4f[_0x47d730('0x8')],_0x1803ec[_0x47d730('0x1e')][_0x47d730('0x2c')]&&(_0x492429[_0x47d730('0x19')]=[{'all':!![]}]),_0x492429=_[_0x47d730('0x30')]({},_0x492429,_0x1803ec[_0x47d730('0x3')]),db[_0x47d730('0x34')][_0x47d730('0xa')](_0x492429)[_0x47d730('0x2e')](handleEntityNotFound(_0x4edf31,null))[_0x47d730('0x2e')](respondWithResult(_0x4edf31,null))[_0x47d730('0x1d')](handleError(_0x4edf31,null));},exports[_0x5fedfb('0x14')]=function(_0x4b4670,_0x312be3){const _0x5ae828=_0x5fedfb;return db[_0x5ae828('0x34')][_0x5ae828('0x14')](_0x4b4670[_0x5ae828('0x29')],{})[_0x5ae828('0x2e')](respondWithResult(_0x312be3,0xc9))[_0x5ae828('0x1d')](handleError(_0x312be3,null));},exports[_0x5fedfb('0x2a')]=function(_0x553045,_0x15246b){const _0x4340fd=_0x5fedfb;return _0x553045[_0x4340fd('0x29')]['id']&&delete _0x553045[_0x4340fd('0x29')]['id'],db['FreshsalesConfiguration'][_0x4340fd('0xa')]({'where':{'id':_0x553045[_0x4340fd('0xc')]['id']}})[_0x4340fd('0x2e')](handleEntityNotFound(_0x15246b,null))['then'](saveUpdates(_0x553045[_0x4340fd('0x29')],null))[_0x4340fd('0x2e')](respondWithResult(_0x15246b,null))['catch'](handleError(_0x15246b,null));},exports[_0x5fedfb('0x0')]=function(_0x382b71,_0x3b0aab){const _0x5d0ee9=_0x5fedfb;return db[_0x5d0ee9('0x34')]['findOne']({'where':{'id':_0x382b71[_0x5d0ee9('0xc')]['id']}})[_0x5d0ee9('0x2e')](handleEntityNotFound(_0x3b0aab,null))[_0x5d0ee9('0x2e')](removeEntity(_0x3b0aab,null))[_0x5d0ee9('0x1d')](handleError(_0x3b0aab,null));},exports[_0x5fedfb('0x9')]=function(_0x842309,_0x744072){const _0x106aec=_0x5fedfb;let _0x3967c8={};const _0x4dde3e={};let _0x386c95,_0x36fd0d;return db[_0x106aec('0x34')]['findOne']({'where':{'id':_0x842309['params']['id']}})['then'](handleEntityNotFound(_0x744072,null))[_0x106aec('0x2e')](function(_0x57d19a){const _0xb035dd=_0x106aec;if(_0x57d19a)return _0x386c95=_0x57d19a,_0x4dde3e[_0xb035dd('0x8')]=_[_0xb035dd('0xb')](db[_0xb035dd('0x1b')][_0xb035dd('0x31')]),_0x4dde3e['query']=_[_0xb035dd('0xb')](_0x842309[_0xb035dd('0x1e')]),_0x4dde3e[_0xb035dd('0x32')]=_[_0xb035dd('0x2d')](_0x4dde3e['model'],_0x4dde3e[_0xb035dd('0x1e')]),_0x3967c8['attributes']=_[_0xb035dd('0x2d')](_0x4dde3e[_0xb035dd('0x8')],qs[_0xb035dd('0x1f')](_0x842309['query']['fields'])),_0x3967c8['attributes']=_0x3967c8[_0xb035dd('0x28')][_0xb035dd('0x33')]?_0x3967c8[_0xb035dd('0x28')]:_0x4dde3e[_0xb035dd('0x8')],_0x3967c8[_0xb035dd('0xd')]=qs[_0xb035dd('0xe')](_0x842309[_0xb035dd('0x1e')][_0xb035dd('0xe')]),_0x3967c8[_0xb035dd('0x17')]=qs[_0xb035dd('0x32')](_[_0xb035dd('0x2')](_0x842309[_0xb035dd('0x1e')],_0x4dde3e[_0xb035dd('0x32')])),_0x842309[_0xb035dd('0x1e')][_0xb035dd('0x13')]&&(_0x3967c8['where']=_[_0xb035dd('0x30')](_0x3967c8[_0xb035dd('0x17')],{[Op['or']]:_['map'](_0x3967c8['attributes'],function(_0x43f164){const _0x5ea4ce=_0xb035dd,_0x4ec0ad={};return _0x4ec0ad[_0x43f164]={[Op['like']]:'%'+_0x842309[_0x5ea4ce('0x1e')]['filter']+'%'},_0x4ec0ad;})})),_0x3967c8=_['merge']({},_0x3967c8,_0x842309[_0xb035dd('0x3')]),_0x386c95['getSubjects'](_0x3967c8);})[_0x106aec('0x2e')](function(_0x3eb3af){const _0x58545d=_0x106aec;if(_0x3eb3af)return _0x36fd0d=_0x3eb3af[_0x58545d('0x33')],typeof _0x842309['query'][_0x58545d('0xf')]===_0x58545d('0x1c')&&(_0x3967c8[_0x58545d('0x20')]=qs[_0x58545d('0x20')](_0x842309['query'][_0x58545d('0x20')]),_0x3967c8['offset']=qs[_0x58545d('0x4')](_0x842309[_0x58545d('0x1e')][_0x58545d('0x4')])),_0x386c95[_0x58545d('0x9')](_0x3967c8);})[_0x106aec('0x2e')](function(_0x311bfb){if(_0x311bfb)return _0x311bfb?{'count':_0x36fd0d,'rows':_0x311bfb}:null;})[_0x106aec('0x2e')](respondWithResult(_0x744072,null))[_0x106aec('0x1d')](handleError(_0x744072,null));},exports[_0x5fedfb('0x11')]=function(_0x218339,_0x5ce136){const _0x335a6a=_0x5fedfb;let _0x51e144={};const _0x2f3f12={};let _0x1b6a38,_0x3f5284;return db[_0x335a6a('0x34')][_0x335a6a('0xa')]({'where':{'id':_0x218339['params']['id']}})[_0x335a6a('0x2e')](handleEntityNotFound(_0x5ce136,null))[_0x335a6a('0x2e')](function(_0x3588d4){const _0x153b29=_0x335a6a;if(_0x3588d4)return _0x1b6a38=_0x3588d4,_0x2f3f12[_0x153b29('0x8')]=_[_0x153b29('0xb')](db['FreshsalesField'][_0x153b29('0x31')]),_0x2f3f12[_0x153b29('0x1e')]=_['keys'](_0x218339[_0x153b29('0x1e')]),_0x2f3f12[_0x153b29('0x32')]=_[_0x153b29('0x2d')](_0x2f3f12[_0x153b29('0x8')],_0x2f3f12[_0x153b29('0x1e')]),_0x51e144[_0x153b29('0x28')]=_[_0x153b29('0x2d')](_0x2f3f12[_0x153b29('0x8')],qs[_0x153b29('0x1f')](_0x218339['query'][_0x153b29('0x1f')])),_0x51e144[_0x153b29('0x28')]=_0x51e144[_0x153b29('0x28')][_0x153b29('0x33')]?_0x51e144[_0x153b29('0x28')]:_0x2f3f12[_0x153b29('0x8')],_0x51e144[_0x153b29('0xd')]=qs[_0x153b29('0xe')](_0x218339[_0x153b29('0x1e')][_0x153b29('0xe')]),_0x51e144[_0x153b29('0x17')]=qs['filters'](_[_0x153b29('0x2')](_0x218339[_0x153b29('0x1e')],_0x2f3f12['filters'])),_0x218339[_0x153b29('0x1e')]['filter']&&(_0x51e144['where']=_[_0x153b29('0x30')](_0x51e144[_0x153b29('0x17')],{[Op['or']]:_[_0x153b29('0x1a')](_0x51e144[_0x153b29('0x28')],function(_0x305e2d){const _0x496b57={};return _0x496b57[_0x305e2d]={[Op['like']]:'%'+_0x218339['query']['filter']+'%'},_0x496b57;})})),_0x51e144=_[_0x153b29('0x30')]({},_0x51e144,_0x218339[_0x153b29('0x3')]),_0x1b6a38['getDescriptions'](_0x51e144);})[_0x335a6a('0x2e')](function(_0x3c45bd){const _0x59658c=_0x335a6a;if(_0x3c45bd)return _0x3f5284=_0x3c45bd[_0x59658c('0x33')],typeof _0x218339[_0x59658c('0x1e')][_0x59658c('0xf')]===_0x59658c('0x1c')&&(_0x51e144[_0x59658c('0x20')]=qs[_0x59658c('0x20')](_0x218339[_0x59658c('0x1e')][_0x59658c('0x20')]),_0x51e144[_0x59658c('0x4')]=qs[_0x59658c('0x4')](_0x218339[_0x59658c('0x1e')][_0x59658c('0x4')])),_0x1b6a38[_0x59658c('0x11')](_0x51e144);})[_0x335a6a('0x2e')](function(_0x5679f5){if(_0x5679f5)return _0x5679f5?{'count':_0x3f5284,'rows':_0x5679f5}:null;})[_0x335a6a('0x2e')](respondWithResult(_0x5ce136,null))[_0x335a6a('0x1d')](handleError(_0x5ce136,null));},exports[_0x5fedfb('0x2b')]=function(_0x5618bc,_0x1e9823){const _0x2c86f6=_0x5fedfb;let _0x410eb6={};const _0x534cb2={};let _0x29708e,_0x3e065a;return db[_0x2c86f6('0x34')][_0x2c86f6('0xa')]({'where':{'id':_0x5618bc[_0x2c86f6('0xc')]['id']}})['then'](handleEntityNotFound(_0x1e9823,null))[_0x2c86f6('0x2e')](function(_0xbe65fe){const _0x2dad8d=_0x2c86f6;if(_0xbe65fe)return _0x29708e=_0xbe65fe,_0x534cb2[_0x2dad8d('0x8')]=_['keys'](db[_0x2dad8d('0x1b')][_0x2dad8d('0x31')]),_0x534cb2[_0x2dad8d('0x1e')]=_['keys'](_0x5618bc['query']),_0x534cb2[_0x2dad8d('0x32')]=_[_0x2dad8d('0x2d')](_0x534cb2['model'],_0x534cb2[_0x2dad8d('0x1e')]),_0x410eb6['attributes']=_[_0x2dad8d('0x2d')](_0x534cb2[_0x2dad8d('0x8')],qs[_0x2dad8d('0x1f')](_0x5618bc[_0x2dad8d('0x1e')][_0x2dad8d('0x1f')])),_0x410eb6['attributes']=_0x410eb6[_0x2dad8d('0x28')][_0x2dad8d('0x33')]?_0x410eb6[_0x2dad8d('0x28')]:_0x534cb2[_0x2dad8d('0x8')],_0x410eb6['order']=qs['sort'](_0x5618bc[_0x2dad8d('0x1e')][_0x2dad8d('0xe')]),_0x410eb6[_0x2dad8d('0x17')]=qs[_0x2dad8d('0x32')](_['pick'](_0x5618bc[_0x2dad8d('0x1e')],_0x534cb2[_0x2dad8d('0x32')])),_0x5618bc[_0x2dad8d('0x1e')]['filter']&&(_0x410eb6['where']=_[_0x2dad8d('0x30')](_0x410eb6[_0x2dad8d('0x17')],{[Op['or']]:_[_0x2dad8d('0x1a')](_0x410eb6[_0x2dad8d('0x28')],function(_0x40ad5c){const _0x9f11a4=_0x2dad8d,_0x12c7bf={};return _0x12c7bf[_0x40ad5c]={[Op[_0x9f11a4('0x25')]]:'%'+_0x5618bc[_0x9f11a4('0x1e')][_0x9f11a4('0x13')]+'%'},_0x12c7bf;})})),_0x410eb6=_[_0x2dad8d('0x30')]({},_0x410eb6,_0x5618bc[_0x2dad8d('0x3')]),_0x29708e[_0x2dad8d('0x2b')](_0x410eb6);})[_0x2c86f6('0x2e')](function(_0x390818){const _0x2e4d67=_0x2c86f6;if(_0x390818)return _0x3e065a=_0x390818['length'],typeof _0x5618bc[_0x2e4d67('0x1e')][_0x2e4d67('0xf')]==='undefined'&&(_0x410eb6[_0x2e4d67('0x20')]=qs[_0x2e4d67('0x20')](_0x5618bc[_0x2e4d67('0x1e')][_0x2e4d67('0x20')]),_0x410eb6['offset']=qs[_0x2e4d67('0x4')](_0x5618bc['query'][_0x2e4d67('0x4')])),_0x29708e['getFields'](_0x410eb6);})[_0x2c86f6('0x2e')](function(_0x292e85){if(_0x292e85)return _0x292e85?{'count':_0x3e065a,'rows':_0x292e85}:null;})[_0x2c86f6('0x2e')](respondWithResult(_0x1e9823,null))[_0x2c86f6('0x1d')](handleError(_0x1e9823,null));};