7fadea6c61721ed4be743247594fed20035c3955
[motion-next.git] / server / api / intServicenowField / intServicenowField.controller.js
1 const a303_0x4e4d=['rows','ServicenowField','query','offset','like','filters','length','index','sort','name','fields','../../mysqldb','update','pick','set','findOne','api','attributes','sendStatus','create','include','merge','filter','stack','fieldName','../../components/parsers/qs','params','intersection','destroy','catch','sequelize','includeAll','then','rawAttributes','json','limit','error','where','nolimit','model','VIRTUAL','count','status','keys','map','../../config/logger','body','lodash','type','Content-Range','order','key','send'];(function(_0x53a9f0,_0x4e4d09){const _0x373c83=function(_0x3968a0){while(--_0x3968a0){_0x53a9f0['push'](_0x53a9f0['shift']());}};_0x373c83(++_0x4e4d09);}(a303_0x4e4d,0x198));const a303_0x373c=function(_0x53a9f0,_0x4e4d09){_0x53a9f0=_0x53a9f0-0x0;let _0x373c83=a303_0x4e4d[_0x53a9f0];return _0x373c83;};const _0x505398=a303_0x373c;'use strict';const _=require(_0x505398('0xa')),qs=require(_0x505398('0x29')),logger=require(_0x505398('0x8'))(_0x505398('0x20')),db=require(_0x505398('0x1b'))['db'],{Op}=require(_0x505398('0x2e'));function respondWithResult(_0x3968a0,_0xa0789f){return _0xa0789f=_0xa0789f||0xc8,function(_0x3918c3){const _0x5499e8=a303_0x373c;if(_0x3918c3)return _0x3968a0[_0x5499e8('0x5')](_0xa0789f)['json'](_0x3918c3);};}function respondWithFilteredResult(_0x4ddb5b,_0x956a0d){return function(_0x464d73){const _0xa07ccb=a303_0x373c;if(_0x464d73){const _0x125d14=_0x464d73[_0xa07ccb('0x4')],_0x50a5e4=_0x956a0d[_0xa07ccb('0x13')];let _0x1ace64=_0x956a0d['offset']+_0x956a0d[_0xa07ccb('0x33')],_0x3f1387;return _0x1ace64>=_0x125d14?(_0x1ace64=_0x125d14,_0x3f1387=0xc8):_0x3f1387=0xce,_0x4ddb5b[_0xa07ccb('0x5')](_0x3f1387),_0x4ddb5b[_0xa07ccb('0x1e')](_0xa07ccb('0xc'),_0x50a5e4+'-'+_0x1ace64+'/'+_0x125d14)[_0xa07ccb('0x32')](_0x464d73);}return null;};}function saveUpdates(_0x613ee3){return function(_0x305a3a){const _0x55c081=a303_0x373c;if(_0x305a3a)return _0x305a3a[_0x55c081('0x1c')](_0x613ee3)[_0x55c081('0x30')](function(_0x178528){return _0x178528;});return null;};}function removeEntity(_0x2f67ba){return function(_0x5e95b7){const _0x4105f4=a303_0x373c;if(_0x5e95b7)return _0x5e95b7['destroy']()[_0x4105f4('0x30')](function(){_0x2f67ba['status'](0xcc)['end']();});};}function handleEntityNotFound(_0x4a56a3){return function(_0x43e15c){const _0x5eff89=a303_0x373c;return!_0x43e15c&&_0x4a56a3[_0x5eff89('0x22')](0x194),_0x43e15c;};}function handleError(_0x2fba12,_0x27a34a){return _0x27a34a=_0x27a34a||0x1f4,function(_0x5c5bfd){const _0x5f1b48=a303_0x373c;logger[_0x5f1b48('0x34')](_0x5c5bfd[_0x5f1b48('0x27')]),_0x5c5bfd[_0x5f1b48('0x19')]&&delete _0x5c5bfd[_0x5f1b48('0x19')],_0x2fba12[_0x5f1b48('0x5')](_0x27a34a)[_0x5f1b48('0xf')](_0x5c5bfd);};}exports[_0x505398('0x17')]=function(_0x17c027,_0xe6c1aa){const _0x13d7ce=_0x505398;let _0x267909={};const _0x5052b9={},_0x29c413={'count':0x0,'rows':[]},_0x2268a3=_[_0x13d7ce('0x7')](db[_0x13d7ce('0x11')][_0x13d7ce('0x31')],function(_0x34dd62){const _0x15d70c=_0x13d7ce;return{'name':_0x34dd62[_0x15d70c('0x28')],'type':_0x34dd62['type'][_0x15d70c('0xe')]};});_0x5052b9[_0x13d7ce('0x2')]=_['map'](_0x2268a3,'name'),_0x5052b9[_0x13d7ce('0x12')]=_[_0x13d7ce('0x6')](_0x17c027[_0x13d7ce('0x12')]),_0x5052b9[_0x13d7ce('0x15')]=_[_0x13d7ce('0x2b')](_0x5052b9[_0x13d7ce('0x2')],_0x5052b9[_0x13d7ce('0x12')]),_0x267909[_0x13d7ce('0x21')]=_['intersection'](_0x5052b9['model'],qs[_0x13d7ce('0x1a')](_0x17c027['query'][_0x13d7ce('0x1a')])),_0x267909[_0x13d7ce('0x21')]=_0x267909['attributes'][_0x13d7ce('0x16')]?_0x267909['attributes']:_0x5052b9['model'];typeof _0x17c027['query'][_0x13d7ce('0x1')]==='undefined'&&(_0x267909[_0x13d7ce('0x33')]=qs[_0x13d7ce('0x33')](_0x17c027[_0x13d7ce('0x12')][_0x13d7ce('0x33')]),_0x267909[_0x13d7ce('0x13')]=qs[_0x13d7ce('0x13')](_0x17c027['query'][_0x13d7ce('0x13')]));_0x267909[_0x13d7ce('0xd')]=qs[_0x13d7ce('0x18')](_0x17c027[_0x13d7ce('0x12')][_0x13d7ce('0x18')]),_0x267909[_0x13d7ce('0x0')]=qs[_0x13d7ce('0x15')](_[_0x13d7ce('0x1d')](_0x17c027[_0x13d7ce('0x12')],_0x5052b9['filters']),_0x2268a3);_0x17c027[_0x13d7ce('0x12')][_0x13d7ce('0x26')]&&(_0x267909[_0x13d7ce('0x0')]=_[_0x13d7ce('0x25')](_0x267909['where'],{[Op['or']]:_[_0x13d7ce('0x7')](_0x2268a3,function(_0x343397){const _0x5a299e=_0x13d7ce;if(_0x343397[_0x5a299e('0xb')]!==_0x5a299e('0x3')){const _0x33a127={};return _0x33a127[_0x343397[_0x5a299e('0x19')]]={[Op[_0x5a299e('0x14')]]:'%'+_0x17c027[_0x5a299e('0x12')][_0x5a299e('0x26')]+'%'},_0x33a127;}})}));_0x267909=_[_0x13d7ce('0x25')]({},_0x267909,_0x17c027['options']);const _0x7f8f64={'where':_0x267909[_0x13d7ce('0x0')]};return db[_0x13d7ce('0x11')][_0x13d7ce('0x4')](_0x7f8f64)['then'](function(_0xf342e2){const _0x15f0be=_0x13d7ce;return _0x29c413['count']=_0xf342e2,_0x17c027[_0x15f0be('0x12')][_0x15f0be('0x2f')]&&(_0x267909[_0x15f0be('0x24')]=[{'all':!![]}]),db[_0x15f0be('0x11')]['findAll'](_0x267909);})[_0x13d7ce('0x30')](function(_0x3c752e){const _0x20aa52=_0x13d7ce;return _0x29c413[_0x20aa52('0x10')]=_0x3c752e,_0x29c413;})[_0x13d7ce('0x30')](respondWithFilteredResult(_0xe6c1aa,_0x267909))[_0x13d7ce('0x2d')](handleError(_0xe6c1aa,null));},exports['show']=function(_0x284c28,_0x267c11){const _0x45031b=_0x505398;let _0x39094f={'raw':!![],'where':{'id':_0x284c28[_0x45031b('0x2a')]['id']}};const _0x2867f7={};return _0x2867f7['model']=_[_0x45031b('0x6')](db[_0x45031b('0x11')][_0x45031b('0x31')]),_0x2867f7[_0x45031b('0x12')]=_[_0x45031b('0x6')](_0x284c28[_0x45031b('0x12')]),_0x2867f7[_0x45031b('0x15')]=_[_0x45031b('0x2b')](_0x2867f7[_0x45031b('0x2')],_0x2867f7[_0x45031b('0x12')]),_0x39094f[_0x45031b('0x21')]=_[_0x45031b('0x2b')](_0x2867f7['model'],qs['fields'](_0x284c28[_0x45031b('0x12')][_0x45031b('0x1a')])),_0x39094f[_0x45031b('0x21')]=_0x39094f[_0x45031b('0x21')]['length']?_0x39094f[_0x45031b('0x21')]:_0x2867f7[_0x45031b('0x2')],_0x284c28['query']['includeAll']&&(_0x39094f['include']=[{'all':!![]}]),_0x39094f=_[_0x45031b('0x25')]({},_0x39094f,_0x284c28['options']),db[_0x45031b('0x11')][_0x45031b('0x1f')](_0x39094f)[_0x45031b('0x30')](handleEntityNotFound(_0x267c11,null))[_0x45031b('0x30')](respondWithResult(_0x267c11,null))[_0x45031b('0x2d')](handleError(_0x267c11,null));},exports[_0x505398('0x23')]=function(_0x5b4240,_0x5eb009){const _0x2a44ba=_0x505398;return db[_0x2a44ba('0x11')]['create'](_0x5b4240[_0x2a44ba('0x9')],{})[_0x2a44ba('0x30')](respondWithResult(_0x5eb009,0xc9))[_0x2a44ba('0x2d')](handleError(_0x5eb009,null));},exports[_0x505398('0x1c')]=function(_0x38b170,_0x36f22d){const _0x1a6431=_0x505398;return _0x38b170[_0x1a6431('0x9')]['id']&&delete _0x38b170[_0x1a6431('0x9')]['id'],db[_0x1a6431('0x11')][_0x1a6431('0x1f')]({'where':{'id':_0x38b170[_0x1a6431('0x2a')]['id']}})['then'](handleEntityNotFound(_0x36f22d,null))['then'](saveUpdates(_0x38b170['body'],null))[_0x1a6431('0x30')](respondWithResult(_0x36f22d,null))[_0x1a6431('0x2d')](handleError(_0x36f22d,null));},exports[_0x505398('0x2c')]=function(_0x2dc370,_0x528dbe){const _0x1054c3=_0x505398;return db[_0x1054c3('0x11')][_0x1054c3('0x1f')]({'where':{'id':_0x2dc370['params']['id']}})[_0x1054c3('0x30')](handleEntityNotFound(_0x528dbe,null))['then'](removeEntity(_0x528dbe,null))[_0x1054c3('0x2d')](handleError(_0x528dbe,null));};