1f480dea7323bb3036d3217f1d7bb57699ca9012
[motion-next.git] / server / api / intFreshdeskField / intFreshdeskField.controller.js
1 const a264_0x1e5a=['where','intersection','findAll','end','../../components/parsers/qs','offset','type','attributes','order','create','body','../../config/logger','like','then','params','show','sequelize','FreshdeskField','include','count','limit','sendStatus','filter','stack','filters','fields','query','key','../../mysqldb','keys','model','set','includeAll','catch','status','sort','error','api','nolimit','Content-Range','map','rawAttributes','merge','length','options','destroy','json','name','findOne'];(function(_0x25bec3,_0x1e5afb){const _0x13677c=function(_0xfab628){while(--_0xfab628){_0x25bec3['push'](_0x25bec3['shift']());}};_0x13677c(++_0x1e5afb);}(a264_0x1e5a,0xad));const a264_0x1367=function(_0x25bec3,_0x1e5afb){_0x25bec3=_0x25bec3-0x0;let _0x13677c=a264_0x1e5a[_0x25bec3];return _0x13677c;};const _0x2ffc58=a264_0x1367;'use strict';const _=require('lodash'),qs=require(_0x2ffc58('0x1b')),logger=require(_0x2ffc58('0x22'))(_0x2ffc58('0xb')),db=require(_0x2ffc58('0x2'))['db'],{Op}=require(_0x2ffc58('0x27'));function respondWithResult(_0xfab628,_0x42ea0b){return _0x42ea0b=_0x42ea0b||0xc8,function(_0x6e6ec6){const _0x362dfa=a264_0x1367;if(_0x6e6ec6)return _0xfab628[_0x362dfa('0x8')](_0x42ea0b)[_0x362dfa('0x14')](_0x6e6ec6);};}function respondWithFilteredResult(_0x8027e9,_0x4e94d4){return function(_0x25373d){const _0x28ff73=a264_0x1367;if(_0x25373d){const _0x18c38f=_0x25373d[_0x28ff73('0x2a')],_0x13c618=_0x4e94d4['offset'];let _0x1d8563=_0x4e94d4[_0x28ff73('0x1c')]+_0x4e94d4[_0x28ff73('0x2b')],_0x579e77;return _0x1d8563>=_0x18c38f?(_0x1d8563=_0x18c38f,_0x579e77=0xc8):_0x579e77=0xce,_0x8027e9[_0x28ff73('0x8')](_0x579e77),_0x8027e9[_0x28ff73('0x5')](_0x28ff73('0xd'),_0x13c618+'-'+_0x1d8563+'/'+_0x18c38f)[_0x28ff73('0x14')](_0x25373d);}return null;};}function saveUpdates(_0x97ee37){return function(_0x58d379){const _0x2be930=a264_0x1367;if(_0x58d379)return _0x58d379['update'](_0x97ee37)[_0x2be930('0x24')](function(_0x1b7abf){return _0x1b7abf;});return null;};}function removeEntity(_0x37788a){return function(_0x318743){const _0x467acd=a264_0x1367;if(_0x318743)return _0x318743[_0x467acd('0x13')]()[_0x467acd('0x24')](function(){const _0x542ac0=_0x467acd;_0x37788a[_0x542ac0('0x8')](0xcc)[_0x542ac0('0x1a')]();});};}function handleEntityNotFound(_0x391899){return function(_0x354ff7){const _0x382e92=a264_0x1367;return!_0x354ff7&&_0x391899[_0x382e92('0x2c')](0x194),_0x354ff7;};}function handleError(_0x28a31c,_0x33ad24){return _0x33ad24=_0x33ad24||0x1f4,function(_0x364a0f){const _0x2ddb16=a264_0x1367;logger[_0x2ddb16('0xa')](_0x364a0f[_0x2ddb16('0x2e')]),_0x364a0f[_0x2ddb16('0x15')]&&delete _0x364a0f['name'],_0x28a31c[_0x2ddb16('0x8')](_0x33ad24)['send'](_0x364a0f);};}exports['index']=function(_0x10c249,_0x42a5eb){const _0x3dc3d6=_0x2ffc58;let _0x58bdbd={};const _0x2808f9={},_0x4a017c={'count':0x0,'rows':[]},_0x735abe=_[_0x3dc3d6('0xe')](db['FreshdeskField']['rawAttributes'],function(_0x157893){const _0x47016c=_0x3dc3d6;return{'name':_0x157893['fieldName'],'type':_0x157893[_0x47016c('0x1d')][_0x47016c('0x1')]};});_0x2808f9['model']=_[_0x3dc3d6('0xe')](_0x735abe,_0x3dc3d6('0x15')),_0x2808f9[_0x3dc3d6('0x0')]=_[_0x3dc3d6('0x3')](_0x10c249[_0x3dc3d6('0x0')]),_0x2808f9[_0x3dc3d6('0x2f')]=_[_0x3dc3d6('0x18')](_0x2808f9[_0x3dc3d6('0x4')],_0x2808f9[_0x3dc3d6('0x0')]),_0x58bdbd[_0x3dc3d6('0x1e')]=_[_0x3dc3d6('0x18')](_0x2808f9['model'],qs[_0x3dc3d6('0x30')](_0x10c249[_0x3dc3d6('0x0')][_0x3dc3d6('0x30')])),_0x58bdbd[_0x3dc3d6('0x1e')]=_0x58bdbd[_0x3dc3d6('0x1e')]['length']?_0x58bdbd[_0x3dc3d6('0x1e')]:_0x2808f9[_0x3dc3d6('0x4')];typeof _0x10c249[_0x3dc3d6('0x0')][_0x3dc3d6('0xc')]==='undefined'&&(_0x58bdbd['limit']=qs[_0x3dc3d6('0x2b')](_0x10c249[_0x3dc3d6('0x0')][_0x3dc3d6('0x2b')]),_0x58bdbd[_0x3dc3d6('0x1c')]=qs[_0x3dc3d6('0x1c')](_0x10c249[_0x3dc3d6('0x0')]['offset']));_0x58bdbd[_0x3dc3d6('0x1f')]=qs[_0x3dc3d6('0x9')](_0x10c249[_0x3dc3d6('0x0')][_0x3dc3d6('0x9')]),_0x58bdbd[_0x3dc3d6('0x17')]=qs['filters'](_['pick'](_0x10c249[_0x3dc3d6('0x0')],_0x2808f9[_0x3dc3d6('0x2f')]),_0x735abe);_0x10c249[_0x3dc3d6('0x0')][_0x3dc3d6('0x2d')]&&(_0x58bdbd[_0x3dc3d6('0x17')]=_[_0x3dc3d6('0x10')](_0x58bdbd['where'],{[Op['or']]:_[_0x3dc3d6('0xe')](_0x735abe,function(_0x55a1b6){const _0x3889fe=_0x3dc3d6;if(_0x55a1b6[_0x3889fe('0x1d')]!=='VIRTUAL'){const _0x4b0ec6={};return _0x4b0ec6[_0x55a1b6['name']]={[Op[_0x3889fe('0x23')]]:'%'+_0x10c249['query']['filter']+'%'},_0x4b0ec6;}})}));_0x58bdbd=_['merge']({},_0x58bdbd,_0x10c249[_0x3dc3d6('0x12')]);const _0x1b2a16={'where':_0x58bdbd[_0x3dc3d6('0x17')]};return db['FreshdeskField'][_0x3dc3d6('0x2a')](_0x1b2a16)[_0x3dc3d6('0x24')](function(_0x2d1a49){const _0x5a0b94=_0x3dc3d6;return _0x4a017c['count']=_0x2d1a49,_0x10c249[_0x5a0b94('0x0')][_0x5a0b94('0x6')]&&(_0x58bdbd[_0x5a0b94('0x29')]=[{'all':!![]}]),db['FreshdeskField'][_0x5a0b94('0x19')](_0x58bdbd);})[_0x3dc3d6('0x24')](function(_0x38f4e7){return _0x4a017c['rows']=_0x38f4e7,_0x4a017c;})[_0x3dc3d6('0x24')](respondWithFilteredResult(_0x42a5eb,_0x58bdbd))[_0x3dc3d6('0x7')](handleError(_0x42a5eb,null));},exports[_0x2ffc58('0x26')]=function(_0x36f380,_0x15c965){const _0x336dc6=_0x2ffc58;let _0x2e2c7f={'raw':!![],'where':{'id':_0x36f380[_0x336dc6('0x25')]['id']}};const _0x3ffb84={};return _0x3ffb84['model']=_[_0x336dc6('0x3')](db[_0x336dc6('0x28')][_0x336dc6('0xf')]),_0x3ffb84[_0x336dc6('0x0')]=_[_0x336dc6('0x3')](_0x36f380[_0x336dc6('0x0')]),_0x3ffb84[_0x336dc6('0x2f')]=_['intersection'](_0x3ffb84[_0x336dc6('0x4')],_0x3ffb84[_0x336dc6('0x0')]),_0x2e2c7f['attributes']=_['intersection'](_0x3ffb84[_0x336dc6('0x4')],qs[_0x336dc6('0x30')](_0x36f380[_0x336dc6('0x0')][_0x336dc6('0x30')])),_0x2e2c7f[_0x336dc6('0x1e')]=_0x2e2c7f[_0x336dc6('0x1e')][_0x336dc6('0x11')]?_0x2e2c7f[_0x336dc6('0x1e')]:_0x3ffb84[_0x336dc6('0x4')],_0x36f380[_0x336dc6('0x0')]['includeAll']&&(_0x2e2c7f[_0x336dc6('0x29')]=[{'all':!![]}]),_0x2e2c7f=_[_0x336dc6('0x10')]({},_0x2e2c7f,_0x36f380['options']),db[_0x336dc6('0x28')][_0x336dc6('0x16')](_0x2e2c7f)['then'](handleEntityNotFound(_0x15c965,null))['then'](respondWithResult(_0x15c965,null))[_0x336dc6('0x7')](handleError(_0x15c965,null));},exports[_0x2ffc58('0x20')]=function(_0x58d0d5,_0x2f5f83){const _0x45f3c3=_0x2ffc58;return db['FreshdeskField']['create'](_0x58d0d5[_0x45f3c3('0x21')],{})[_0x45f3c3('0x24')](respondWithResult(_0x2f5f83,0xc9))['catch'](handleError(_0x2f5f83,null));},exports['update']=function(_0x519e88,_0x590155){const _0x538b31=_0x2ffc58;return _0x519e88[_0x538b31('0x21')]['id']&&delete _0x519e88[_0x538b31('0x21')]['id'],db[_0x538b31('0x28')][_0x538b31('0x16')]({'where':{'id':_0x519e88['params']['id']}})[_0x538b31('0x24')](handleEntityNotFound(_0x590155,null))['then'](saveUpdates(_0x519e88[_0x538b31('0x21')],null))['then'](respondWithResult(_0x590155,null))[_0x538b31('0x7')](handleError(_0x590155,null));},exports[_0x2ffc58('0x13')]=function(_0x4b8dc3,_0x78fb13){const _0x3d1bed=_0x2ffc58;return db[_0x3d1bed('0x28')][_0x3d1bed('0x16')]({'where':{'id':_0x4b8dc3['params']['id']}})['then'](handleEntityNotFound(_0x78fb13,null))[_0x3d1bed('0x24')](removeEntity(_0x78fb13,null))[_0x3d1bed('0x7')](handleError(_0x78fb13,null));};