683f0d7a8ae04df8d82e51c73b6a9b2eb92a4c19
[motion-next.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
1 const a312_0x5f1e=['pick','filters','offset','body','index','create','where','map','json','params','type','sort','SugarcrmField','VIRTUAL','rows','intersection','model','../../mysqldb','sequelize','like','SugarcrmConfiguration','order','status','end','includeAll','update','show','getFields','error','../../config/logger','catch','filter','length','options','undefined','getDescriptions','query','attributes','limit','sendStatus','count','stack','then','name','getSubjects','findOne','fieldName','destroy','merge','lodash','nolimit','keys','fields','rawAttributes','send'];(function(_0xd35702,_0x5f1e67){const _0x4eb9af=function(_0x376efa){while(--_0x376efa){_0xd35702['push'](_0xd35702['shift']());}};_0x4eb9af(++_0x5f1e67);}(a312_0x5f1e,0x1dc));const a312_0x4eb9=function(_0xd35702,_0x5f1e67){_0xd35702=_0xd35702-0x0;let _0x4eb9af=a312_0x5f1e[_0xd35702];return _0x4eb9af;};const _0x308f00=a312_0x4eb9;'use strict';const _=require(_0x308f00('0xd')),qs=require('../../components/parsers/qs'),logger=require(_0x308f00('0x30'))('api'),db=require(_0x308f00('0x24'))['db'],{Op}=require(_0x308f00('0x25'));function respondWithResult(_0x376efa,_0x5b02aa){return _0x5b02aa=_0x5b02aa||0xc8,function(_0x5aad59){const _0x3a0247=a312_0x4eb9;if(_0x5aad59)return _0x376efa[_0x3a0247('0x29')](_0x5b02aa)[_0x3a0247('0x1b')](_0x5aad59);};}function respondWithFilteredResult(_0x3f5d5d,_0x4630dd){return function(_0x264cb7){const _0x83d81b=a312_0x4eb9;if(_0x264cb7){const _0x50eaef=_0x264cb7['count'],_0x2ec810=_0x4630dd[_0x83d81b('0x15')];let _0x5008cf=_0x4630dd[_0x83d81b('0x15')]+_0x4630dd[_0x83d81b('0x2')],_0x4b0725;return _0x5008cf>=_0x50eaef?(_0x5008cf=_0x50eaef,_0x4b0725=0xc8):_0x4b0725=0xce,_0x3f5d5d['status'](_0x4b0725),_0x3f5d5d['set']('Content-Range',_0x2ec810+'-'+_0x5008cf+'/'+_0x50eaef)[_0x83d81b('0x1b')](_0x264cb7);}return null;};}function saveUpdates(_0xe9cec8){return function(_0x51a8d0){const _0x1a77cb=a312_0x4eb9;if(_0x51a8d0)return _0x51a8d0[_0x1a77cb('0x2c')](_0xe9cec8)[_0x1a77cb('0x6')](function(_0x110e74){return _0x110e74;});return null;};}function removeEntity(_0x30457a){return function(_0x3746c6){const _0x3f6fd3=a312_0x4eb9;if(_0x3746c6)return _0x3746c6[_0x3f6fd3('0xb')]()[_0x3f6fd3('0x6')](function(){const _0x2cdfa9=_0x3f6fd3;_0x30457a[_0x2cdfa9('0x29')](0xcc)[_0x2cdfa9('0x2a')]();});};}function handleEntityNotFound(_0x28baf9){return function(_0x4f6182){const _0x4482f7=a312_0x4eb9;return!_0x4f6182&&_0x28baf9[_0x4482f7('0x3')](0x194),_0x4f6182;};}function handleError(_0x66d5a7,_0x1fcb40){return _0x1fcb40=_0x1fcb40||0x1f4,function(_0xf3df4e){const _0x511d0d=a312_0x4eb9;logger[_0x511d0d('0x2f')](_0xf3df4e[_0x511d0d('0x5')]),_0xf3df4e[_0x511d0d('0x7')]&&delete _0xf3df4e[_0x511d0d('0x7')],_0x66d5a7[_0x511d0d('0x29')](_0x1fcb40)[_0x511d0d('0x12')](_0xf3df4e);};}exports[_0x308f00('0x17')]=function(_0x58561f,_0x17185d){const _0x358503=_0x308f00;let _0x556680={};const _0x3c1092={},_0x34cd67={'count':0x0,'rows':[]},_0xf130b=_[_0x358503('0x1a')](db[_0x358503('0x27')][_0x358503('0x11')],function(_0x4dc7de){const _0x3bcf95=_0x358503;return{'name':_0x4dc7de[_0x3bcf95('0xa')],'type':_0x4dc7de[_0x3bcf95('0x1d')]['key']};});_0x3c1092[_0x358503('0x23')]=_[_0x358503('0x1a')](_0xf130b,_0x358503('0x7')),_0x3c1092[_0x358503('0x0')]=_[_0x358503('0xf')](_0x58561f['query']),_0x3c1092[_0x358503('0x14')]=_[_0x358503('0x22')](_0x3c1092[_0x358503('0x23')],_0x3c1092[_0x358503('0x0')]),_0x556680[_0x358503('0x1')]=_[_0x358503('0x22')](_0x3c1092['model'],qs['fields'](_0x58561f['query'][_0x358503('0x10')])),_0x556680[_0x358503('0x1')]=_0x556680[_0x358503('0x1')][_0x358503('0x33')]?_0x556680[_0x358503('0x1')]:_0x3c1092[_0x358503('0x23')];typeof _0x58561f[_0x358503('0x0')][_0x358503('0xe')]===_0x358503('0x35')&&(_0x556680[_0x358503('0x2')]=qs[_0x358503('0x2')](_0x58561f['query'][_0x358503('0x2')]),_0x556680['offset']=qs['offset'](_0x58561f[_0x358503('0x0')][_0x358503('0x15')]));_0x556680[_0x358503('0x28')]=qs[_0x358503('0x1e')](_0x58561f['query'][_0x358503('0x1e')]),_0x556680[_0x358503('0x19')]=qs[_0x358503('0x14')](_['pick'](_0x58561f[_0x358503('0x0')],_0x3c1092[_0x358503('0x14')]),_0xf130b);_0x58561f[_0x358503('0x0')][_0x358503('0x32')]&&(_0x556680[_0x358503('0x19')]=_[_0x358503('0xc')](_0x556680['where'],{[Op['or']]:_[_0x358503('0x1a')](_0xf130b,function(_0x2d16f4){const _0xb1ff5a=_0x358503;if(_0x2d16f4[_0xb1ff5a('0x1d')]!==_0xb1ff5a('0x20')){const _0x1eb695={};return _0x1eb695[_0x2d16f4[_0xb1ff5a('0x7')]]={[Op[_0xb1ff5a('0x26')]]:'%'+_0x58561f[_0xb1ff5a('0x0')]['filter']+'%'},_0x1eb695;}})}));_0x556680=_[_0x358503('0xc')]({},_0x556680,_0x58561f[_0x358503('0x34')]);const _0xcc1b58={'where':_0x556680[_0x358503('0x19')]};return db[_0x358503('0x27')][_0x358503('0x4')](_0xcc1b58)[_0x358503('0x6')](function(_0x1a4d45){const _0x494806=_0x358503;return _0x34cd67[_0x494806('0x4')]=_0x1a4d45,_0x58561f['query'][_0x494806('0x2b')]&&(_0x556680['include']=[{'all':!![]}]),db['SugarcrmConfiguration']['findAll'](_0x556680);})[_0x358503('0x6')](function(_0x1fa946){const _0x11208b=_0x358503;return _0x34cd67[_0x11208b('0x21')]=_0x1fa946,_0x34cd67;})[_0x358503('0x6')](respondWithFilteredResult(_0x17185d,_0x556680))['catch'](handleError(_0x17185d,null));},exports[_0x308f00('0x2d')]=function(_0x6f361c,_0x300bd8){const _0x2bc6fb=_0x308f00;let _0x1770da={'raw':![],'where':{'id':_0x6f361c[_0x2bc6fb('0x1c')]['id']}};const _0x5f5206={};return _0x5f5206[_0x2bc6fb('0x23')]=_[_0x2bc6fb('0xf')](db[_0x2bc6fb('0x27')][_0x2bc6fb('0x11')]),_0x5f5206[_0x2bc6fb('0x0')]=_[_0x2bc6fb('0xf')](_0x6f361c[_0x2bc6fb('0x0')]),_0x5f5206['filters']=_[_0x2bc6fb('0x22')](_0x5f5206[_0x2bc6fb('0x23')],_0x5f5206[_0x2bc6fb('0x0')]),_0x1770da[_0x2bc6fb('0x1')]=_[_0x2bc6fb('0x22')](_0x5f5206[_0x2bc6fb('0x23')],qs[_0x2bc6fb('0x10')](_0x6f361c['query'][_0x2bc6fb('0x10')])),_0x1770da['attributes']=_0x1770da[_0x2bc6fb('0x1')][_0x2bc6fb('0x33')]?_0x1770da[_0x2bc6fb('0x1')]:_0x5f5206[_0x2bc6fb('0x23')],_0x6f361c[_0x2bc6fb('0x0')][_0x2bc6fb('0x2b')]&&(_0x1770da['include']=[{'all':!![]}]),_0x1770da=_[_0x2bc6fb('0xc')]({},_0x1770da,_0x6f361c[_0x2bc6fb('0x34')]),db[_0x2bc6fb('0x27')][_0x2bc6fb('0x9')](_0x1770da)[_0x2bc6fb('0x6')](handleEntityNotFound(_0x300bd8,null))[_0x2bc6fb('0x6')](respondWithResult(_0x300bd8,null))[_0x2bc6fb('0x31')](handleError(_0x300bd8,null));},exports[_0x308f00('0x18')]=function(_0x7cdd0b,_0x538667){const _0x430e65=_0x308f00;return db[_0x430e65('0x27')][_0x430e65('0x18')](_0x7cdd0b[_0x430e65('0x16')],{})[_0x430e65('0x6')](respondWithResult(_0x538667,0xc9))[_0x430e65('0x31')](handleError(_0x538667,null));},exports[_0x308f00('0x2c')]=function(_0x1e0840,_0x3c6c7b){const _0x5009f8=_0x308f00;return _0x1e0840[_0x5009f8('0x16')]['id']&&delete _0x1e0840[_0x5009f8('0x16')]['id'],db[_0x5009f8('0x27')][_0x5009f8('0x9')]({'where':{'id':_0x1e0840[_0x5009f8('0x1c')]['id']}})[_0x5009f8('0x6')](handleEntityNotFound(_0x3c6c7b,null))[_0x5009f8('0x6')](saveUpdates(_0x1e0840['body'],null))[_0x5009f8('0x6')](respondWithResult(_0x3c6c7b,null))[_0x5009f8('0x31')](handleError(_0x3c6c7b,null));},exports['destroy']=function(_0x6a3aa0,_0x2e224f){const _0x38f662=_0x308f00;return db[_0x38f662('0x27')][_0x38f662('0x9')]({'where':{'id':_0x6a3aa0['params']['id']}})[_0x38f662('0x6')](handleEntityNotFound(_0x2e224f,null))['then'](removeEntity(_0x2e224f,null))['catch'](handleError(_0x2e224f,null));},exports[_0x308f00('0x2e')]=function(_0x69cc6a,_0x5ae48b){const _0xed3b79=_0x308f00;let _0x3de7a6={};const _0x52c95c={};let _0x433dd4,_0x3e5ca0;return db[_0xed3b79('0x27')][_0xed3b79('0x9')]({'where':{'id':_0x69cc6a[_0xed3b79('0x1c')]['id']}})[_0xed3b79('0x6')](handleEntityNotFound(_0x5ae48b,null))['then'](function(_0xfa69b7){const _0x3fbf20=_0xed3b79;if(_0xfa69b7)return _0x433dd4=_0xfa69b7,_0x52c95c['model']=_['keys'](db[_0x3fbf20('0x1f')]['rawAttributes']),_0x52c95c[_0x3fbf20('0x0')]=_[_0x3fbf20('0xf')](_0x69cc6a[_0x3fbf20('0x0')]),_0x52c95c[_0x3fbf20('0x14')]=_[_0x3fbf20('0x22')](_0x52c95c['model'],_0x52c95c['query']),_0x3de7a6[_0x3fbf20('0x1')]=_[_0x3fbf20('0x22')](_0x52c95c[_0x3fbf20('0x23')],qs[_0x3fbf20('0x10')](_0x69cc6a[_0x3fbf20('0x0')][_0x3fbf20('0x10')])),_0x3de7a6[_0x3fbf20('0x1')]=_0x3de7a6[_0x3fbf20('0x1')]['length']?_0x3de7a6[_0x3fbf20('0x1')]:_0x52c95c['model'],_0x3de7a6['order']=qs[_0x3fbf20('0x1e')](_0x69cc6a[_0x3fbf20('0x0')][_0x3fbf20('0x1e')]),_0x3de7a6[_0x3fbf20('0x19')]=qs[_0x3fbf20('0x14')](_[_0x3fbf20('0x13')](_0x69cc6a[_0x3fbf20('0x0')],_0x52c95c[_0x3fbf20('0x14')])),_0x69cc6a[_0x3fbf20('0x0')][_0x3fbf20('0x32')]&&(_0x3de7a6[_0x3fbf20('0x19')]=_[_0x3fbf20('0xc')](_0x3de7a6[_0x3fbf20('0x19')],{[Op['or']]:_['map'](_0x3de7a6[_0x3fbf20('0x1')],function(_0x2908dc){const _0x45dd22=_0x3fbf20,_0x189c29={};return _0x189c29[_0x2908dc]={[Op[_0x45dd22('0x26')]]:'%'+_0x69cc6a[_0x45dd22('0x0')][_0x45dd22('0x32')]+'%'},_0x189c29;})})),_0x3de7a6=_['merge']({},_0x3de7a6,_0x69cc6a[_0x3fbf20('0x34')]),_0x433dd4[_0x3fbf20('0x2e')](_0x3de7a6);})[_0xed3b79('0x6')](function(_0x4bf170){const _0x41494b=_0xed3b79;if(_0x4bf170)return _0x3e5ca0=_0x4bf170[_0x41494b('0x33')],typeof _0x69cc6a['query']['nolimit']===_0x41494b('0x35')&&(_0x3de7a6[_0x41494b('0x2')]=qs[_0x41494b('0x2')](_0x69cc6a['query'][_0x41494b('0x2')]),_0x3de7a6[_0x41494b('0x15')]=qs[_0x41494b('0x15')](_0x69cc6a['query']['offset'])),_0x433dd4[_0x41494b('0x2e')](_0x3de7a6);})[_0xed3b79('0x6')](function(_0x40df63){if(_0x40df63)return _0x40df63?{'count':_0x3e5ca0,'rows':_0x40df63}:null;})['then'](respondWithResult(_0x5ae48b,null))['catch'](handleError(_0x5ae48b,null));},exports[_0x308f00('0x8')]=function(_0x27ef69,_0x1eaaad){const _0x4a3fb4=_0x308f00;let _0x1e6a1c={};const _0x326be6={};let _0x703cf5,_0x515eb8;return db['SugarcrmConfiguration'][_0x4a3fb4('0x9')]({'where':{'id':_0x27ef69[_0x4a3fb4('0x1c')]['id']}})['then'](handleEntityNotFound(_0x1eaaad,null))[_0x4a3fb4('0x6')](function(_0x3dcb21){const _0x2db4d2=_0x4a3fb4;if(_0x3dcb21)return _0x703cf5=_0x3dcb21,_0x326be6[_0x2db4d2('0x23')]=_['keys'](db[_0x2db4d2('0x1f')][_0x2db4d2('0x11')]),_0x326be6[_0x2db4d2('0x0')]=_[_0x2db4d2('0xf')](_0x27ef69[_0x2db4d2('0x0')]),_0x326be6[_0x2db4d2('0x14')]=_[_0x2db4d2('0x22')](_0x326be6[_0x2db4d2('0x23')],_0x326be6[_0x2db4d2('0x0')]),_0x1e6a1c['attributes']=_[_0x2db4d2('0x22')](_0x326be6[_0x2db4d2('0x23')],qs[_0x2db4d2('0x10')](_0x27ef69[_0x2db4d2('0x0')]['fields'])),_0x1e6a1c[_0x2db4d2('0x1')]=_0x1e6a1c[_0x2db4d2('0x1')][_0x2db4d2('0x33')]?_0x1e6a1c[_0x2db4d2('0x1')]:_0x326be6[_0x2db4d2('0x23')],_0x1e6a1c['order']=qs[_0x2db4d2('0x1e')](_0x27ef69[_0x2db4d2('0x0')][_0x2db4d2('0x1e')]),_0x1e6a1c[_0x2db4d2('0x19')]=qs[_0x2db4d2('0x14')](_[_0x2db4d2('0x13')](_0x27ef69[_0x2db4d2('0x0')],_0x326be6[_0x2db4d2('0x14')])),_0x27ef69[_0x2db4d2('0x0')][_0x2db4d2('0x32')]&&(_0x1e6a1c['where']=_[_0x2db4d2('0xc')](_0x1e6a1c[_0x2db4d2('0x19')],{[Op['or']]:_[_0x2db4d2('0x1a')](_0x1e6a1c[_0x2db4d2('0x1')],function(_0x33811c){const _0xc8487f=_0x2db4d2,_0x29ae85={};return _0x29ae85[_0x33811c]={[Op[_0xc8487f('0x26')]]:'%'+_0x27ef69[_0xc8487f('0x0')]['filter']+'%'},_0x29ae85;})})),_0x1e6a1c=_[_0x2db4d2('0xc')]({},_0x1e6a1c,_0x27ef69[_0x2db4d2('0x34')]),_0x703cf5[_0x2db4d2('0x8')](_0x1e6a1c);})[_0x4a3fb4('0x6')](function(_0x197593){const _0x2945f7=_0x4a3fb4;if(_0x197593)return _0x515eb8=_0x197593[_0x2945f7('0x33')],typeof _0x27ef69[_0x2945f7('0x0')][_0x2945f7('0xe')]===_0x2945f7('0x35')&&(_0x1e6a1c[_0x2945f7('0x2')]=qs['limit'](_0x27ef69[_0x2945f7('0x0')]['limit']),_0x1e6a1c['offset']=qs['offset'](_0x27ef69[_0x2945f7('0x0')][_0x2945f7('0x15')])),_0x703cf5['getSubjects'](_0x1e6a1c);})[_0x4a3fb4('0x6')](function(_0x38c679){if(_0x38c679)return _0x38c679?{'count':_0x515eb8,'rows':_0x38c679}:null;})[_0x4a3fb4('0x6')](respondWithResult(_0x1eaaad,null))[_0x4a3fb4('0x31')](handleError(_0x1eaaad,null));},exports[_0x308f00('0x36')]=function(_0x542fc1,_0x4b0108){const _0x12f56d=_0x308f00;let _0x20a0a6={};const _0x5734bc={};let _0x31118c,_0x4ee1c5;return db['SugarcrmConfiguration'][_0x12f56d('0x9')]({'where':{'id':_0x542fc1[_0x12f56d('0x1c')]['id']}})[_0x12f56d('0x6')](handleEntityNotFound(_0x4b0108,null))[_0x12f56d('0x6')](function(_0x2c28bc){const _0x1b369f=_0x12f56d;if(_0x2c28bc)return _0x31118c=_0x2c28bc,_0x5734bc[_0x1b369f('0x23')]=_[_0x1b369f('0xf')](db[_0x1b369f('0x1f')][_0x1b369f('0x11')]),_0x5734bc[_0x1b369f('0x0')]=_['keys'](_0x542fc1[_0x1b369f('0x0')]),_0x5734bc['filters']=_['intersection'](_0x5734bc[_0x1b369f('0x23')],_0x5734bc[_0x1b369f('0x0')]),_0x20a0a6[_0x1b369f('0x1')]=_[_0x1b369f('0x22')](_0x5734bc[_0x1b369f('0x23')],qs[_0x1b369f('0x10')](_0x542fc1['query']['fields'])),_0x20a0a6[_0x1b369f('0x1')]=_0x20a0a6[_0x1b369f('0x1')][_0x1b369f('0x33')]?_0x20a0a6[_0x1b369f('0x1')]:_0x5734bc['model'],_0x20a0a6[_0x1b369f('0x28')]=qs[_0x1b369f('0x1e')](_0x542fc1[_0x1b369f('0x0')][_0x1b369f('0x1e')]),_0x20a0a6[_0x1b369f('0x19')]=qs[_0x1b369f('0x14')](_[_0x1b369f('0x13')](_0x542fc1['query'],_0x5734bc[_0x1b369f('0x14')])),_0x542fc1[_0x1b369f('0x0')]['filter']&&(_0x20a0a6[_0x1b369f('0x19')]=_['merge'](_0x20a0a6[_0x1b369f('0x19')],{[Op['or']]:_[_0x1b369f('0x1a')](_0x20a0a6['attributes'],function(_0x24898d){const _0x411386=_0x1b369f,_0x1e78d1={};return _0x1e78d1[_0x24898d]={[Op[_0x411386('0x26')]]:'%'+_0x542fc1['query'][_0x411386('0x32')]+'%'},_0x1e78d1;})})),_0x20a0a6=_['merge']({},_0x20a0a6,_0x542fc1[_0x1b369f('0x34')]),_0x31118c[_0x1b369f('0x36')](_0x20a0a6);})[_0x12f56d('0x6')](function(_0x20ffa8){const _0x30b738=_0x12f56d;if(_0x20ffa8)return _0x4ee1c5=_0x20ffa8[_0x30b738('0x33')],typeof _0x542fc1['query'][_0x30b738('0xe')]==='undefined'&&(_0x20a0a6['limit']=qs[_0x30b738('0x2')](_0x542fc1[_0x30b738('0x0')]['limit']),_0x20a0a6[_0x30b738('0x15')]=qs['offset'](_0x542fc1[_0x30b738('0x0')][_0x30b738('0x15')])),_0x31118c[_0x30b738('0x36')](_0x20a0a6);})['then'](function(_0x199599){if(_0x199599)return _0x199599?{'count':_0x4ee1c5,'rows':_0x199599}:null;})[_0x12f56d('0x6')](respondWithResult(_0x4b0108,null))[_0x12f56d('0x31')](handleError(_0x4b0108,null));};