d224da4950a2f8488b18272718f419556d2489f9
[motion-next.git] / server / api / intSugarcrmField / intSugarcrmField.controller.js
1 const a316_0x3c20=['merge','api','like','includeAll','filters','options','error','stack','../../components/parsers/qs','lodash','sequelize','intersection','filter','name','index','../../config/logger','create','keys','destroy','map','query','undefined','end','findOne','fieldName','body','update','Content-Range','then','set','catch','rows','SugarcrmField','count','params','json','include','fields','length','sort','order','attributes','where','limit','sendStatus','status','show','key','type','offset','pick','model','rawAttributes'];(function(_0xb49fa0,_0x3c200f){const _0x4d326e=function(_0x5d2300){while(--_0x5d2300){_0xb49fa0['push'](_0xb49fa0['shift']());}};_0x4d326e(++_0x3c200f);}(a316_0x3c20,0x16d));const a316_0x4d32=function(_0xb49fa0,_0x3c200f){_0xb49fa0=_0xb49fa0-0x0;let _0x4d326e=a316_0x3c20[_0xb49fa0];return _0x4d326e;};const _0x5082aa=a316_0x4d32;'use strict';const _=require(_0x5082aa('0xf')),qs=require(_0x5082aa('0xe')),logger=require(_0x5082aa('0x15'))(_0x5082aa('0x7')),db=require('../../mysqldb')['db'],{Op}=require(_0x5082aa('0x10'));function respondWithResult(_0x5d2300,_0x50b285){return _0x50b285=_0x50b285||0xc8,function(_0x1ccafa){const _0x337c99=a316_0x4d32;if(_0x1ccafa)return _0x5d2300[_0x337c99('0x33')](_0x50b285)[_0x337c99('0x29')](_0x1ccafa);};}function respondWithFilteredResult(_0xf8fbd,_0x568d80){return function(_0xae3430){const _0x524f07=a316_0x4d32;if(_0xae3430){const _0x2275e1=_0xae3430['count'],_0x5c20bf=_0x568d80[_0x524f07('0x2')];let _0x9956ba=_0x568d80[_0x524f07('0x2')]+_0x568d80[_0x524f07('0x31')],_0x1e1143;return _0x9956ba>=_0x2275e1?(_0x9956ba=_0x2275e1,_0x1e1143=0xc8):_0x1e1143=0xce,_0xf8fbd[_0x524f07('0x33')](_0x1e1143),_0xf8fbd[_0x524f07('0x23')](_0x524f07('0x21'),_0x5c20bf+'-'+_0x9956ba+'/'+_0x2275e1)['json'](_0xae3430);}return null;};}function saveUpdates(_0x5aa3f0){return function(_0x45bad6){const _0x4065fb=a316_0x4d32;if(_0x45bad6)return _0x45bad6[_0x4065fb('0x20')](_0x5aa3f0)[_0x4065fb('0x22')](function(_0x3ac3d9){return _0x3ac3d9;});return null;};}function removeEntity(_0x2e0d85){return function(_0x5c9d7e){const _0x115214=a316_0x4d32;if(_0x5c9d7e)return _0x5c9d7e[_0x115214('0x18')]()[_0x115214('0x22')](function(){const _0x4ad4fa=_0x115214;_0x2e0d85[_0x4ad4fa('0x33')](0xcc)[_0x4ad4fa('0x1c')]();});};}function handleEntityNotFound(_0x5db7c0){return function(_0x35f9eb){const _0x168c82=a316_0x4d32;return!_0x35f9eb&&_0x5db7c0[_0x168c82('0x32')](0x194),_0x35f9eb;};}function handleError(_0x5e7015,_0x34f82c){return _0x34f82c=_0x34f82c||0x1f4,function(_0x13210b){const _0xa827b6=a316_0x4d32;logger[_0xa827b6('0xc')](_0x13210b[_0xa827b6('0xd')]),_0x13210b['name']&&delete _0x13210b[_0xa827b6('0x13')],_0x5e7015[_0xa827b6('0x33')](_0x34f82c)['send'](_0x13210b);};}exports[_0x5082aa('0x14')]=function(_0x145f02,_0x5b035b){const _0x4b9bf1=_0x5082aa;let _0x2ec08f={};const _0x4a14c4={},_0x5e081b={'count':0x0,'rows':[]},_0x227218=_[_0x4b9bf1('0x19')](db[_0x4b9bf1('0x26')][_0x4b9bf1('0x5')],function(_0x3c0a64){const _0x5bf8b0=_0x4b9bf1;return{'name':_0x3c0a64[_0x5bf8b0('0x1e')],'type':_0x3c0a64[_0x5bf8b0('0x1')][_0x5bf8b0('0x0')]};});_0x4a14c4[_0x4b9bf1('0x4')]=_['map'](_0x227218,_0x4b9bf1('0x13')),_0x4a14c4[_0x4b9bf1('0x1a')]=_['keys'](_0x145f02[_0x4b9bf1('0x1a')]),_0x4a14c4['filters']=_[_0x4b9bf1('0x11')](_0x4a14c4[_0x4b9bf1('0x4')],_0x4a14c4[_0x4b9bf1('0x1a')]),_0x2ec08f[_0x4b9bf1('0x2f')]=_[_0x4b9bf1('0x11')](_0x4a14c4['model'],qs['fields'](_0x145f02[_0x4b9bf1('0x1a')][_0x4b9bf1('0x2b')])),_0x2ec08f['attributes']=_0x2ec08f['attributes'][_0x4b9bf1('0x2c')]?_0x2ec08f['attributes']:_0x4a14c4[_0x4b9bf1('0x4')];typeof _0x145f02[_0x4b9bf1('0x1a')]['nolimit']===_0x4b9bf1('0x1b')&&(_0x2ec08f[_0x4b9bf1('0x31')]=qs['limit'](_0x145f02[_0x4b9bf1('0x1a')][_0x4b9bf1('0x31')]),_0x2ec08f[_0x4b9bf1('0x2')]=qs['offset'](_0x145f02[_0x4b9bf1('0x1a')]['offset']));_0x2ec08f[_0x4b9bf1('0x2e')]=qs[_0x4b9bf1('0x2d')](_0x145f02[_0x4b9bf1('0x1a')][_0x4b9bf1('0x2d')]),_0x2ec08f[_0x4b9bf1('0x30')]=qs[_0x4b9bf1('0xa')](_[_0x4b9bf1('0x3')](_0x145f02[_0x4b9bf1('0x1a')],_0x4a14c4[_0x4b9bf1('0xa')]),_0x227218);_0x145f02[_0x4b9bf1('0x1a')][_0x4b9bf1('0x12')]&&(_0x2ec08f[_0x4b9bf1('0x30')]=_[_0x4b9bf1('0x6')](_0x2ec08f[_0x4b9bf1('0x30')],{[Op['or']]:_[_0x4b9bf1('0x19')](_0x227218,function(_0x2df5e6){const _0x255770=_0x4b9bf1;if(_0x2df5e6[_0x255770('0x1')]!=='VIRTUAL'){const _0x1fba2b={};return _0x1fba2b[_0x2df5e6[_0x255770('0x13')]]={[Op[_0x255770('0x8')]]:'%'+_0x145f02[_0x255770('0x1a')][_0x255770('0x12')]+'%'},_0x1fba2b;}})}));_0x2ec08f=_['merge']({},_0x2ec08f,_0x145f02[_0x4b9bf1('0xb')]);const _0x42a65c={'where':_0x2ec08f[_0x4b9bf1('0x30')]};return db[_0x4b9bf1('0x26')]['count'](_0x42a65c)['then'](function(_0xd05d21){const _0x57d011=_0x4b9bf1;return _0x5e081b[_0x57d011('0x27')]=_0xd05d21,_0x145f02[_0x57d011('0x1a')][_0x57d011('0x9')]&&(_0x2ec08f[_0x57d011('0x2a')]=[{'all':!![]}]),db['SugarcrmField']['findAll'](_0x2ec08f);})[_0x4b9bf1('0x22')](function(_0x326b7b){const _0x3b7c5e=_0x4b9bf1;return _0x5e081b[_0x3b7c5e('0x25')]=_0x326b7b,_0x5e081b;})[_0x4b9bf1('0x22')](respondWithFilteredResult(_0x5b035b,_0x2ec08f))['catch'](handleError(_0x5b035b,null));},exports[_0x5082aa('0x34')]=function(_0xfc4a04,_0x31955f){const _0x9b4ad1=_0x5082aa;let _0x5ea272={'raw':!![],'where':{'id':_0xfc4a04[_0x9b4ad1('0x28')]['id']}};const _0x55a40d={};return _0x55a40d[_0x9b4ad1('0x4')]=_[_0x9b4ad1('0x17')](db[_0x9b4ad1('0x26')][_0x9b4ad1('0x5')]),_0x55a40d[_0x9b4ad1('0x1a')]=_[_0x9b4ad1('0x17')](_0xfc4a04[_0x9b4ad1('0x1a')]),_0x55a40d[_0x9b4ad1('0xa')]=_[_0x9b4ad1('0x11')](_0x55a40d[_0x9b4ad1('0x4')],_0x55a40d['query']),_0x5ea272[_0x9b4ad1('0x2f')]=_[_0x9b4ad1('0x11')](_0x55a40d['model'],qs[_0x9b4ad1('0x2b')](_0xfc4a04[_0x9b4ad1('0x1a')][_0x9b4ad1('0x2b')])),_0x5ea272['attributes']=_0x5ea272['attributes'][_0x9b4ad1('0x2c')]?_0x5ea272[_0x9b4ad1('0x2f')]:_0x55a40d['model'],_0xfc4a04[_0x9b4ad1('0x1a')]['includeAll']&&(_0x5ea272[_0x9b4ad1('0x2a')]=[{'all':!![]}]),_0x5ea272=_[_0x9b4ad1('0x6')]({},_0x5ea272,_0xfc4a04[_0x9b4ad1('0xb')]),db[_0x9b4ad1('0x26')][_0x9b4ad1('0x1d')](_0x5ea272)['then'](handleEntityNotFound(_0x31955f,null))[_0x9b4ad1('0x22')](respondWithResult(_0x31955f,null))['catch'](handleError(_0x31955f,null));},exports[_0x5082aa('0x16')]=function(_0x274dbc,_0x1dac92){const _0x377ef5=_0x5082aa;return db[_0x377ef5('0x26')][_0x377ef5('0x16')](_0x274dbc[_0x377ef5('0x1f')],{})[_0x377ef5('0x22')](respondWithResult(_0x1dac92,0xc9))[_0x377ef5('0x24')](handleError(_0x1dac92,null));},exports['update']=function(_0x278e98,_0x389409){const _0x1d59da=_0x5082aa;return _0x278e98[_0x1d59da('0x1f')]['id']&&delete _0x278e98[_0x1d59da('0x1f')]['id'],db[_0x1d59da('0x26')][_0x1d59da('0x1d')]({'where':{'id':_0x278e98[_0x1d59da('0x28')]['id']}})[_0x1d59da('0x22')](handleEntityNotFound(_0x389409,null))[_0x1d59da('0x22')](saveUpdates(_0x278e98[_0x1d59da('0x1f')],null))['then'](respondWithResult(_0x389409,null))[_0x1d59da('0x24')](handleError(_0x389409,null));},exports[_0x5082aa('0x18')]=function(_0x31a17c,_0x83e589){const _0x124da7=_0x5082aa;return db[_0x124da7('0x26')][_0x124da7('0x1d')]({'where':{'id':_0x31a17c['params']['id']}})[_0x124da7('0x22')](handleEntityNotFound(_0x83e589,null))[_0x124da7('0x22')](removeEntity(_0x83e589,null))['catch'](handleError(_0x83e589,null));};