f4c2ea3eb55edc655709a4c676b1fc362bd2fe53
[motion-next.git] / server / api / jscriptyAnswerReport / jscriptyAnswerReport.controller.js
1 const a374_0x4354=['set','where','JscriptyAnswerReport','describe','body','attributes','params','undefined','rawAttributes','query','sequelize','limit','json','../../components/parsers/qs','sort','Content-Range','update','intersection','VIRTUAL','status','send','options','rows','model','destroy','filters','index','then','error','type','merge','findOne','keys','length','offset','lodash','end','stack','like','filter','order','api','map','sendStatus','findAll','count','nolimit','../../mysqldb','../../config/logger','include','create','fields','key','catch','name'];(function(_0x806885,_0x435450){const _0x2c9acd=function(_0x46fc4f){while(--_0x46fc4f){_0x806885['push'](_0x806885['shift']());}};_0x2c9acd(++_0x435450);}(a374_0x4354,0x1ea));const a374_0x2c9a=function(_0x806885,_0x435450){_0x806885=_0x806885-0x0;let _0x2c9acd=a374_0x4354[_0x806885];return _0x2c9acd;};const _0x328512=a374_0x2c9a;'use strict';const _=require(_0x328512('0x28')),qs=require(_0x328512('0x12')),logger=require(_0x328512('0x35'))(_0x328512('0x2e')),db=require(_0x328512('0x34'))['db'],{Op}=require(_0x328512('0xf'));function respondWithResult(_0x46fc4f,_0x1fb2f0){return _0x1fb2f0=_0x1fb2f0||0xc8,function(_0x35affb){const _0x5e76fb=a374_0x2c9a;if(_0x35affb)return _0x46fc4f[_0x5e76fb('0x18')](_0x1fb2f0)[_0x5e76fb('0x11')](_0x35affb);};}function respondWithFilteredResult(_0x318ed9,_0x78ab8a){return function(_0x29d038){const _0x406286=a374_0x2c9a;if(_0x29d038){const _0x1a8f4b=_0x29d038['count'],_0x2b1b67=_0x78ab8a['offset'];let _0x318700=_0x78ab8a[_0x406286('0x27')]+_0x78ab8a['limit'],_0x3b02b6;return _0x318700>=_0x1a8f4b?(_0x318700=_0x1a8f4b,_0x3b02b6=0xc8):_0x3b02b6=0xce,_0x318ed9['status'](_0x3b02b6),_0x318ed9[_0x406286('0x5')](_0x406286('0x14'),_0x2b1b67+'-'+_0x318700+'/'+_0x1a8f4b)['json'](_0x29d038);}return null;};}function saveUpdates(_0x416ac1){return function(_0x57d53a){const _0x14fcda=a374_0x2c9a;if(_0x57d53a)return _0x57d53a[_0x14fcda('0x15')](_0x416ac1)[_0x14fcda('0x20')](function(_0x243204){return _0x243204;});return null;};}function removeEntity(_0x3f2eb7){return function(_0x61641b){const _0x3fc9b0=a374_0x2c9a;if(_0x61641b)return _0x61641b[_0x3fc9b0('0x1d')]()['then'](function(){const _0x1a71d5=_0x3fc9b0;_0x3f2eb7['status'](0xcc)[_0x1a71d5('0x29')]();});};}function handleEntityNotFound(_0x2d1f6c){return function(_0x3817fe){const _0x493059=a374_0x2c9a;return!_0x3817fe&&_0x2d1f6c[_0x493059('0x30')](0x194),_0x3817fe;};}function handleError(_0x449173,_0x36cb41){return _0x36cb41=_0x36cb41||0x1f4,function(_0x520342){const _0x3ea8e2=a374_0x2c9a;logger[_0x3ea8e2('0x21')](_0x520342[_0x3ea8e2('0x2a')]),_0x520342[_0x3ea8e2('0x4')]&&delete _0x520342[_0x3ea8e2('0x4')],_0x449173['status'](_0x36cb41)[_0x3ea8e2('0x19')](_0x520342);};}exports[_0x328512('0x1f')]=function(_0x25bd70,_0x5482fd){const _0x57cd31=_0x328512;let _0x531998={};const _0x40497c={},_0xe6fbf8={'count':0x0,'rows':[]},_0x586726=_[_0x57cd31('0x2f')](db[_0x57cd31('0x7')][_0x57cd31('0xd')],function(_0x5d688e){const _0x10fc78=_0x57cd31;return{'name':_0x5d688e['fieldName'],'type':_0x5d688e['type'][_0x10fc78('0x2')]};});_0x40497c[_0x57cd31('0x1c')]=_[_0x57cd31('0x2f')](_0x586726,_0x57cd31('0x4')),_0x40497c[_0x57cd31('0xe')]=_[_0x57cd31('0x25')](_0x25bd70[_0x57cd31('0xe')]),_0x40497c[_0x57cd31('0x1e')]=_['intersection'](_0x40497c['model'],_0x40497c[_0x57cd31('0xe')]),_0x531998['attributes']=_[_0x57cd31('0x16')](_0x40497c['model'],qs[_0x57cd31('0x1')](_0x25bd70[_0x57cd31('0xe')][_0x57cd31('0x1')])),_0x531998[_0x57cd31('0xa')]=_0x531998[_0x57cd31('0xa')][_0x57cd31('0x26')]?_0x531998['attributes']:_0x40497c[_0x57cd31('0x1c')];typeof _0x25bd70[_0x57cd31('0xe')][_0x57cd31('0x33')]===_0x57cd31('0xc')&&(_0x531998[_0x57cd31('0x10')]=qs[_0x57cd31('0x10')](_0x25bd70['query'][_0x57cd31('0x10')]),_0x531998[_0x57cd31('0x27')]=qs['offset'](_0x25bd70[_0x57cd31('0xe')]['offset']));_0x531998[_0x57cd31('0x2d')]=qs['sort'](_0x25bd70[_0x57cd31('0xe')][_0x57cd31('0x13')]),_0x531998[_0x57cd31('0x6')]=qs[_0x57cd31('0x1e')](_['pick'](_0x25bd70[_0x57cd31('0xe')],_0x40497c[_0x57cd31('0x1e')]),_0x586726);_0x25bd70[_0x57cd31('0xe')][_0x57cd31('0x2c')]&&(_0x531998['where']=_['merge'](_0x531998[_0x57cd31('0x6')],{[Op['or']]:_['map'](_0x586726,function(_0x47f2e4){const _0x162ec9=_0x57cd31;if(_0x47f2e4[_0x162ec9('0x22')]!==_0x162ec9('0x17')){const _0x4cfc4d={};return _0x4cfc4d[_0x47f2e4['name']]={[Op[_0x162ec9('0x2b')]]:'%'+_0x25bd70[_0x162ec9('0xe')]['filter']+'%'},_0x4cfc4d;}})}));_0x531998=_[_0x57cd31('0x23')]({},_0x531998,_0x25bd70['options']);const _0x3c60a9={'where':_0x531998['where']};return db[_0x57cd31('0x7')][_0x57cd31('0x32')](_0x3c60a9)[_0x57cd31('0x20')](function(_0x1f79c1){const _0x2937a0=_0x57cd31;return _0xe6fbf8[_0x2937a0('0x32')]=_0x1f79c1,_0x25bd70[_0x2937a0('0xe')]['includeAll']&&(_0x531998[_0x2937a0('0x36')]=[{'all':!![]}]),db[_0x2937a0('0x7')][_0x2937a0('0x31')](_0x531998);})[_0x57cd31('0x20')](function(_0x2e3c12){const _0x588698=_0x57cd31;return _0xe6fbf8[_0x588698('0x1b')]=_0x2e3c12,_0xe6fbf8;})[_0x57cd31('0x20')](respondWithFilteredResult(_0x5482fd,_0x531998))[_0x57cd31('0x3')](handleError(_0x5482fd,null));},exports['show']=function(_0x9320d0,_0x25d926){const _0x54613f=_0x328512;let _0x570f2f={'raw':!![],'where':{'id':_0x9320d0[_0x54613f('0xb')]['id']}};const _0x38092c={};return _0x38092c[_0x54613f('0x1c')]=_[_0x54613f('0x25')](db[_0x54613f('0x7')][_0x54613f('0xd')]),_0x38092c[_0x54613f('0xe')]=_['keys'](_0x9320d0[_0x54613f('0xe')]),_0x38092c[_0x54613f('0x1e')]=_[_0x54613f('0x16')](_0x38092c[_0x54613f('0x1c')],_0x38092c[_0x54613f('0xe')]),_0x570f2f[_0x54613f('0xa')]=_[_0x54613f('0x16')](_0x38092c[_0x54613f('0x1c')],qs[_0x54613f('0x1')](_0x9320d0[_0x54613f('0xe')][_0x54613f('0x1')])),_0x570f2f['attributes']=_0x570f2f[_0x54613f('0xa')][_0x54613f('0x26')]?_0x570f2f[_0x54613f('0xa')]:_0x38092c[_0x54613f('0x1c')],_0x9320d0[_0x54613f('0xe')]['includeAll']&&(_0x570f2f[_0x54613f('0x36')]=[{'all':!![]}]),_0x570f2f=_[_0x54613f('0x23')]({},_0x570f2f,_0x9320d0[_0x54613f('0x1a')]),db[_0x54613f('0x7')][_0x54613f('0x24')](_0x570f2f)[_0x54613f('0x20')](handleEntityNotFound(_0x25d926,null))[_0x54613f('0x20')](respondWithResult(_0x25d926,null))[_0x54613f('0x3')](handleError(_0x25d926,null));},exports[_0x328512('0x0')]=function(_0x56a0a0,_0xcea5eb){const _0x5467c0=_0x328512;return db[_0x5467c0('0x7')]['create'](_0x56a0a0[_0x5467c0('0x9')],{})[_0x5467c0('0x20')](respondWithResult(_0xcea5eb,0xc9))[_0x5467c0('0x3')](handleError(_0xcea5eb,null));},exports[_0x328512('0x15')]=function(_0x29094d,_0x8e4936){const _0x4790f8=_0x328512;return _0x29094d['body']['id']&&delete _0x29094d['body']['id'],db[_0x4790f8('0x7')]['findOne']({'where':{'id':_0x29094d[_0x4790f8('0xb')]['id']}})[_0x4790f8('0x20')](handleEntityNotFound(_0x8e4936,null))[_0x4790f8('0x20')](saveUpdates(_0x29094d[_0x4790f8('0x9')],null))[_0x4790f8('0x20')](respondWithResult(_0x8e4936,null))[_0x4790f8('0x3')](handleError(_0x8e4936,null));},exports[_0x328512('0x1d')]=function(_0x1e2c7e,_0x1e1f0){const _0x1e7f66=_0x328512;return db[_0x1e7f66('0x7')]['findOne']({'where':{'id':_0x1e2c7e[_0x1e7f66('0xb')]['id']}})[_0x1e7f66('0x20')](handleEntityNotFound(_0x1e1f0,null))[_0x1e7f66('0x20')](removeEntity(_0x1e1f0,null))['catch'](handleError(_0x1e1f0,null));},exports['describe']=function(_0x55c2d5,_0x57ca4d){const _0x1dfbe3=_0x328512;return db['JscriptyAnswerReport'][_0x1dfbe3('0x8')]()[_0x1dfbe3('0x20')](respondWithResult(_0x57ca4d,null))['catch'](handleError(_0x57ca4d,null));};