6a6df2445cffc2ff5eca73fe2e0b1a7b03a1f39d
[motion-next.git] / server / api / cmCustomField / cmCustomField.controller.js
1 const a133_0x4e76=['defaultValue','lodash','../../mysqldb','sort','limit','body','count','TEXT','type','like','queryInterface','include','order','length','update','undefined','sendStatus','attributes','filter','map','differenceBy','destroy','key','addColumn','BOOLEAN','create','fieldName','offset','Sequelize','transaction','query','options','cf_%d','model','name','where','findAll','intersection','VIRTUAL','../../config/logger','api','cm_contacts','send','switch','fields','keys','findOne','filters','set','index','then','status','Content-Range','stack','nolimit','CmCustomField','catch','params','sequelize','json','rows','merge'];(function(_0x2731f6,_0x4e76ff){const _0x5172a8=function(_0x1869bd){while(--_0x1869bd){_0x2731f6['push'](_0x2731f6['shift']());}};_0x5172a8(++_0x4e76ff);}(a133_0x4e76,0x1ba));const a133_0x5172=function(_0x2731f6,_0x4e76ff){_0x2731f6=_0x2731f6-0x0;let _0x5172a8=a133_0x4e76[_0x2731f6];return _0x5172a8;};const _0x3531f1=a133_0x5172;'use strict';const util=require('util'),_=require(_0x3531f1('0x37')),qs=require('../../components/parsers/qs'),logger=require(_0x3531f1('0x1f'))(_0x3531f1('0x20')),db=require(_0x3531f1('0x38'))['db'],{Op}=require(_0x3531f1('0x32'));function respondWithResult(_0x1869bd,_0x44ea0e){return _0x44ea0e=_0x44ea0e||0xc8,function(_0x5d11c3){const _0x3e9c35=a133_0x5172;if(_0x5d11c3)return _0x1869bd[_0x3e9c35('0x2b')](_0x44ea0e)[_0x3e9c35('0x33')](_0x5d11c3);};}function respondWithFilteredResult(_0x1c1850,_0x48f0d3){return function(_0x21aa83){const _0x144230=a133_0x5172;if(_0x21aa83){const _0xf56417=_0x21aa83['count'],_0x1ad8a4=_0x48f0d3[_0x144230('0x13')];let _0x505e62=_0x48f0d3[_0x144230('0x13')]+_0x48f0d3[_0x144230('0x3a')],_0x1db2a2;return _0x505e62>=_0xf56417?(_0x505e62=_0xf56417,_0x1db2a2=0xc8):_0x1db2a2=0xce,_0x1c1850['status'](_0x1db2a2),_0x1c1850[_0x144230('0x28')](_0x144230('0x2c'),_0x1ad8a4+'-'+_0x505e62+'/'+_0xf56417)[_0x144230('0x33')](_0x21aa83);}return null;};}function saveUpdates(_0x14b467){return function(_0x1ecd83){const _0x55449d=a133_0x5172;if(_0x1ecd83)return _0x1ecd83[_0x55449d('0x6')](_0x14b467)[_0x55449d('0x2a')](function(_0x48b91d){return _0x48b91d;});return null;};}function removeEntity(_0x2fa07e){return function(_0xbc4643){const _0x41d7cc=a133_0x5172;if(_0xbc4643)return _0xbc4643[_0x41d7cc('0xd')]()[_0x41d7cc('0x2a')](function(){const _0x4ec508=_0x41d7cc;_0x2fa07e[_0x4ec508('0x2b')](0xcc)['end']();});};}function handleEntityNotFound(_0x1d4f50){return function(_0x3552e5){const _0x25713b=a133_0x5172;return!_0x3552e5&&_0x1d4f50[_0x25713b('0x8')](0x194),_0x3552e5;};}function handleError(_0x404420,_0x599189){return _0x599189=_0x599189||0x1f4,function(_0x1c0776){const _0x12c25e=a133_0x5172;logger['error'](_0x1c0776[_0x12c25e('0x2d')]),_0x1c0776[_0x12c25e('0x1a')]&&delete _0x1c0776[_0x12c25e('0x1a')],_0x404420[_0x12c25e('0x2b')](_0x599189)[_0x12c25e('0x22')](_0x1c0776);};}exports[_0x3531f1('0x29')]=function(_0x2259f5,_0x139619){const _0x9dc85b=_0x3531f1;let _0x5d1b52={};const _0x1ecff1={},_0x2031d0={'count':0x0,'rows':[]},_0x2418dc=_['map'](db[_0x9dc85b('0x2f')]['rawAttributes'],function(_0x37175e){const _0x2ac1c2=_0x9dc85b;return{'name':_0x37175e[_0x2ac1c2('0x12')],'type':_0x37175e[_0x2ac1c2('0x0')][_0x2ac1c2('0xe')]};});_0x1ecff1[_0x9dc85b('0x19')]=_[_0x9dc85b('0xc')](_[_0x9dc85b('0xb')](_0x2418dc,'name'),[_0x9dc85b('0x1a')]),_0x1ecff1[_0x9dc85b('0x16')]=_[_0x9dc85b('0x25')](_0x2259f5[_0x9dc85b('0x16')]),_0x1ecff1[_0x9dc85b('0x27')]=_['intersection'](_0x1ecff1[_0x9dc85b('0x19')],_0x1ecff1[_0x9dc85b('0x16')]),_0x5d1b52[_0x9dc85b('0x9')]=_[_0x9dc85b('0x1d')](_0x1ecff1[_0x9dc85b('0x19')],qs['fields'](_0x2259f5['query'][_0x9dc85b('0x24')])),_0x5d1b52['attributes']=_0x5d1b52[_0x9dc85b('0x9')][_0x9dc85b('0x5')]?_0x5d1b52[_0x9dc85b('0x9')]:_0x1ecff1[_0x9dc85b('0x19')];typeof _0x2259f5[_0x9dc85b('0x16')][_0x9dc85b('0x2e')]===_0x9dc85b('0x7')&&(_0x5d1b52[_0x9dc85b('0x3a')]=qs['limit'](_0x2259f5['query']['limit']),_0x5d1b52[_0x9dc85b('0x13')]=qs[_0x9dc85b('0x13')](_0x2259f5[_0x9dc85b('0x16')][_0x9dc85b('0x13')]));_0x5d1b52[_0x9dc85b('0x4')]=qs[_0x9dc85b('0x39')](_0x2259f5['query'][_0x9dc85b('0x39')]),_0x5d1b52[_0x9dc85b('0x1b')]=qs[_0x9dc85b('0x27')](_['pick'](_0x2259f5['query'],_0x1ecff1[_0x9dc85b('0x27')]),_0x2418dc);_0x2259f5['query'][_0x9dc85b('0xa')]&&(_0x5d1b52[_0x9dc85b('0x1b')]=_['merge'](_0x5d1b52[_0x9dc85b('0x1b')],{[Op['or']]:_[_0x9dc85b('0xb')](_0x2418dc,function(_0x39e2ee){const _0x31c057=_0x9dc85b;if(_0x39e2ee[_0x31c057('0x0')]!==_0x31c057('0x1e')){const _0x18e74e={};return _0x18e74e[_0x39e2ee['name']]={[Op[_0x31c057('0x1')]]:'%'+_0x2259f5[_0x31c057('0x16')][_0x31c057('0xa')]+'%'},_0x18e74e;}})}));_0x5d1b52=_[_0x9dc85b('0x35')]({},_0x5d1b52,_0x2259f5[_0x9dc85b('0x17')]);const _0x1b713e={'where':_0x5d1b52['where']};return db[_0x9dc85b('0x2f')]['count'](_0x1b713e)[_0x9dc85b('0x2a')](function(_0x4b42b0){const _0x5a5791=_0x9dc85b;return _0x2031d0[_0x5a5791('0x3c')]=_0x4b42b0,_0x2259f5[_0x5a5791('0x16')]['includeAll']&&(_0x5d1b52[_0x5a5791('0x3')]=[{'all':!![]}]),db[_0x5a5791('0x2f')][_0x5a5791('0x1c')](_0x5d1b52);})[_0x9dc85b('0x2a')](function(_0x20912c){const _0x15223a=_0x9dc85b;return _0x2031d0[_0x15223a('0x34')]=_0x20912c,_0x2031d0;})['then'](respondWithFilteredResult(_0x139619,_0x5d1b52))[_0x9dc85b('0x30')](handleError(_0x139619,null));},exports['show']=function(_0xa4099f,_0x160b0f){const _0xc1704d=_0x3531f1;let _0x59a2c8={'raw':!![],'where':{'id':_0xa4099f[_0xc1704d('0x31')]['id']}};const _0x3b45d3={};return _0x3b45d3[_0xc1704d('0x19')]=_[_0xc1704d('0x25')](db[_0xc1704d('0x2f')]['rawAttributes']),_0x3b45d3[_0xc1704d('0x16')]=_[_0xc1704d('0x25')](_0xa4099f['query']),_0x3b45d3['filters']=_[_0xc1704d('0x1d')](_0x3b45d3['model'],_0x3b45d3[_0xc1704d('0x16')]),_0x59a2c8[_0xc1704d('0x9')]=_[_0xc1704d('0x1d')](_0x3b45d3[_0xc1704d('0x19')],qs[_0xc1704d('0x24')](_0xa4099f['query'][_0xc1704d('0x24')])),_0x59a2c8['attributes']=_0x59a2c8[_0xc1704d('0x9')][_0xc1704d('0x5')]?_0x59a2c8['attributes']:_0x3b45d3[_0xc1704d('0x19')],_0xa4099f['query']['includeAll']&&(_0x59a2c8[_0xc1704d('0x3')]=[{'all':!![]}]),_0x59a2c8=_[_0xc1704d('0x35')]({},_0x59a2c8,_0xa4099f[_0xc1704d('0x17')]),db['CmCustomField']['findOne'](_0x59a2c8)[_0xc1704d('0x2a')](handleEntityNotFound(_0x160b0f,null))[_0xc1704d('0x2a')](respondWithResult(_0x160b0f,null))[_0xc1704d('0x30')](handleError(_0x160b0f,null));},exports[_0x3531f1('0x6')]=function(_0x13ccf4,_0x542ab4){const _0x2d06d3=_0x3531f1;return _0x13ccf4[_0x2d06d3('0x3b')]['id']&&delete _0x13ccf4['body']['id'],db[_0x2d06d3('0x2f')][_0x2d06d3('0x26')]({'where':{'id':_0x13ccf4['params']['id']}})[_0x2d06d3('0x2a')](handleEntityNotFound(_0x542ab4,null))[_0x2d06d3('0x2a')](saveUpdates(_0x13ccf4[_0x2d06d3('0x3b')],null))['then'](respondWithResult(_0x542ab4,null))[_0x2d06d3('0x30')](handleError(_0x542ab4,null));},exports[_0x3531f1('0xd')]=function(_0x44d4a2,_0xa39fdf){const _0x3be35a=_0x3531f1;return db[_0x3be35a('0x2f')][_0x3be35a('0x26')]({'where':{'id':_0x44d4a2[_0x3be35a('0x31')]['id']}})[_0x3be35a('0x2a')](handleEntityNotFound(_0xa39fdf,null))[_0x3be35a('0x2a')](removeEntity(_0xa39fdf,null))[_0x3be35a('0x30')](handleError(_0xa39fdf,null));},exports[_0x3531f1('0x11')]=function(_0x1baa0b,_0x5505b8){const _0xe50485=_0x3531f1;let _0x420833;return db['sequelize'][_0xe50485('0x15')](function(_0x4dc25f){const _0x2d8c36=_0xe50485;return db['CmCustomField'][_0x2d8c36('0x11')](_0x1baa0b['body'],{'transaction':_0x4dc25f})['then'](function(_0x341b98){const _0x4d4c49=_0x2d8c36;_0x420833=_0x341b98;const _0x38d1e9={'type':db[_0x4d4c49('0x14')][_0x4d4c49('0x3d')],'transaction':_0x4dc25f};switch(_0x1baa0b[_0x4d4c49('0x3b')]['type']){case'text':_0x38d1e9[_0x4d4c49('0x0')]=db['Sequelize'][_0x4d4c49('0x3d')];break;case'number':_0x38d1e9[_0x4d4c49('0x0')]=db[_0x4d4c49('0x14')]['INTEGER'];break;case _0x4d4c49('0x23'):_0x38d1e9[_0x4d4c49('0x0')]=db[_0x4d4c49('0x14')][_0x4d4c49('0x10')],_0x38d1e9[_0x4d4c49('0x36')]=![];break;default:}return db[_0x4d4c49('0x32')][_0x4d4c49('0x2')][_0x4d4c49('0xf')](_0x4d4c49('0x21'),util['format'](_0x4d4c49('0x18'),_0x420833['id']),_0x38d1e9);})[_0x2d8c36('0x2a')](function(){return _0x420833;});})['then'](respondWithResult(_0x5505b8,0xc9))[_0xe50485('0x30')](handleError(_0x5505b8,null));};