Built motion from commit 4a18b36e645f5fa4a517d36f9783bde259878164. Version 3.0.0...
[motion-next.git] / server / api / cmCustomField / cmCustomField.controller.js
1 const a133_0x3fb5=['defaultValue','filters','transaction','show','sendStatus','../../mysqldb','api','send','params','CmCustomField','end','../../config/logger','keys','set','length','switch','../../components/parsers/qs','limit','TEXT','BOOLEAN','include','cm_contacts','status','nolimit','json','destroy','offset','rows','model','fields','body','includeAll','findOne','sort','query','catch','map','where','create','count','text','lodash','fieldName','intersection','update','cf_%d','Content-Range','options','filter','name','differenceBy','type','order','Sequelize','format','sequelize','rawAttributes','key','index','INTEGER','queryInterface','attributes','then','merge','addColumn','util'];(function(_0x1f6060,_0x3fb505){const _0x37076c=function(_0x44b155){while(--_0x44b155){_0x1f6060['push'](_0x1f6060['shift']());}};_0x37076c(++_0x3fb505);}(a133_0x3fb5,0x131));const a133_0x3707=function(_0x1f6060,_0x3fb505){_0x1f6060=_0x1f6060-0x0;let _0x37076c=a133_0x3fb5[_0x1f6060];return _0x37076c;};const _0x24cd02=a133_0x3707;'use strict';const util=require(_0x24cd02('0x18')),_=require(_0x24cd02('0x0')),qs=require(_0x24cd02('0x29')),logger=require(_0x24cd02('0x24'))(_0x24cd02('0x1f')),db=require(_0x24cd02('0x1e'))['db'],{Op}=require(_0x24cd02('0xe'));function respondWithResult(_0x44b155,_0x4ceda9){return _0x4ceda9=_0x4ceda9||0xc8,function(_0x301d6d){const _0x3fdc19=a133_0x3707;if(_0x301d6d)return _0x44b155[_0x3fdc19('0x2f')](_0x4ceda9)[_0x3fdc19('0x31')](_0x301d6d);};}function respondWithFilteredResult(_0x32c83c,_0x4989b4){return function(_0x3a14aa){const _0x1f7f83=a133_0x3707;if(_0x3a14aa){const _0x5b4413=_0x3a14aa[_0x1f7f83('0x40')],_0x6487b1=_0x4989b4[_0x1f7f83('0x33')];let _0x562f4e=_0x4989b4[_0x1f7f83('0x33')]+_0x4989b4[_0x1f7f83('0x2a')],_0x5ee290;return _0x562f4e>=_0x5b4413?(_0x562f4e=_0x5b4413,_0x5ee290=0xc8):_0x5ee290=0xce,_0x32c83c[_0x1f7f83('0x2f')](_0x5ee290),_0x32c83c[_0x1f7f83('0x26')](_0x1f7f83('0x5'),_0x6487b1+'-'+_0x562f4e+'/'+_0x5b4413)['json'](_0x3a14aa);}return null;};}function saveUpdates(_0x532a74){return function(_0x56e938){const _0x352ead=a133_0x3707;if(_0x56e938)return _0x56e938['update'](_0x532a74)[_0x352ead('0x15')](function(_0x382249){return _0x382249;});return null;};}function removeEntity(_0x274e96){return function(_0x134be3){const _0x899e7=a133_0x3707;if(_0x134be3)return _0x134be3[_0x899e7('0x32')]()['then'](function(){const _0x448dd2=_0x899e7;_0x274e96[_0x448dd2('0x2f')](0xcc)[_0x448dd2('0x23')]();});};}function handleEntityNotFound(_0x4e3af0){return function(_0x25afaa){const _0x27a2f6=a133_0x3707;return!_0x25afaa&&_0x4e3af0[_0x27a2f6('0x1d')](0x194),_0x25afaa;};}function handleError(_0x446f2f,_0x27f511){return _0x27f511=_0x27f511||0x1f4,function(_0x28adf3){const _0x25092a=a133_0x3707;logger['error'](_0x28adf3['stack']),_0x28adf3[_0x25092a('0x8')]&&delete _0x28adf3[_0x25092a('0x8')],_0x446f2f[_0x25092a('0x2f')](_0x27f511)[_0x25092a('0x20')](_0x28adf3);};}exports[_0x24cd02('0x11')]=function(_0x3aea4e,_0x3fb328){const _0x58d1b2=_0x24cd02;let _0x38b6ad={};const _0x4039a9={},_0x5dc9f2={'count':0x0,'rows':[]},_0x4f4417=_[_0x58d1b2('0x3d')](db[_0x58d1b2('0x22')][_0x58d1b2('0xf')],function(_0x349d38){const _0x30a62b=_0x58d1b2;return{'name':_0x349d38[_0x30a62b('0x1')],'type':_0x349d38[_0x30a62b('0xa')][_0x30a62b('0x10')]};});_0x4039a9[_0x58d1b2('0x35')]=_[_0x58d1b2('0x9')](_[_0x58d1b2('0x3d')](_0x4f4417,_0x58d1b2('0x8')),[_0x58d1b2('0x8')]),_0x4039a9['query']=_[_0x58d1b2('0x25')](_0x3aea4e[_0x58d1b2('0x3b')]),_0x4039a9[_0x58d1b2('0x1a')]=_['intersection'](_0x4039a9[_0x58d1b2('0x35')],_0x4039a9[_0x58d1b2('0x3b')]),_0x38b6ad[_0x58d1b2('0x14')]=_[_0x58d1b2('0x2')](_0x4039a9[_0x58d1b2('0x35')],qs['fields'](_0x3aea4e[_0x58d1b2('0x3b')][_0x58d1b2('0x36')])),_0x38b6ad[_0x58d1b2('0x14')]=_0x38b6ad[_0x58d1b2('0x14')][_0x58d1b2('0x27')]?_0x38b6ad[_0x58d1b2('0x14')]:_0x4039a9['model'];typeof _0x3aea4e[_0x58d1b2('0x3b')][_0x58d1b2('0x30')]==='undefined'&&(_0x38b6ad[_0x58d1b2('0x2a')]=qs[_0x58d1b2('0x2a')](_0x3aea4e[_0x58d1b2('0x3b')][_0x58d1b2('0x2a')]),_0x38b6ad[_0x58d1b2('0x33')]=qs[_0x58d1b2('0x33')](_0x3aea4e['query']['offset']));_0x38b6ad[_0x58d1b2('0xb')]=qs[_0x58d1b2('0x3a')](_0x3aea4e[_0x58d1b2('0x3b')][_0x58d1b2('0x3a')]),_0x38b6ad[_0x58d1b2('0x3e')]=qs[_0x58d1b2('0x1a')](_['pick'](_0x3aea4e['query'],_0x4039a9[_0x58d1b2('0x1a')]),_0x4f4417);_0x3aea4e[_0x58d1b2('0x3b')]['filter']&&(_0x38b6ad['where']=_[_0x58d1b2('0x16')](_0x38b6ad[_0x58d1b2('0x3e')],{[Op['or']]:_[_0x58d1b2('0x3d')](_0x4f4417,function(_0x3f9e0a){const _0x1828a0=_0x58d1b2;if(_0x3f9e0a[_0x1828a0('0xa')]!=='VIRTUAL'){const _0x54a5ad={};return _0x54a5ad[_0x3f9e0a[_0x1828a0('0x8')]]={[Op['like']]:'%'+_0x3aea4e[_0x1828a0('0x3b')][_0x1828a0('0x7')]+'%'},_0x54a5ad;}})}));_0x38b6ad=_['merge']({},_0x38b6ad,_0x3aea4e[_0x58d1b2('0x6')]);const _0x589f97={'where':_0x38b6ad[_0x58d1b2('0x3e')]};return db[_0x58d1b2('0x22')][_0x58d1b2('0x40')](_0x589f97)[_0x58d1b2('0x15')](function(_0x5cf1c5){const _0x5f4e99=_0x58d1b2;return _0x5dc9f2[_0x5f4e99('0x40')]=_0x5cf1c5,_0x3aea4e[_0x5f4e99('0x3b')][_0x5f4e99('0x38')]&&(_0x38b6ad[_0x5f4e99('0x2d')]=[{'all':!![]}]),db[_0x5f4e99('0x22')]['findAll'](_0x38b6ad);})['then'](function(_0x377c37){const _0x105c20=_0x58d1b2;return _0x5dc9f2[_0x105c20('0x34')]=_0x377c37,_0x5dc9f2;})[_0x58d1b2('0x15')](respondWithFilteredResult(_0x3fb328,_0x38b6ad))[_0x58d1b2('0x3c')](handleError(_0x3fb328,null));},exports[_0x24cd02('0x1c')]=function(_0x295df5,_0xda1bf3){const _0x4e308e=_0x24cd02;let _0x315e6d={'raw':!![],'where':{'id':_0x295df5[_0x4e308e('0x21')]['id']}};const _0x138c1d={};return _0x138c1d[_0x4e308e('0x35')]=_[_0x4e308e('0x25')](db['CmCustomField'][_0x4e308e('0xf')]),_0x138c1d[_0x4e308e('0x3b')]=_[_0x4e308e('0x25')](_0x295df5[_0x4e308e('0x3b')]),_0x138c1d[_0x4e308e('0x1a')]=_[_0x4e308e('0x2')](_0x138c1d[_0x4e308e('0x35')],_0x138c1d['query']),_0x315e6d[_0x4e308e('0x14')]=_['intersection'](_0x138c1d[_0x4e308e('0x35')],qs[_0x4e308e('0x36')](_0x295df5[_0x4e308e('0x3b')][_0x4e308e('0x36')])),_0x315e6d[_0x4e308e('0x14')]=_0x315e6d[_0x4e308e('0x14')][_0x4e308e('0x27')]?_0x315e6d['attributes']:_0x138c1d[_0x4e308e('0x35')],_0x295df5['query'][_0x4e308e('0x38')]&&(_0x315e6d[_0x4e308e('0x2d')]=[{'all':!![]}]),_0x315e6d=_[_0x4e308e('0x16')]({},_0x315e6d,_0x295df5[_0x4e308e('0x6')]),db[_0x4e308e('0x22')][_0x4e308e('0x39')](_0x315e6d)[_0x4e308e('0x15')](handleEntityNotFound(_0xda1bf3,null))['then'](respondWithResult(_0xda1bf3,null))[_0x4e308e('0x3c')](handleError(_0xda1bf3,null));},exports[_0x24cd02('0x3')]=function(_0x47d407,_0x4eff09){const _0x5e3c78=_0x24cd02;return _0x47d407[_0x5e3c78('0x37')]['id']&&delete _0x47d407[_0x5e3c78('0x37')]['id'],db[_0x5e3c78('0x22')][_0x5e3c78('0x39')]({'where':{'id':_0x47d407['params']['id']}})[_0x5e3c78('0x15')](handleEntityNotFound(_0x4eff09,null))[_0x5e3c78('0x15')](saveUpdates(_0x47d407[_0x5e3c78('0x37')],null))[_0x5e3c78('0x15')](respondWithResult(_0x4eff09,null))[_0x5e3c78('0x3c')](handleError(_0x4eff09,null));},exports[_0x24cd02('0x32')]=function(_0x984f19,_0x59e514){const _0x66f28a=_0x24cd02;return db['CmCustomField']['findOne']({'where':{'id':_0x984f19[_0x66f28a('0x21')]['id']}})['then'](handleEntityNotFound(_0x59e514,null))['then'](removeEntity(_0x59e514,null))[_0x66f28a('0x3c')](handleError(_0x59e514,null));},exports[_0x24cd02('0x3f')]=function(_0x25fd8d,_0x55c306){const _0x41bb70=_0x24cd02;let _0x41f46d;return db[_0x41bb70('0xe')][_0x41bb70('0x1b')](function(_0x3c4c8d){const _0x1ca785=_0x41bb70;return db[_0x1ca785('0x22')][_0x1ca785('0x3f')](_0x25fd8d[_0x1ca785('0x37')],{'transaction':_0x3c4c8d})[_0x1ca785('0x15')](function(_0x3bb29d){const _0x20f1c9=_0x1ca785;_0x41f46d=_0x3bb29d;const _0xa869a6={'type':db[_0x20f1c9('0xc')][_0x20f1c9('0x2b')],'transaction':_0x3c4c8d};switch(_0x25fd8d[_0x20f1c9('0x37')][_0x20f1c9('0xa')]){case _0x20f1c9('0x41'):_0xa869a6[_0x20f1c9('0xa')]=db[_0x20f1c9('0xc')][_0x20f1c9('0x2b')];break;case'number':_0xa869a6[_0x20f1c9('0xa')]=db[_0x20f1c9('0xc')][_0x20f1c9('0x12')];break;case _0x20f1c9('0x28'):_0xa869a6['type']=db[_0x20f1c9('0xc')][_0x20f1c9('0x2c')],_0xa869a6[_0x20f1c9('0x19')]=![];break;default:}return db[_0x20f1c9('0xe')][_0x20f1c9('0x13')][_0x20f1c9('0x17')](_0x20f1c9('0x2e'),util[_0x20f1c9('0xd')](_0x20f1c9('0x4'),_0x41f46d['id']),_0xa869a6);})[_0x1ca785('0x15')](function(){return _0x41f46d;});})[_0x41bb70('0x15')](respondWithResult(_0x55c306,0xc9))[_0x41bb70('0x3c')](handleError(_0x55c306,null));};