Built motion from commit c49361c37b5f784889c8087ac6e0e91b7e6b561a. Version 3.0.0...
[motion-next.git] / server / api / intVtigerField / intVtigerField.controller.js
1 const a329_0x3ccc=['limit','params','status','type','key','intersection','findOne','../../mysqldb','map','destroy','body','filter','../../components/parsers/qs','count','json','options','VtigerField','keys','sendStatus','offset','where','Content-Range','end','send','fieldName','include','then','pick','stack','update','catch','../../config/logger','merge','rawAttributes','rows','set','index','undefined','includeAll','show','length','nolimit','fields','query','attributes','VIRTUAL','api','error','name','lodash','model','sort','sequelize','create','filters'];(function(_0x355f9b,_0x3cccec){const _0x22ebb4=function(_0x2a416d){while(--_0x2a416d){_0x355f9b['push'](_0x355f9b['shift']());}};_0x22ebb4(++_0x3cccec);}(a329_0x3ccc,0x133));const a329_0x22eb=function(_0x355f9b,_0x3cccec){_0x355f9b=_0x355f9b-0x0;let _0x22ebb4=a329_0x3ccc[_0x355f9b];return _0x22ebb4;};const _0x267abe=a329_0x22eb;'use strict';const _=require(_0x267abe('0x11')),qs=require(_0x267abe('0x23')),logger=require(_0x267abe('0x36'))(_0x267abe('0xe')),db=require(_0x267abe('0x1e'))['db'],{Op}=require(_0x267abe('0x14'));function respondWithResult(_0x2a416d,_0x268731){return _0x268731=_0x268731||0xc8,function(_0x28b3ea){const _0x33f0d3=a329_0x22eb;if(_0x28b3ea)return _0x2a416d['status'](_0x268731)[_0x33f0d3('0x25')](_0x28b3ea);};}function respondWithFilteredResult(_0x18d0fa,_0x1d4492){return function(_0x20685e){const _0x3e990c=a329_0x22eb;if(_0x20685e){const _0x4a834e=_0x20685e[_0x3e990c('0x24')],_0x7edfa8=_0x1d4492[_0x3e990c('0x2a')];let _0x26b2f2=_0x1d4492[_0x3e990c('0x2a')]+_0x1d4492['limit'],_0xc86a86;return _0x26b2f2>=_0x4a834e?(_0x26b2f2=_0x4a834e,_0xc86a86=0xc8):_0xc86a86=0xce,_0x18d0fa[_0x3e990c('0x19')](_0xc86a86),_0x18d0fa[_0x3e990c('0x3')](_0x3e990c('0x2c'),_0x7edfa8+'-'+_0x26b2f2+'/'+_0x4a834e)[_0x3e990c('0x25')](_0x20685e);}return null;};}function saveUpdates(_0x2aa528){return function(_0x26cf06){if(_0x26cf06)return _0x26cf06['update'](_0x2aa528)['then'](function(_0x49ef43){return _0x49ef43;});return null;};}function removeEntity(_0xd98fa7){return function(_0x1a0103){const _0xdf8c69=a329_0x22eb;if(_0x1a0103)return _0x1a0103[_0xdf8c69('0x20')]()[_0xdf8c69('0x31')](function(){const _0xdcb69c=_0xdf8c69;_0xd98fa7[_0xdcb69c('0x19')](0xcc)[_0xdcb69c('0x2d')]();});};}function handleEntityNotFound(_0x5bf1a4){return function(_0x2f4025){const _0x8e01f1=a329_0x22eb;return!_0x2f4025&&_0x5bf1a4[_0x8e01f1('0x29')](0x194),_0x2f4025;};}function handleError(_0x18fcfa,_0x2dd40c){return _0x2dd40c=_0x2dd40c||0x1f4,function(_0xea0965){const _0x15f406=a329_0x22eb;logger[_0x15f406('0xf')](_0xea0965[_0x15f406('0x33')]),_0xea0965[_0x15f406('0x10')]&&delete _0xea0965['name'],_0x18fcfa['status'](_0x2dd40c)[_0x15f406('0x2e')](_0xea0965);};}exports[_0x267abe('0x4')]=function(_0xfc6df3,_0x2f5d51){const _0x481c9d=_0x267abe;let _0x5d422b={};const _0x1fc4f={},_0x4d3260={'count':0x0,'rows':[]},_0x4e9cd4=_[_0x481c9d('0x1f')](db[_0x481c9d('0x27')][_0x481c9d('0x1')],function(_0x33d924){const _0x1d49a4=_0x481c9d;return{'name':_0x33d924[_0x1d49a4('0x2f')],'type':_0x33d924['type'][_0x1d49a4('0x1b')]};});_0x1fc4f[_0x481c9d('0x12')]=_[_0x481c9d('0x1f')](_0x4e9cd4,_0x481c9d('0x10')),_0x1fc4f[_0x481c9d('0xb')]=_[_0x481c9d('0x28')](_0xfc6df3['query']),_0x1fc4f['filters']=_['intersection'](_0x1fc4f[_0x481c9d('0x12')],_0x1fc4f[_0x481c9d('0xb')]),_0x5d422b['attributes']=_['intersection'](_0x1fc4f[_0x481c9d('0x12')],qs['fields'](_0xfc6df3[_0x481c9d('0xb')][_0x481c9d('0xa')])),_0x5d422b[_0x481c9d('0xc')]=_0x5d422b[_0x481c9d('0xc')][_0x481c9d('0x8')]?_0x5d422b[_0x481c9d('0xc')]:_0x1fc4f['model'];typeof _0xfc6df3[_0x481c9d('0xb')][_0x481c9d('0x9')]===_0x481c9d('0x5')&&(_0x5d422b[_0x481c9d('0x17')]=qs['limit'](_0xfc6df3[_0x481c9d('0xb')][_0x481c9d('0x17')]),_0x5d422b[_0x481c9d('0x2a')]=qs[_0x481c9d('0x2a')](_0xfc6df3[_0x481c9d('0xb')][_0x481c9d('0x2a')]));_0x5d422b['order']=qs[_0x481c9d('0x13')](_0xfc6df3[_0x481c9d('0xb')]['sort']),_0x5d422b['where']=qs['filters'](_[_0x481c9d('0x32')](_0xfc6df3[_0x481c9d('0xb')],_0x1fc4f['filters']),_0x4e9cd4);_0xfc6df3[_0x481c9d('0xb')][_0x481c9d('0x22')]&&(_0x5d422b[_0x481c9d('0x2b')]=_[_0x481c9d('0x0')](_0x5d422b[_0x481c9d('0x2b')],{[Op['or']]:_[_0x481c9d('0x1f')](_0x4e9cd4,function(_0x43cedb){const _0x41e702=_0x481c9d;if(_0x43cedb[_0x41e702('0x1a')]!==_0x41e702('0xd')){const _0xf814e7={};return _0xf814e7[_0x43cedb['name']]={[Op['like']]:'%'+_0xfc6df3[_0x41e702('0xb')]['filter']+'%'},_0xf814e7;}})}));_0x5d422b=_['merge']({},_0x5d422b,_0xfc6df3['options']);const _0x4d9220={'where':_0x5d422b[_0x481c9d('0x2b')]};return db['VtigerField'][_0x481c9d('0x24')](_0x4d9220)['then'](function(_0x15bac4){const _0x2b53a2=_0x481c9d;return _0x4d3260[_0x2b53a2('0x24')]=_0x15bac4,_0xfc6df3[_0x2b53a2('0xb')][_0x2b53a2('0x6')]&&(_0x5d422b[_0x2b53a2('0x30')]=[{'all':!![]}]),db[_0x2b53a2('0x27')]['findAll'](_0x5d422b);})[_0x481c9d('0x31')](function(_0x18201b){const _0x45703e=_0x481c9d;return _0x4d3260[_0x45703e('0x2')]=_0x18201b,_0x4d3260;})[_0x481c9d('0x31')](respondWithFilteredResult(_0x2f5d51,_0x5d422b))['catch'](handleError(_0x2f5d51,null));},exports[_0x267abe('0x7')]=function(_0x2dc024,_0x179172){const _0x35f201=_0x267abe;let _0x344dfe={'raw':!![],'where':{'id':_0x2dc024[_0x35f201('0x18')]['id']}};const _0x4c61e5={};return _0x4c61e5[_0x35f201('0x12')]=_[_0x35f201('0x28')](db[_0x35f201('0x27')][_0x35f201('0x1')]),_0x4c61e5[_0x35f201('0xb')]=_[_0x35f201('0x28')](_0x2dc024[_0x35f201('0xb')]),_0x4c61e5[_0x35f201('0x16')]=_[_0x35f201('0x1c')](_0x4c61e5['model'],_0x4c61e5['query']),_0x344dfe[_0x35f201('0xc')]=_['intersection'](_0x4c61e5[_0x35f201('0x12')],qs[_0x35f201('0xa')](_0x2dc024[_0x35f201('0xb')][_0x35f201('0xa')])),_0x344dfe[_0x35f201('0xc')]=_0x344dfe[_0x35f201('0xc')][_0x35f201('0x8')]?_0x344dfe[_0x35f201('0xc')]:_0x4c61e5[_0x35f201('0x12')],_0x2dc024[_0x35f201('0xb')][_0x35f201('0x6')]&&(_0x344dfe['include']=[{'all':!![]}]),_0x344dfe=_[_0x35f201('0x0')]({},_0x344dfe,_0x2dc024[_0x35f201('0x26')]),db[_0x35f201('0x27')][_0x35f201('0x1d')](_0x344dfe)[_0x35f201('0x31')](handleEntityNotFound(_0x179172,null))[_0x35f201('0x31')](respondWithResult(_0x179172,null))[_0x35f201('0x35')](handleError(_0x179172,null));},exports['create']=function(_0x40bddc,_0x80093d){const _0x2b07c4=_0x267abe;return db[_0x2b07c4('0x27')][_0x2b07c4('0x15')](_0x40bddc[_0x2b07c4('0x21')],{})[_0x2b07c4('0x31')](respondWithResult(_0x80093d,0xc9))[_0x2b07c4('0x35')](handleError(_0x80093d,null));},exports[_0x267abe('0x34')]=function(_0x5b827a,_0x4d5f26){const _0x101f84=_0x267abe;return _0x5b827a['body']['id']&&delete _0x5b827a[_0x101f84('0x21')]['id'],db[_0x101f84('0x27')][_0x101f84('0x1d')]({'where':{'id':_0x5b827a[_0x101f84('0x18')]['id']}})[_0x101f84('0x31')](handleEntityNotFound(_0x4d5f26,null))['then'](saveUpdates(_0x5b827a[_0x101f84('0x21')],null))[_0x101f84('0x31')](respondWithResult(_0x4d5f26,null))[_0x101f84('0x35')](handleError(_0x4d5f26,null));},exports[_0x267abe('0x20')]=function(_0x34cef8,_0x521bfb){const _0x284611=_0x267abe;return db[_0x284611('0x27')]['findOne']({'where':{'id':_0x34cef8['params']['id']}})[_0x284611('0x31')](handleEntityNotFound(_0x521bfb,null))[_0x284611('0x31')](removeEntity(_0x521bfb,null))[_0x284611('0x35')](handleError(_0x521bfb,null));};