7c39d1d06d141c32f15a6ffc40b9d15e866e4363
[motion-next.git] / server / api / intDynamics365Field / intDynamics365Field.controller.js
1 const a251_0x1663=['merge','sequelize','destroy','includeAll','sendStatus','include','rawAttributes','like','type','../../components/parsers/qs','VIRTUAL','stack','limit','count','body','model','nolimit','key','../../mysqldb','show','filter','undefined','name','rows','api','set','length','pick','index','findAll','attributes','update','fieldName','keys','create','status','send','filters','query','Content-Range','params','options','fields','lodash','then','json','findOne','where','offset','sort','catch','intersection','map','Dynamics365Field'];(function(_0x5ae103,_0x16631c){const _0x3cd11a=function(_0x55649f){while(--_0x55649f){_0x5ae103['push'](_0x5ae103['shift']());}};_0x3cd11a(++_0x16631c);}(a251_0x1663,0x1ac));const a251_0x3cd1=function(_0x5ae103,_0x16631c){_0x5ae103=_0x5ae103-0x0;let _0x3cd11a=a251_0x1663[_0x5ae103];return _0x3cd11a;};const _0x2e0c7c=a251_0x3cd1;'use strict';const _=require(_0x2e0c7c('0x2f')),qs=require(_0x2e0c7c('0xd')),logger=require('../../config/logger')(_0x2e0c7c('0x1c')),db=require(_0x2e0c7c('0x16'))['db'],{Op}=require(_0x2e0c7c('0x5'));function respondWithResult(_0x55649f,_0x4afd28){return _0x4afd28=_0x4afd28||0xc8,function(_0x1bfa01){const _0x3a4ee0=a251_0x3cd1;if(_0x1bfa01)return _0x55649f[_0x3a4ee0('0x27')](_0x4afd28)[_0x3a4ee0('0x31')](_0x1bfa01);};}function respondWithFilteredResult(_0x229069,_0x3c45d8){return function(_0x4a8585){const _0x1e2b92=a251_0x3cd1;if(_0x4a8585){const _0x39dcfd=_0x4a8585[_0x1e2b92('0x11')],_0x42aa71=_0x3c45d8['offset'];let _0x291b52=_0x3c45d8[_0x1e2b92('0x34')]+_0x3c45d8[_0x1e2b92('0x10')],_0x29757a;return _0x291b52>=_0x39dcfd?(_0x291b52=_0x39dcfd,_0x29757a=0xc8):_0x29757a=0xce,_0x229069['status'](_0x29757a),_0x229069[_0x1e2b92('0x1d')](_0x1e2b92('0x2b'),_0x42aa71+'-'+_0x291b52+'/'+_0x39dcfd)[_0x1e2b92('0x31')](_0x4a8585);}return null;};}function saveUpdates(_0xed6dc1){return function(_0x2cf6d3){const _0x254dd5=a251_0x3cd1;if(_0x2cf6d3)return _0x2cf6d3[_0x254dd5('0x23')](_0xed6dc1)[_0x254dd5('0x30')](function(_0x2d68ad){return _0x2d68ad;});return null;};}function removeEntity(_0x434d72){return function(_0x28737e){if(_0x28737e)return _0x28737e['destroy']()['then'](function(){const _0x54012b=a251_0x3cd1;_0x434d72[_0x54012b('0x27')](0xcc)['end']();});};}function handleEntityNotFound(_0x2db1fe){return function(_0x8d0179){const _0x550a60=a251_0x3cd1;return!_0x8d0179&&_0x2db1fe[_0x550a60('0x8')](0x194),_0x8d0179;};}function handleError(_0x2194b2,_0x289d32){return _0x289d32=_0x289d32||0x1f4,function(_0x4c45a0){const _0x12a441=a251_0x3cd1;logger['error'](_0x4c45a0[_0x12a441('0xf')]),_0x4c45a0[_0x12a441('0x1a')]&&delete _0x4c45a0[_0x12a441('0x1a')],_0x2194b2[_0x12a441('0x27')](_0x289d32)[_0x12a441('0x28')](_0x4c45a0);};}exports[_0x2e0c7c('0x20')]=function(_0xe42ea,_0x54f5ec){const _0x433d78=_0x2e0c7c;let _0x5418bf={};const _0x968553={},_0x6a8a81={'count':0x0,'rows':[]},_0x5ce219=_[_0x433d78('0x2')](db['Dynamics365Field']['rawAttributes'],function(_0x5cd6b3){const _0x545299=_0x433d78;return{'name':_0x5cd6b3[_0x545299('0x24')],'type':_0x5cd6b3[_0x545299('0xc')][_0x545299('0x15')]};});_0x968553['model']=_[_0x433d78('0x2')](_0x5ce219,_0x433d78('0x1a')),_0x968553[_0x433d78('0x2a')]=_[_0x433d78('0x25')](_0xe42ea[_0x433d78('0x2a')]),_0x968553[_0x433d78('0x29')]=_[_0x433d78('0x1')](_0x968553['model'],_0x968553[_0x433d78('0x2a')]),_0x5418bf[_0x433d78('0x22')]=_[_0x433d78('0x1')](_0x968553[_0x433d78('0x13')],qs[_0x433d78('0x2e')](_0xe42ea[_0x433d78('0x2a')][_0x433d78('0x2e')])),_0x5418bf[_0x433d78('0x22')]=_0x5418bf[_0x433d78('0x22')][_0x433d78('0x1e')]?_0x5418bf['attributes']:_0x968553[_0x433d78('0x13')];typeof _0xe42ea[_0x433d78('0x2a')][_0x433d78('0x14')]===_0x433d78('0x19')&&(_0x5418bf[_0x433d78('0x10')]=qs[_0x433d78('0x10')](_0xe42ea[_0x433d78('0x2a')][_0x433d78('0x10')]),_0x5418bf[_0x433d78('0x34')]=qs[_0x433d78('0x34')](_0xe42ea[_0x433d78('0x2a')]['offset']));_0x5418bf['order']=qs[_0x433d78('0x35')](_0xe42ea['query']['sort']),_0x5418bf['where']=qs[_0x433d78('0x29')](_[_0x433d78('0x1f')](_0xe42ea[_0x433d78('0x2a')],_0x968553[_0x433d78('0x29')]),_0x5ce219);_0xe42ea[_0x433d78('0x2a')][_0x433d78('0x18')]&&(_0x5418bf[_0x433d78('0x33')]=_[_0x433d78('0x4')](_0x5418bf['where'],{[Op['or']]:_[_0x433d78('0x2')](_0x5ce219,function(_0x41de4f){const _0x5c3689=_0x433d78;if(_0x41de4f[_0x5c3689('0xc')]!==_0x5c3689('0xe')){const _0x24df86={};return _0x24df86[_0x41de4f['name']]={[Op[_0x5c3689('0xb')]]:'%'+_0xe42ea[_0x5c3689('0x2a')]['filter']+'%'},_0x24df86;}})}));_0x5418bf=_[_0x433d78('0x4')]({},_0x5418bf,_0xe42ea[_0x433d78('0x2d')]);const _0xfceb97={'where':_0x5418bf[_0x433d78('0x33')]};return db['Dynamics365Field'][_0x433d78('0x11')](_0xfceb97)[_0x433d78('0x30')](function(_0xda4d3){const _0x3e5fa0=_0x433d78;return _0x6a8a81['count']=_0xda4d3,_0xe42ea[_0x3e5fa0('0x2a')][_0x3e5fa0('0x7')]&&(_0x5418bf['include']=[{'all':!![]}]),db[_0x3e5fa0('0x3')][_0x3e5fa0('0x21')](_0x5418bf);})[_0x433d78('0x30')](function(_0x2d7616){const _0x2a2221=_0x433d78;return _0x6a8a81[_0x2a2221('0x1b')]=_0x2d7616,_0x6a8a81;})[_0x433d78('0x30')](respondWithFilteredResult(_0x54f5ec,_0x5418bf))[_0x433d78('0x0')](handleError(_0x54f5ec,null));},exports[_0x2e0c7c('0x17')]=function(_0x38fb56,_0x2c552a){const _0x49ce06=_0x2e0c7c;let _0x32b9a1={'raw':!![],'where':{'id':_0x38fb56[_0x49ce06('0x2c')]['id']}};const _0x35f804={};return _0x35f804[_0x49ce06('0x13')]=_[_0x49ce06('0x25')](db[_0x49ce06('0x3')][_0x49ce06('0xa')]),_0x35f804[_0x49ce06('0x2a')]=_[_0x49ce06('0x25')](_0x38fb56[_0x49ce06('0x2a')]),_0x35f804['filters']=_[_0x49ce06('0x1')](_0x35f804[_0x49ce06('0x13')],_0x35f804['query']),_0x32b9a1[_0x49ce06('0x22')]=_[_0x49ce06('0x1')](_0x35f804[_0x49ce06('0x13')],qs[_0x49ce06('0x2e')](_0x38fb56[_0x49ce06('0x2a')][_0x49ce06('0x2e')])),_0x32b9a1['attributes']=_0x32b9a1[_0x49ce06('0x22')][_0x49ce06('0x1e')]?_0x32b9a1[_0x49ce06('0x22')]:_0x35f804[_0x49ce06('0x13')],_0x38fb56[_0x49ce06('0x2a')][_0x49ce06('0x7')]&&(_0x32b9a1[_0x49ce06('0x9')]=[{'all':!![]}]),_0x32b9a1=_[_0x49ce06('0x4')]({},_0x32b9a1,_0x38fb56[_0x49ce06('0x2d')]),db[_0x49ce06('0x3')][_0x49ce06('0x32')](_0x32b9a1)[_0x49ce06('0x30')](handleEntityNotFound(_0x2c552a,null))[_0x49ce06('0x30')](respondWithResult(_0x2c552a,null))[_0x49ce06('0x0')](handleError(_0x2c552a,null));},exports['create']=function(_0x57fa96,_0x4265e6){const _0x80ece4=_0x2e0c7c;return db['Dynamics365Field'][_0x80ece4('0x26')](_0x57fa96[_0x80ece4('0x12')],{})['then'](respondWithResult(_0x4265e6,0xc9))[_0x80ece4('0x0')](handleError(_0x4265e6,null));},exports[_0x2e0c7c('0x23')]=function(_0x11af0f,_0x3e9bec){const _0x47639e=_0x2e0c7c;return _0x11af0f[_0x47639e('0x12')]['id']&&delete _0x11af0f[_0x47639e('0x12')]['id'],db[_0x47639e('0x3')][_0x47639e('0x32')]({'where':{'id':_0x11af0f[_0x47639e('0x2c')]['id']}})[_0x47639e('0x30')](handleEntityNotFound(_0x3e9bec,null))[_0x47639e('0x30')](saveUpdates(_0x11af0f[_0x47639e('0x12')],null))[_0x47639e('0x30')](respondWithResult(_0x3e9bec,null))['catch'](handleError(_0x3e9bec,null));},exports[_0x2e0c7c('0x6')]=function(_0x3d1d7e,_0x24d25e){const _0x446299=_0x2e0c7c;return db[_0x446299('0x3')][_0x446299('0x32')]({'where':{'id':_0x3d1d7e[_0x446299('0x2c')]['id']}})[_0x446299('0x30')](handleEntityNotFound(_0x24d25e,null))[_0x446299('0x30')](removeEntity(_0x24d25e,null))['catch'](handleError(_0x24d25e,null));};