d4f9045dfa38a471f5cc5973e4d829af0e2cb96d
[motion-next.git] / server / api / jscriptyAnswerReport / jscriptyAnswerReport.controller.js
1 const a374_0xaf85=['order','model','sequelize','Content-Range','VIRTUAL','map','error','intersection','status','stack','nolimit','show','where','lodash','params','api','update','sort','catch','count','../../mysqldb','set','rawAttributes','end','type','options','like','findOne','key','filters','attributes','rows','includeAll','sendStatus','limit','destroy','length','filter','name','keys','describe','then','../../config/logger','fieldName','query','JscriptyAnswerReport','merge','offset','body','include'];(function(_0x1118e6,_0xaf851b){const _0x3ea173=function(_0x518492){while(--_0x518492){_0x1118e6['push'](_0x1118e6['shift']());}};_0x3ea173(++_0xaf851b);}(a374_0xaf85,0x12b));const a374_0x3ea1=function(_0x1118e6,_0xaf851b){_0x1118e6=_0x1118e6-0x0;let _0x3ea173=a374_0xaf85[_0x1118e6];return _0x3ea173;};const _0x586138=a374_0x3ea1;'use strict';const _=require(_0x586138('0xe')),qs=require('../../components/parsers/qs'),logger=require(_0x586138('0x2b'))(_0x586138('0x10')),db=require(_0x586138('0x15'))['db'],{Op}=require(_0x586138('0x3'));function respondWithResult(_0x518492,_0x2776c5){return _0x2776c5=_0x2776c5||0xc8,function(_0x2a8afc){if(_0x2a8afc)return _0x518492['status'](_0x2776c5)['json'](_0x2a8afc);};}function respondWithFilteredResult(_0x25fdd9,_0x881e47){return function(_0x317b26){const _0x4285a4=a374_0x3ea1;if(_0x317b26){const _0x1aaa68=_0x317b26[_0x4285a4('0x14')],_0x4c788f=_0x881e47['offset'];let _0x3a3ca8=_0x881e47[_0x4285a4('0x30')]+_0x881e47[_0x4285a4('0x23')],_0x3c58a6;return _0x3a3ca8>=_0x1aaa68?(_0x3a3ca8=_0x1aaa68,_0x3c58a6=0xc8):_0x3c58a6=0xce,_0x25fdd9[_0x4285a4('0x9')](_0x3c58a6),_0x25fdd9[_0x4285a4('0x16')](_0x4285a4('0x4'),_0x4c788f+'-'+_0x3a3ca8+'/'+_0x1aaa68)['json'](_0x317b26);}return null;};}function saveUpdates(_0x5266c2){return function(_0x10ca90){const _0x8240c0=a374_0x3ea1;if(_0x10ca90)return _0x10ca90[_0x8240c0('0x11')](_0x5266c2)[_0x8240c0('0x2a')](function(_0x3e2742){return _0x3e2742;});return null;};}function removeEntity(_0x2c77de){return function(_0x38b310){const _0x12da49=a374_0x3ea1;if(_0x38b310)return _0x38b310[_0x12da49('0x24')]()[_0x12da49('0x2a')](function(){const _0x342867=_0x12da49;_0x2c77de[_0x342867('0x9')](0xcc)[_0x342867('0x18')]();});};}function handleEntityNotFound(_0x26f9ec){return function(_0x51333e){const _0x369a4e=a374_0x3ea1;return!_0x51333e&&_0x26f9ec[_0x369a4e('0x22')](0x194),_0x51333e;};}function handleError(_0x426e1f,_0x2d5e34){return _0x2d5e34=_0x2d5e34||0x1f4,function(_0x5ae4b2){const _0x23562d=a374_0x3ea1;logger[_0x23562d('0x7')](_0x5ae4b2[_0x23562d('0xa')]),_0x5ae4b2[_0x23562d('0x27')]&&delete _0x5ae4b2[_0x23562d('0x27')],_0x426e1f['status'](_0x2d5e34)['send'](_0x5ae4b2);};}exports['index']=function(_0x167037,_0x3fba4e){const _0x5e7a20=_0x586138;let _0x4db133={};const _0x1890a3={},_0x1a20e2={'count':0x0,'rows':[]},_0x4d16d9=_[_0x5e7a20('0x6')](db[_0x5e7a20('0x2e')][_0x5e7a20('0x17')],function(_0x5a81cd){const _0x434cab=_0x5e7a20;return{'name':_0x5a81cd[_0x434cab('0x2c')],'type':_0x5a81cd['type'][_0x434cab('0x1d')]};});_0x1890a3[_0x5e7a20('0x2')]=_['map'](_0x4d16d9,_0x5e7a20('0x27')),_0x1890a3[_0x5e7a20('0x2d')]=_[_0x5e7a20('0x28')](_0x167037[_0x5e7a20('0x2d')]),_0x1890a3[_0x5e7a20('0x1e')]=_[_0x5e7a20('0x8')](_0x1890a3[_0x5e7a20('0x2')],_0x1890a3[_0x5e7a20('0x2d')]),_0x4db133[_0x5e7a20('0x1f')]=_['intersection'](_0x1890a3['model'],qs['fields'](_0x167037[_0x5e7a20('0x2d')]['fields'])),_0x4db133[_0x5e7a20('0x1f')]=_0x4db133[_0x5e7a20('0x1f')]['length']?_0x4db133[_0x5e7a20('0x1f')]:_0x1890a3['model'];typeof _0x167037[_0x5e7a20('0x2d')][_0x5e7a20('0xb')]==='undefined'&&(_0x4db133[_0x5e7a20('0x23')]=qs[_0x5e7a20('0x23')](_0x167037[_0x5e7a20('0x2d')]['limit']),_0x4db133[_0x5e7a20('0x30')]=qs[_0x5e7a20('0x30')](_0x167037[_0x5e7a20('0x2d')]['offset']));_0x4db133[_0x5e7a20('0x1')]=qs[_0x5e7a20('0x12')](_0x167037[_0x5e7a20('0x2d')][_0x5e7a20('0x12')]),_0x4db133[_0x5e7a20('0xd')]=qs[_0x5e7a20('0x1e')](_['pick'](_0x167037[_0x5e7a20('0x2d')],_0x1890a3['filters']),_0x4d16d9);_0x167037[_0x5e7a20('0x2d')][_0x5e7a20('0x26')]&&(_0x4db133[_0x5e7a20('0xd')]=_['merge'](_0x4db133[_0x5e7a20('0xd')],{[Op['or']]:_[_0x5e7a20('0x6')](_0x4d16d9,function(_0x2e5011){const _0x3a431c=_0x5e7a20;if(_0x2e5011[_0x3a431c('0x19')]!==_0x3a431c('0x5')){const _0x419e38={};return _0x419e38[_0x2e5011[_0x3a431c('0x27')]]={[Op[_0x3a431c('0x1b')]]:'%'+_0x167037['query']['filter']+'%'},_0x419e38;}})}));_0x4db133=_[_0x5e7a20('0x2f')]({},_0x4db133,_0x167037['options']);const _0x27c502={'where':_0x4db133[_0x5e7a20('0xd')]};return db[_0x5e7a20('0x2e')][_0x5e7a20('0x14')](_0x27c502)[_0x5e7a20('0x2a')](function(_0x9f2f94){const _0x538033=_0x5e7a20;return _0x1a20e2[_0x538033('0x14')]=_0x9f2f94,_0x167037[_0x538033('0x2d')][_0x538033('0x21')]&&(_0x4db133[_0x538033('0x0')]=[{'all':!![]}]),db['JscriptyAnswerReport']['findAll'](_0x4db133);})[_0x5e7a20('0x2a')](function(_0x50a0e0){const _0x3bddc8=_0x5e7a20;return _0x1a20e2[_0x3bddc8('0x20')]=_0x50a0e0,_0x1a20e2;})['then'](respondWithFilteredResult(_0x3fba4e,_0x4db133))['catch'](handleError(_0x3fba4e,null));},exports[_0x586138('0xc')]=function(_0x50301f,_0x2adbcb){const _0x9a4122=_0x586138;let _0x49006d={'raw':!![],'where':{'id':_0x50301f['params']['id']}};const _0x2c877e={};return _0x2c877e[_0x9a4122('0x2')]=_[_0x9a4122('0x28')](db[_0x9a4122('0x2e')][_0x9a4122('0x17')]),_0x2c877e[_0x9a4122('0x2d')]=_[_0x9a4122('0x28')](_0x50301f[_0x9a4122('0x2d')]),_0x2c877e[_0x9a4122('0x1e')]=_[_0x9a4122('0x8')](_0x2c877e['model'],_0x2c877e[_0x9a4122('0x2d')]),_0x49006d[_0x9a4122('0x1f')]=_[_0x9a4122('0x8')](_0x2c877e[_0x9a4122('0x2')],qs['fields'](_0x50301f[_0x9a4122('0x2d')]['fields'])),_0x49006d[_0x9a4122('0x1f')]=_0x49006d[_0x9a4122('0x1f')][_0x9a4122('0x25')]?_0x49006d[_0x9a4122('0x1f')]:_0x2c877e[_0x9a4122('0x2')],_0x50301f[_0x9a4122('0x2d')][_0x9a4122('0x21')]&&(_0x49006d['include']=[{'all':!![]}]),_0x49006d=_[_0x9a4122('0x2f')]({},_0x49006d,_0x50301f[_0x9a4122('0x1a')]),db[_0x9a4122('0x2e')][_0x9a4122('0x1c')](_0x49006d)[_0x9a4122('0x2a')](handleEntityNotFound(_0x2adbcb,null))[_0x9a4122('0x2a')](respondWithResult(_0x2adbcb,null))[_0x9a4122('0x13')](handleError(_0x2adbcb,null));},exports['create']=function(_0x3a10f3,_0x5e77c8){const _0x197636=_0x586138;return db['JscriptyAnswerReport']['create'](_0x3a10f3[_0x197636('0x31')],{})['then'](respondWithResult(_0x5e77c8,0xc9))[_0x197636('0x13')](handleError(_0x5e77c8,null));},exports[_0x586138('0x11')]=function(_0x182598,_0x464dff){const _0x5f3b97=_0x586138;return _0x182598[_0x5f3b97('0x31')]['id']&&delete _0x182598[_0x5f3b97('0x31')]['id'],db[_0x5f3b97('0x2e')][_0x5f3b97('0x1c')]({'where':{'id':_0x182598[_0x5f3b97('0xf')]['id']}})['then'](handleEntityNotFound(_0x464dff,null))[_0x5f3b97('0x2a')](saveUpdates(_0x182598[_0x5f3b97('0x31')],null))[_0x5f3b97('0x2a')](respondWithResult(_0x464dff,null))[_0x5f3b97('0x13')](handleError(_0x464dff,null));},exports[_0x586138('0x24')]=function(_0x456559,_0x49b7e8){const _0x56600a=_0x586138;return db['JscriptyAnswerReport'][_0x56600a('0x1c')]({'where':{'id':_0x456559['params']['id']}})[_0x56600a('0x2a')](handleEntityNotFound(_0x49b7e8,null))['then'](removeEntity(_0x49b7e8,null))[_0x56600a('0x13')](handleError(_0x49b7e8,null));},exports[_0x586138('0x29')]=function(_0x21f907,_0x4bb68f){const _0x56d1fa=_0x586138;return db[_0x56d1fa('0x2e')]['describe']()[_0x56d1fa('0x2a')](respondWithResult(_0x4bb68f,null))['catch'](handleError(_0x4bb68f,null));};