Built motion from commit df3e9871f6bcc3432fec345b2f4facbd4dba8b5c. Version 3.0.0...
[motion-next.git] / server / api / userProfileResource / userProfileResource.controller.js
1 const a674_0x1301=['error','body','params','filter','Content-Range','send','model','length','rawAttributes','filters','intersection','query','fields','api','attributes','destroy','pick','name','VIRTUAL','sequelize','status','catch','nolimit','fieldName','options','create','UserProfileResource','count','keys','limit','describe','update','rows','then','order','offset','sort','undefined','index','findOne','like','merge','where','includeAll','json','set','include'];(function(_0x5680f3,_0x1301fb){const _0xfed06b=function(_0x5bd6f7){while(--_0x5bd6f7){_0x5680f3['push'](_0x5680f3['shift']());}};_0xfed06b(++_0x1301fb);}(a674_0x1301,0x1f2));const a674_0xfed0=function(_0x5680f3,_0x1301fb){_0x5680f3=_0x5680f3-0x0;let _0xfed06b=a674_0x1301[_0x5680f3];return _0xfed06b;};const _0x5991a1=a674_0xfed0;'use strict';const _=require('lodash'),qs=require('../../components/parsers/qs'),logger=require('../../config/logger')(_0x5991a1('0x20')),db=require('../../mysqldb')['db'],{Op}=require(_0x5991a1('0x26'));function respondWithResult(_0x5bd6f7,_0x3a7c97){return _0x3a7c97=_0x3a7c97||0xc8,function(_0xe9c51a){const _0x3211f5=a674_0xfed0;if(_0xe9c51a)return _0x5bd6f7[_0x3211f5('0x27')](_0x3a7c97)[_0x3211f5('0x10')](_0xe9c51a);};}function respondWithFilteredResult(_0xc59c3c,_0x5007f3){return function(_0x51b575){const _0x396ce4=a674_0xfed0;if(_0x51b575){const _0x216bbb=_0x51b575['count'],_0x3b7dd8=_0x5007f3['offset'];let _0x2cb466=_0x5007f3['offset']+_0x5007f3['limit'],_0x1e8e18;return _0x2cb466>=_0x216bbb?(_0x2cb466=_0x216bbb,_0x1e8e18=0xc8):_0x1e8e18=0xce,_0xc59c3c['status'](_0x1e8e18),_0xc59c3c[_0x396ce4('0x11')](_0x396ce4('0x17'),_0x3b7dd8+'-'+_0x2cb466+'/'+_0x216bbb)['json'](_0x51b575);}return null;};}function saveUpdates(_0xfa2b67){return function(_0x4be98b){const _0x6ae0f=a674_0xfed0;if(_0x4be98b)return _0x4be98b[_0x6ae0f('0x3')](_0xfa2b67)[_0x6ae0f('0x5')](function(_0x4532e6){return _0x4532e6;});return null;};}function removeEntity(_0x25aae1){return function(_0x48af53){const _0x457421=a674_0xfed0;if(_0x48af53)return _0x48af53[_0x457421('0x22')]()['then'](function(){const _0x3a40ab=_0x457421;_0x25aae1[_0x3a40ab('0x27')](0xcc)['end']();});};}function handleEntityNotFound(_0x5b7113){return function(_0x828c76){return!_0x828c76&&_0x5b7113['sendStatus'](0x194),_0x828c76;};}function handleError(_0x2fdfde,_0xccc884){return _0xccc884=_0xccc884||0x1f4,function(_0x142a9a){const _0x412420=a674_0xfed0;logger[_0x412420('0x13')](_0x142a9a['stack']),_0x142a9a['name']&&delete _0x142a9a['name'],_0x2fdfde[_0x412420('0x27')](_0xccc884)[_0x412420('0x18')](_0x142a9a);};}exports[_0x5991a1('0xa')]=function(_0xb430a7,_0x26c7cc){const _0x2024e1=_0x5991a1;let _0x3a06da={};const _0x320299={},_0x5e932a={'count':0x0,'rows':[]},_0x2c477a=_['map'](db[_0x2024e1('0x2d')][_0x2024e1('0x1b')],function(_0x45390d){const _0x42402e=_0x2024e1;return{'name':_0x45390d[_0x42402e('0x2a')],'type':_0x45390d['type']['key']};});_0x320299[_0x2024e1('0x19')]=_['map'](_0x2c477a,'name'),_0x320299[_0x2024e1('0x1e')]=_[_0x2024e1('0x0')](_0xb430a7['query']),_0x320299['filters']=_[_0x2024e1('0x1d')](_0x320299[_0x2024e1('0x19')],_0x320299['query']),_0x3a06da[_0x2024e1('0x21')]=_[_0x2024e1('0x1d')](_0x320299[_0x2024e1('0x19')],qs['fields'](_0xb430a7['query'][_0x2024e1('0x1f')])),_0x3a06da[_0x2024e1('0x21')]=_0x3a06da[_0x2024e1('0x21')][_0x2024e1('0x1a')]?_0x3a06da[_0x2024e1('0x21')]:_0x320299[_0x2024e1('0x19')];typeof _0xb430a7[_0x2024e1('0x1e')][_0x2024e1('0x29')]===_0x2024e1('0x9')&&(_0x3a06da[_0x2024e1('0x1')]=qs['limit'](_0xb430a7[_0x2024e1('0x1e')][_0x2024e1('0x1')]),_0x3a06da[_0x2024e1('0x7')]=qs[_0x2024e1('0x7')](_0xb430a7[_0x2024e1('0x1e')][_0x2024e1('0x7')]));_0x3a06da[_0x2024e1('0x6')]=qs[_0x2024e1('0x8')](_0xb430a7[_0x2024e1('0x1e')][_0x2024e1('0x8')]),_0x3a06da['where']=qs[_0x2024e1('0x1c')](_[_0x2024e1('0x23')](_0xb430a7[_0x2024e1('0x1e')],_0x320299[_0x2024e1('0x1c')]),_0x2c477a);_0xb430a7[_0x2024e1('0x1e')][_0x2024e1('0x16')]&&(_0x3a06da[_0x2024e1('0xe')]=_[_0x2024e1('0xd')](_0x3a06da['where'],{[Op['or']]:_['map'](_0x2c477a,function(_0x364d78){const _0x6b8ad0=_0x2024e1;if(_0x364d78['type']!==_0x6b8ad0('0x25')){const _0xc7daf1={};return _0xc7daf1[_0x364d78[_0x6b8ad0('0x24')]]={[Op[_0x6b8ad0('0xc')]]:'%'+_0xb430a7[_0x6b8ad0('0x1e')]['filter']+'%'},_0xc7daf1;}})}));_0x3a06da=_[_0x2024e1('0xd')]({},_0x3a06da,_0xb430a7['options']);const _0x3ba4bc={'where':_0x3a06da['where']};return db[_0x2024e1('0x2d')]['count'](_0x3ba4bc)[_0x2024e1('0x5')](function(_0x55de47){const _0x5899e9=_0x2024e1;return _0x5e932a[_0x5899e9('0x2e')]=_0x55de47,_0xb430a7[_0x5899e9('0x1e')][_0x5899e9('0xf')]&&(_0x3a06da[_0x5899e9('0x12')]=[{'all':!![]}]),db[_0x5899e9('0x2d')]['findAll'](_0x3a06da);})[_0x2024e1('0x5')](function(_0xc7ce0a){const _0x104532=_0x2024e1;return _0x5e932a[_0x104532('0x4')]=_0xc7ce0a,_0x5e932a;})['then'](respondWithFilteredResult(_0x26c7cc,_0x3a06da))[_0x2024e1('0x28')](handleError(_0x26c7cc,null));},exports['show']=function(_0x1d08da,_0x2fe40e){const _0x1e7700=_0x5991a1;let _0xb60f4d={'raw':![],'where':{'id':_0x1d08da[_0x1e7700('0x15')]['id']}};const _0x5db586={};return _0x5db586[_0x1e7700('0x19')]=_['keys'](db['UserProfileResource'][_0x1e7700('0x1b')]),_0x5db586[_0x1e7700('0x1e')]=_[_0x1e7700('0x0')](_0x1d08da[_0x1e7700('0x1e')]),_0x5db586[_0x1e7700('0x1c')]=_[_0x1e7700('0x1d')](_0x5db586[_0x1e7700('0x19')],_0x5db586[_0x1e7700('0x1e')]),_0xb60f4d['attributes']=_[_0x1e7700('0x1d')](_0x5db586[_0x1e7700('0x19')],qs[_0x1e7700('0x1f')](_0x1d08da[_0x1e7700('0x1e')][_0x1e7700('0x1f')])),_0xb60f4d[_0x1e7700('0x21')]=_0xb60f4d[_0x1e7700('0x21')][_0x1e7700('0x1a')]?_0xb60f4d[_0x1e7700('0x21')]:_0x5db586['model'],_0x1d08da[_0x1e7700('0x1e')][_0x1e7700('0xf')]&&(_0xb60f4d[_0x1e7700('0x12')]=[{'all':!![]}]),_0xb60f4d=_[_0x1e7700('0xd')]({},_0xb60f4d,_0x1d08da[_0x1e7700('0x2b')]),db[_0x1e7700('0x2d')][_0x1e7700('0xb')](_0xb60f4d)[_0x1e7700('0x5')](handleEntityNotFound(_0x2fe40e,null))[_0x1e7700('0x5')](respondWithResult(_0x2fe40e,null))[_0x1e7700('0x28')](handleError(_0x2fe40e,null));},exports[_0x5991a1('0x2c')]=function(_0x56c6f5,_0x22a602){const _0xf45f0b=_0x5991a1;return db[_0xf45f0b('0x2d')][_0xf45f0b('0x2c')](_0x56c6f5[_0xf45f0b('0x14')],{})[_0xf45f0b('0x5')](respondWithResult(_0x22a602,0xc9))[_0xf45f0b('0x28')](handleError(_0x22a602,null));},exports[_0x5991a1('0x3')]=function(_0xb31d69,_0x3eea6c){const _0x231eec=_0x5991a1;return _0xb31d69[_0x231eec('0x14')]['id']&&delete _0xb31d69[_0x231eec('0x14')]['id'],db[_0x231eec('0x2d')][_0x231eec('0xb')]({'where':{'id':_0xb31d69['params']['id']}})[_0x231eec('0x5')](handleEntityNotFound(_0x3eea6c,null))['then'](saveUpdates(_0xb31d69['body'],null))['then'](respondWithResult(_0x3eea6c,null))[_0x231eec('0x28')](handleError(_0x3eea6c,null));},exports['destroy']=function(_0x4e39ef,_0xeb9271){const _0x250976=_0x5991a1;return db[_0x250976('0x2d')][_0x250976('0xb')]({'where':{'id':_0x4e39ef[_0x250976('0x15')]['id']}})[_0x250976('0x5')](handleEntityNotFound(_0xeb9271,null))[_0x250976('0x5')](removeEntity(_0xeb9271,null))['catch'](handleError(_0xeb9271,null));},exports[_0x5991a1('0x2')]=function(_0x55d54d,_0x1f4d3e){const _0x509125=_0x5991a1;return db[_0x509125('0x2d')][_0x509125('0x2')]()[_0x509125('0x5')](respondWithResult(_0x1f4d3e,null))['catch'](handleError(_0x1f4d3e,null));};