Built motion from commit 362b9399b4d0ed5560fbb795af995925d345fc38. Version 3.0.0...
[motion-next.git] / server / api / userProfileResource / userProfileResource.controller.js
1 const a807_0x379b=['order','rows','pick','undefined','intersection','offset','stack','type','fields','limit','findOne','status','../../config/logger','merge','UserProfileResource','end','sequelize','sendStatus','Content-Range','findAll','body','../../components/parsers/qs','filters','where','json','error','rawAttributes','destroy','includeAll','map','then','keys','include','key','attributes','catch','filter','length','index','sort','params','model','query','lodash','name','send','count','create','update'];(function(_0x27848b,_0x1a5191){const _0x379b0e=function(_0x325244){while(--_0x325244){_0x27848b['push'](_0x27848b['shift']());}};_0x379b0e(++_0x1a5191);}(a807_0x379b,0x118));const a807_0x3252=function(_0x27848b,_0x1a5191){_0x27848b=_0x27848b-0x1a9;let _0x379b0e=a807_0x379b[_0x27848b];return _0x379b0e;};const a807_0x5616e6=a807_0x3252;'use strict';const _=require(a807_0x5616e6(0x1b1)),qs=require(a807_0x5616e6(0x1cc)),logger=require(a807_0x5616e6(0x1c3))('api'),{db}=require('../../mysqldb'),{Op}=require(a807_0x5616e6(0x1c7));function respondWithResult(_0x4f9c44,_0x17ad62){return _0x17ad62=_0x17ad62||0xc8,function(_0x41d643){if(_0x41d643)return _0x4f9c44['status'](_0x17ad62)['json'](_0x41d643);};}function respondWithFilteredResult(_0x5d9451,_0x4e422b){return function(_0x48249e){const _0x5c846a=a807_0x3252;if(_0x48249e){const _0x44a553=_0x48249e[_0x5c846a(0x1b4)],_0x5a8995=_0x4e422b[_0x5c846a(0x1bc)];let _0x692e01=_0x4e422b['offset']+_0x4e422b[_0x5c846a(0x1c0)],_0x35d582;return _0x692e01>=_0x44a553?(_0x692e01=_0x44a553,_0x35d582=0xc8):_0x35d582=0xce,_0x5d9451[_0x5c846a(0x1c2)](_0x35d582),_0x5d9451['set'](_0x5c846a(0x1c9),_0x5a8995+'-'+_0x692e01+'/'+_0x44a553)[_0x5c846a(0x1cf)](_0x48249e);}return null;};}function saveUpdates(_0x317c50){return function(_0x35414b){const _0x5b5964=a807_0x3252;if(_0x35414b)return _0x35414b[_0x5b5964(0x1b6)](_0x317c50)[_0x5b5964(0x1d5)](function(_0x52082d){return _0x52082d;});return null;};}function removeEntity(_0x14ca00){return function(_0x48bd4d){const _0x477220=a807_0x3252;if(_0x48bd4d)return _0x48bd4d['destroy']()[_0x477220(0x1d5)](function(){const _0x3f3557=_0x477220;_0x14ca00['status'](0xcc)[_0x3f3557(0x1c6)]();});};}function handleEntityNotFound(_0x2737b3){return function(_0x447013){const _0x496f2c=a807_0x3252;return!_0x447013&&_0x2737b3[_0x496f2c(0x1c8)](0x194),_0x447013;};}function handleError(_0x1ea914,_0x18aafa){return _0x18aafa=_0x18aafa||0x1f4,function(_0x11ea20){const _0x350e6f=a807_0x3252;logger[_0x350e6f(0x1d0)](_0x11ea20[_0x350e6f(0x1bd)]),_0x11ea20[_0x350e6f(0x1b2)]&&delete _0x11ea20['name'],_0x1ea914[_0x350e6f(0x1c2)](_0x18aafa)[_0x350e6f(0x1b3)](_0x11ea20);};}exports[a807_0x5616e6(0x1ac)]=function(_0x25703f,_0x56b47b){const _0x568f50=a807_0x5616e6;let _0x1653cf={};const _0x272dc7={},_0x4167a9={'count':0x0,'rows':[]},_0x142697=_[_0x568f50(0x1d4)](db[_0x568f50(0x1c5)][_0x568f50(0x1d1)],function(_0x205862){const _0x3d3a1e=_0x568f50;return{'name':_0x205862['fieldName'],'type':_0x205862['type'][_0x3d3a1e(0x1d8)]};});_0x272dc7[_0x568f50(0x1af)]=_['map'](_0x142697,_0x568f50(0x1b2)),_0x272dc7[_0x568f50(0x1b0)]=_[_0x568f50(0x1d6)](_0x25703f[_0x568f50(0x1b0)]),_0x272dc7[_0x568f50(0x1cd)]=_['intersection'](_0x272dc7['model'],_0x272dc7[_0x568f50(0x1b0)]),_0x1653cf[_0x568f50(0x1d9)]=_[_0x568f50(0x1bb)](_0x272dc7[_0x568f50(0x1af)],qs[_0x568f50(0x1bf)](_0x25703f['query']['fields'])),_0x1653cf[_0x568f50(0x1d9)]=_0x1653cf[_0x568f50(0x1d9)][_0x568f50(0x1ab)]?_0x1653cf[_0x568f50(0x1d9)]:_0x272dc7['model'];typeof _0x25703f[_0x568f50(0x1b0)]['nolimit']===_0x568f50(0x1ba)&&(_0x1653cf[_0x568f50(0x1c0)]=qs[_0x568f50(0x1c0)](_0x25703f[_0x568f50(0x1b0)][_0x568f50(0x1c0)]),_0x1653cf[_0x568f50(0x1bc)]=qs[_0x568f50(0x1bc)](_0x25703f[_0x568f50(0x1b0)]['offset']));_0x1653cf[_0x568f50(0x1b7)]=qs[_0x568f50(0x1ad)](_0x25703f[_0x568f50(0x1b0)][_0x568f50(0x1ad)]),_0x1653cf[_0x568f50(0x1ce)]=qs['filters'](_[_0x568f50(0x1b9)](_0x25703f[_0x568f50(0x1b0)],_0x272dc7['filters']),_0x142697);_0x25703f[_0x568f50(0x1b0)][_0x568f50(0x1aa)]&&(_0x1653cf['where']=_[_0x568f50(0x1c4)](_0x1653cf[_0x568f50(0x1ce)],{[Op['or']]:_[_0x568f50(0x1d4)](_0x142697,function(_0x3b5127){const _0x4713ad=_0x568f50;if(_0x3b5127[_0x4713ad(0x1be)]!=='VIRTUAL'){const _0x1c7e39={};return _0x1c7e39[_0x3b5127[_0x4713ad(0x1b2)]]={[Op['like']]:'%'+_0x25703f[_0x4713ad(0x1b0)][_0x4713ad(0x1aa)]+'%'},_0x1c7e39;}})}));_0x1653cf=_[_0x568f50(0x1c4)]({},_0x1653cf,_0x25703f['options']);const _0x350d66={'where':_0x1653cf['where']};return db['UserProfileResource'][_0x568f50(0x1b4)](_0x350d66)['then'](function(_0x2a0a92){const _0x56cdf5=_0x568f50;return _0x4167a9[_0x56cdf5(0x1b4)]=_0x2a0a92,_0x25703f[_0x56cdf5(0x1b0)][_0x56cdf5(0x1d3)]&&(_0x1653cf[_0x56cdf5(0x1d7)]=[{'all':!![]}]),db[_0x56cdf5(0x1c5)][_0x56cdf5(0x1ca)](_0x1653cf);})['then'](function(_0x28bdc7){const _0x5608d9=_0x568f50;return _0x4167a9[_0x5608d9(0x1b8)]=_0x28bdc7,_0x4167a9;})[_0x568f50(0x1d5)](respondWithFilteredResult(_0x56b47b,_0x1653cf))[_0x568f50(0x1a9)](handleError(_0x56b47b,null));},exports['show']=function(_0x1f261e,_0x276ee0){const _0x437039=a807_0x5616e6;let _0x26bfcb={'raw':![],'where':{'id':_0x1f261e[_0x437039(0x1ae)]['id']}};const _0x46f498={};return _0x46f498[_0x437039(0x1af)]=_[_0x437039(0x1d6)](db[_0x437039(0x1c5)][_0x437039(0x1d1)]),_0x46f498['query']=_[_0x437039(0x1d6)](_0x1f261e[_0x437039(0x1b0)]),_0x46f498[_0x437039(0x1cd)]=_['intersection'](_0x46f498['model'],_0x46f498[_0x437039(0x1b0)]),_0x26bfcb['attributes']=_[_0x437039(0x1bb)](_0x46f498['model'],qs[_0x437039(0x1bf)](_0x1f261e['query'][_0x437039(0x1bf)])),_0x26bfcb['attributes']=_0x26bfcb[_0x437039(0x1d9)][_0x437039(0x1ab)]?_0x26bfcb['attributes']:_0x46f498['model'],_0x1f261e[_0x437039(0x1b0)][_0x437039(0x1d3)]&&(_0x26bfcb[_0x437039(0x1d7)]=[{'all':!![]}]),_0x26bfcb=_[_0x437039(0x1c4)]({},_0x26bfcb,_0x1f261e['options']),db[_0x437039(0x1c5)][_0x437039(0x1c1)](_0x26bfcb)['then'](handleEntityNotFound(_0x276ee0,null))['then'](respondWithResult(_0x276ee0,null))[_0x437039(0x1a9)](handleError(_0x276ee0,null));},exports[a807_0x5616e6(0x1b5)]=function(_0x30bebc,_0x36451e){const _0x35f3e1=a807_0x5616e6;return db[_0x35f3e1(0x1c5)][_0x35f3e1(0x1b5)](_0x30bebc[_0x35f3e1(0x1cb)],{})[_0x35f3e1(0x1d5)](respondWithResult(_0x36451e,0xc9))[_0x35f3e1(0x1a9)](handleError(_0x36451e,null));},exports[a807_0x5616e6(0x1b6)]=function(_0x3305a0,_0x16cf20){const _0xe3e840=a807_0x5616e6;return _0x3305a0[_0xe3e840(0x1cb)]['id']&&delete _0x3305a0[_0xe3e840(0x1cb)]['id'],db[_0xe3e840(0x1c5)][_0xe3e840(0x1c1)]({'where':{'id':_0x3305a0[_0xe3e840(0x1ae)]['id']}})[_0xe3e840(0x1d5)](handleEntityNotFound(_0x16cf20,null))['then'](saveUpdates(_0x3305a0['body'],null))[_0xe3e840(0x1d5)](respondWithResult(_0x16cf20,null))['catch'](handleError(_0x16cf20,null));},exports[a807_0x5616e6(0x1d2)]=function(_0x385208,_0x920e0b){const _0x3955c6=a807_0x5616e6;return db[_0x3955c6(0x1c5)][_0x3955c6(0x1c1)]({'where':{'id':_0x385208[_0x3955c6(0x1ae)]['id']}})['then'](handleEntityNotFound(_0x920e0b,null))['then'](removeEntity(_0x920e0b,null))[_0x3955c6(0x1a9)](handleError(_0x920e0b,null));},exports['describe']=function(_0x1988b8,_0x59e893){const _0x1f208c=a807_0x5616e6;return db[_0x1f208c(0x1c5)]['describe']()['then'](respondWithResult(_0x59e893,null))[_0x1f208c(0x1a9)](handleError(_0x59e893,null));};