Built motion from commit 4a18b36e645f5fa4a517d36f9783bde259878164. Version 3.0.0...
[motion-next.git] / server / api / intDeskField / intDeskField.controller.js
1 const a238_0x3471=['../../config/logger','undefined','attributes','include','body','VIRTUAL','where','rawAttributes','options','pick','length','DeskField','count','api','sendStatus','destroy','rows','send','key','fieldName','lodash','fields','json','status','catch','model','set','intersection','name','findOne','nolimit','filter','create','query','params','includeAll','filters','type','update','end','merge','sort','then','like','Content-Range','stack','sequelize','limit','map','offset','keys','findAll'];(function(_0x1930d6,_0x34710b){const _0x23cedb=function(_0x23e877){while(--_0x23e877){_0x1930d6['push'](_0x1930d6['shift']());}};_0x23cedb(++_0x34710b);}(a238_0x3471,0x69));const a238_0x23ce=function(_0x1930d6,_0x34710b){_0x1930d6=_0x1930d6-0x0;let _0x23cedb=a238_0x3471[_0x1930d6];return _0x23cedb;};const _0x36d7f8=a238_0x23ce;'use strict';const _=require(_0x36d7f8('0x13')),qs=require('../../components/parsers/qs'),logger=require(_0x36d7f8('0x33'))(_0x36d7f8('0xc')),db=require('../../mysqldb')['db'],{Op}=require(_0x36d7f8('0x2d'));function respondWithResult(_0x23e877,_0x234b7a){return _0x234b7a=_0x234b7a||0xc8,function(_0x2dc7fa){const _0xf00c78=a238_0x23ce;if(_0x2dc7fa)return _0x23e877[_0xf00c78('0x16')](_0x234b7a)['json'](_0x2dc7fa);};}function respondWithFilteredResult(_0x30c03d,_0x16ee4b){return function(_0x43908c){const _0x3609cc=a238_0x23ce;if(_0x43908c){const _0x6ec798=_0x43908c[_0x3609cc('0xb')],_0xff11a=_0x16ee4b['offset'];let _0x1b7ddf=_0x16ee4b[_0x3609cc('0x30')]+_0x16ee4b[_0x3609cc('0x2e')],_0x37fa62;return _0x1b7ddf>=_0x6ec798?(_0x1b7ddf=_0x6ec798,_0x37fa62=0xc8):_0x37fa62=0xce,_0x30c03d['status'](_0x37fa62),_0x30c03d[_0x3609cc('0x19')](_0x3609cc('0x2b'),_0xff11a+'-'+_0x1b7ddf+'/'+_0x6ec798)[_0x3609cc('0x15')](_0x43908c);}return null;};}function saveUpdates(_0x46f70a){return function(_0x4a0f18){if(_0x4a0f18)return _0x4a0f18['update'](_0x46f70a)['then'](function(_0x15212b){return _0x15212b;});return null;};}function removeEntity(_0x57462e){return function(_0x2e84b5){const _0x24b1e8=a238_0x23ce;if(_0x2e84b5)return _0x2e84b5[_0x24b1e8('0xe')]()['then'](function(){const _0x1e7ead=_0x24b1e8;_0x57462e[_0x1e7ead('0x16')](0xcc)[_0x1e7ead('0x26')]();});};}function handleEntityNotFound(_0x21a99d){return function(_0x3a8361){const _0x5da882=a238_0x23ce;return!_0x3a8361&&_0x21a99d[_0x5da882('0xd')](0x194),_0x3a8361;};}function handleError(_0x2f9b09,_0x222205){return _0x222205=_0x222205||0x1f4,function(_0x32e721){const _0x10f285=a238_0x23ce;logger['error'](_0x32e721[_0x10f285('0x2c')]),_0x32e721[_0x10f285('0x1b')]&&delete _0x32e721[_0x10f285('0x1b')],_0x2f9b09[_0x10f285('0x16')](_0x222205)[_0x10f285('0x10')](_0x32e721);};}exports['index']=function(_0x398c08,_0x39bd3e){const _0x285b6a=_0x36d7f8;let _0x440dcf={};const _0x21db1f={},_0x183858={'count':0x0,'rows':[]},_0x237970=_['map'](db[_0x285b6a('0xa')][_0x285b6a('0x6')],function(_0x2aca23){const _0x38dd54=_0x285b6a;return{'name':_0x2aca23[_0x38dd54('0x12')],'type':_0x2aca23['type'][_0x38dd54('0x11')]};});_0x21db1f['model']=_['map'](_0x237970,_0x285b6a('0x1b')),_0x21db1f[_0x285b6a('0x20')]=_[_0x285b6a('0x31')](_0x398c08[_0x285b6a('0x20')]),_0x21db1f[_0x285b6a('0x23')]=_[_0x285b6a('0x1a')](_0x21db1f[_0x285b6a('0x18')],_0x21db1f['query']),_0x440dcf[_0x285b6a('0x1')]=_[_0x285b6a('0x1a')](_0x21db1f[_0x285b6a('0x18')],qs[_0x285b6a('0x14')](_0x398c08[_0x285b6a('0x20')]['fields'])),_0x440dcf['attributes']=_0x440dcf[_0x285b6a('0x1')]['length']?_0x440dcf[_0x285b6a('0x1')]:_0x21db1f[_0x285b6a('0x18')];typeof _0x398c08[_0x285b6a('0x20')][_0x285b6a('0x1d')]===_0x285b6a('0x0')&&(_0x440dcf[_0x285b6a('0x2e')]=qs[_0x285b6a('0x2e')](_0x398c08[_0x285b6a('0x20')][_0x285b6a('0x2e')]),_0x440dcf[_0x285b6a('0x30')]=qs[_0x285b6a('0x30')](_0x398c08['query'][_0x285b6a('0x30')]));_0x440dcf['order']=qs[_0x285b6a('0x28')](_0x398c08['query']['sort']),_0x440dcf[_0x285b6a('0x5')]=qs[_0x285b6a('0x23')](_[_0x285b6a('0x8')](_0x398c08[_0x285b6a('0x20')],_0x21db1f[_0x285b6a('0x23')]),_0x237970);_0x398c08['query'][_0x285b6a('0x1e')]&&(_0x440dcf[_0x285b6a('0x5')]=_['merge'](_0x440dcf['where'],{[Op['or']]:_[_0x285b6a('0x2f')](_0x237970,function(_0x2d52ee){const _0x4dc660=_0x285b6a;if(_0x2d52ee[_0x4dc660('0x24')]!==_0x4dc660('0x4')){const _0x1629c5={};return _0x1629c5[_0x2d52ee[_0x4dc660('0x1b')]]={[Op[_0x4dc660('0x2a')]]:'%'+_0x398c08[_0x4dc660('0x20')][_0x4dc660('0x1e')]+'%'},_0x1629c5;}})}));_0x440dcf=_['merge']({},_0x440dcf,_0x398c08[_0x285b6a('0x7')]);const _0x12cb92={'where':_0x440dcf[_0x285b6a('0x5')]};return db[_0x285b6a('0xa')][_0x285b6a('0xb')](_0x12cb92)['then'](function(_0x4df9ad){const _0x114d1a=_0x285b6a;return _0x183858[_0x114d1a('0xb')]=_0x4df9ad,_0x398c08[_0x114d1a('0x20')][_0x114d1a('0x22')]&&(_0x440dcf[_0x114d1a('0x2')]=[{'all':!![]}]),db[_0x114d1a('0xa')][_0x114d1a('0x32')](_0x440dcf);})['then'](function(_0x309b2b){const _0x469f60=_0x285b6a;return _0x183858[_0x469f60('0xf')]=_0x309b2b,_0x183858;})['then'](respondWithFilteredResult(_0x39bd3e,_0x440dcf))[_0x285b6a('0x17')](handleError(_0x39bd3e,null));},exports['show']=function(_0x2ccbf6,_0x1268c1){const _0x3e1d62=_0x36d7f8;let _0x3d6a65={'raw':!![],'where':{'id':_0x2ccbf6[_0x3e1d62('0x21')]['id']}};const _0x56f72c={};return _0x56f72c[_0x3e1d62('0x18')]=_[_0x3e1d62('0x31')](db[_0x3e1d62('0xa')]['rawAttributes']),_0x56f72c['query']=_[_0x3e1d62('0x31')](_0x2ccbf6[_0x3e1d62('0x20')]),_0x56f72c[_0x3e1d62('0x23')]=_[_0x3e1d62('0x1a')](_0x56f72c['model'],_0x56f72c[_0x3e1d62('0x20')]),_0x3d6a65[_0x3e1d62('0x1')]=_[_0x3e1d62('0x1a')](_0x56f72c[_0x3e1d62('0x18')],qs[_0x3e1d62('0x14')](_0x2ccbf6['query'][_0x3e1d62('0x14')])),_0x3d6a65[_0x3e1d62('0x1')]=_0x3d6a65[_0x3e1d62('0x1')][_0x3e1d62('0x9')]?_0x3d6a65[_0x3e1d62('0x1')]:_0x56f72c['model'],_0x2ccbf6[_0x3e1d62('0x20')][_0x3e1d62('0x22')]&&(_0x3d6a65[_0x3e1d62('0x2')]=[{'all':!![]}]),_0x3d6a65=_[_0x3e1d62('0x27')]({},_0x3d6a65,_0x2ccbf6[_0x3e1d62('0x7')]),db[_0x3e1d62('0xa')][_0x3e1d62('0x1c')](_0x3d6a65)[_0x3e1d62('0x29')](handleEntityNotFound(_0x1268c1,null))[_0x3e1d62('0x29')](respondWithResult(_0x1268c1,null))['catch'](handleError(_0x1268c1,null));},exports[_0x36d7f8('0x1f')]=function(_0x2a282e,_0x55e293){const _0x210fc7=_0x36d7f8;return db[_0x210fc7('0xa')][_0x210fc7('0x1f')](_0x2a282e[_0x210fc7('0x3')],{})['then'](respondWithResult(_0x55e293,0xc9))[_0x210fc7('0x17')](handleError(_0x55e293,null));},exports[_0x36d7f8('0x25')]=function(_0x235ec1,_0x10e1ac){const _0x39f755=_0x36d7f8;return _0x235ec1['body']['id']&&delete _0x235ec1[_0x39f755('0x3')]['id'],db[_0x39f755('0xa')][_0x39f755('0x1c')]({'where':{'id':_0x235ec1['params']['id']}})['then'](handleEntityNotFound(_0x10e1ac,null))[_0x39f755('0x29')](saveUpdates(_0x235ec1['body'],null))[_0x39f755('0x29')](respondWithResult(_0x10e1ac,null))[_0x39f755('0x17')](handleError(_0x10e1ac,null));},exports[_0x36d7f8('0xe')]=function(_0x10b1f7,_0x442c6f){const _0x2ecdf2=_0x36d7f8;return db['DeskField'][_0x2ecdf2('0x1c')]({'where':{'id':_0x10b1f7['params']['id']}})[_0x2ecdf2('0x29')](handleEntityNotFound(_0x442c6f,null))[_0x2ecdf2('0x29')](removeEntity(_0x442c6f,null))[_0x2ecdf2('0x17')](handleError(_0x442c6f,null));};