1265fc7df3982b582f486af93a2b64938143b4d1
[motion-next.git] / server / api / jscriptyAnswerReport / jscriptyAnswerReport.controller.js
1 const a374_0x184d=['catch','rows','update','model','sequelize','type','api','undefined','JscriptyAnswerReport','destroy','params','where','../../components/parsers/qs','then','Content-Range','rawAttributes','name','like','fields','options','intersection','map','lodash','nolimit','offset','order','VIRTUAL','../../config/logger','length','attributes','json','create','query','error','body','includeAll','count','limit','sort','status','show','key','stack','keys','include','set','end','merge','send','describe','filters','findOne','fieldName','findAll'];(function(_0x41feb4,_0x184d01){const _0x563f7f=function(_0x20b564){while(--_0x20b564){_0x41feb4['push'](_0x41feb4['shift']());}};_0x563f7f(++_0x184d01);}(a374_0x184d,0x1a1));const a374_0x563f=function(_0x41feb4,_0x184d01){_0x41feb4=_0x41feb4-0x0;let _0x563f7f=a374_0x184d[_0x41feb4];return _0x563f7f;};const _0xacf6c4=a374_0x563f;'use strict';const _=require(_0xacf6c4('0x25')),qs=require(_0xacf6c4('0x1b')),logger=require(_0xacf6c4('0x2a'))(_0xacf6c4('0x15')),db=require('../../mysqldb')['db'],{Op}=require(_0xacf6c4('0x13'));function respondWithResult(_0x20b564,_0x307130){return _0x307130=_0x307130||0xc8,function(_0x577ce3){const _0xe17150=a374_0x563f;if(_0x577ce3)return _0x20b564[_0xe17150('0x0')](_0x307130)[_0xe17150('0x2d')](_0x577ce3);};}function respondWithFilteredResult(_0xbc839,_0x2f9d4a){return function(_0x6b925d){const _0x5ce494=a374_0x563f;if(_0x6b925d){const _0x32102e=_0x6b925d['count'],_0x1f86b0=_0x2f9d4a['offset'];let _0x4bce75=_0x2f9d4a['offset']+_0x2f9d4a[_0x5ce494('0x34')],_0x3564ce;return _0x4bce75>=_0x32102e?(_0x4bce75=_0x32102e,_0x3564ce=0xc8):_0x3564ce=0xce,_0xbc839[_0x5ce494('0x0')](_0x3564ce),_0xbc839[_0x5ce494('0x6')](_0x5ce494('0x1d'),_0x1f86b0+'-'+_0x4bce75+'/'+_0x32102e)[_0x5ce494('0x2d')](_0x6b925d);}return null;};}function saveUpdates(_0x54bee6){return function(_0x35fda2){const _0x551a44=a374_0x563f;if(_0x35fda2)return _0x35fda2[_0x551a44('0x11')](_0x54bee6)['then'](function(_0x104118){return _0x104118;});return null;};}function removeEntity(_0xf2a18b){return function(_0x17db67){const _0x1bcbd8=a374_0x563f;if(_0x17db67)return _0x17db67['destroy']()[_0x1bcbd8('0x1c')](function(){const _0x5880af=_0x1bcbd8;_0xf2a18b['status'](0xcc)[_0x5880af('0x7')]();});};}function handleEntityNotFound(_0xbe5168){return function(_0x1714d4){return!_0x1714d4&&_0xbe5168['sendStatus'](0x194),_0x1714d4;};}function handleError(_0x504944,_0x481f0f){return _0x481f0f=_0x481f0f||0x1f4,function(_0x16209a){const _0xc6c32d=a374_0x563f;logger[_0xc6c32d('0x30')](_0x16209a[_0xc6c32d('0x3')]),_0x16209a['name']&&delete _0x16209a['name'],_0x504944[_0xc6c32d('0x0')](_0x481f0f)[_0xc6c32d('0x9')](_0x16209a);};}exports['index']=function(_0x42cb6b,_0x477abf){const _0x3a8ba2=_0xacf6c4;let _0x56e86a={};const _0x1ab813={},_0x53d6ce={'count':0x0,'rows':[]},_0x534f6a=_['map'](db['JscriptyAnswerReport'][_0x3a8ba2('0x1e')],function(_0xa465f6){const _0x302a46=_0x3a8ba2;return{'name':_0xa465f6[_0x302a46('0xd')],'type':_0xa465f6[_0x302a46('0x14')][_0x302a46('0x2')]};});_0x1ab813[_0x3a8ba2('0x12')]=_[_0x3a8ba2('0x24')](_0x534f6a,'name'),_0x1ab813[_0x3a8ba2('0x2f')]=_[_0x3a8ba2('0x4')](_0x42cb6b['query']),_0x1ab813[_0x3a8ba2('0xb')]=_[_0x3a8ba2('0x23')](_0x1ab813['model'],_0x1ab813[_0x3a8ba2('0x2f')]),_0x56e86a[_0x3a8ba2('0x2c')]=_['intersection'](_0x1ab813['model'],qs[_0x3a8ba2('0x21')](_0x42cb6b[_0x3a8ba2('0x2f')][_0x3a8ba2('0x21')])),_0x56e86a[_0x3a8ba2('0x2c')]=_0x56e86a[_0x3a8ba2('0x2c')][_0x3a8ba2('0x2b')]?_0x56e86a['attributes']:_0x1ab813[_0x3a8ba2('0x12')];typeof _0x42cb6b[_0x3a8ba2('0x2f')][_0x3a8ba2('0x26')]===_0x3a8ba2('0x16')&&(_0x56e86a['limit']=qs['limit'](_0x42cb6b[_0x3a8ba2('0x2f')][_0x3a8ba2('0x34')]),_0x56e86a[_0x3a8ba2('0x27')]=qs[_0x3a8ba2('0x27')](_0x42cb6b[_0x3a8ba2('0x2f')][_0x3a8ba2('0x27')]));_0x56e86a[_0x3a8ba2('0x28')]=qs[_0x3a8ba2('0x35')](_0x42cb6b['query']['sort']),_0x56e86a['where']=qs['filters'](_['pick'](_0x42cb6b[_0x3a8ba2('0x2f')],_0x1ab813[_0x3a8ba2('0xb')]),_0x534f6a);_0x42cb6b[_0x3a8ba2('0x2f')]['filter']&&(_0x56e86a[_0x3a8ba2('0x1a')]=_['merge'](_0x56e86a[_0x3a8ba2('0x1a')],{[Op['or']]:_[_0x3a8ba2('0x24')](_0x534f6a,function(_0x4d567f){const _0x2bd6e3=_0x3a8ba2;if(_0x4d567f[_0x2bd6e3('0x14')]!==_0x2bd6e3('0x29')){const _0x553217={};return _0x553217[_0x4d567f[_0x2bd6e3('0x1f')]]={[Op[_0x2bd6e3('0x20')]]:'%'+_0x42cb6b[_0x2bd6e3('0x2f')]['filter']+'%'},_0x553217;}})}));_0x56e86a=_['merge']({},_0x56e86a,_0x42cb6b[_0x3a8ba2('0x22')]);const _0x43450e={'where':_0x56e86a['where']};return db['JscriptyAnswerReport'][_0x3a8ba2('0x33')](_0x43450e)[_0x3a8ba2('0x1c')](function(_0x38ee33){const _0x335d08=_0x3a8ba2;return _0x53d6ce[_0x335d08('0x33')]=_0x38ee33,_0x42cb6b[_0x335d08('0x2f')]['includeAll']&&(_0x56e86a['include']=[{'all':!![]}]),db[_0x335d08('0x17')][_0x335d08('0xe')](_0x56e86a);})[_0x3a8ba2('0x1c')](function(_0xbec016){const _0x5731e7=_0x3a8ba2;return _0x53d6ce[_0x5731e7('0x10')]=_0xbec016,_0x53d6ce;})[_0x3a8ba2('0x1c')](respondWithFilteredResult(_0x477abf,_0x56e86a))[_0x3a8ba2('0xf')](handleError(_0x477abf,null));},exports[_0xacf6c4('0x1')]=function(_0x52dccd,_0x13be7c){const _0x10b031=_0xacf6c4;let _0x5ca453={'raw':!![],'where':{'id':_0x52dccd['params']['id']}};const _0x37e813={};return _0x37e813[_0x10b031('0x12')]=_[_0x10b031('0x4')](db['JscriptyAnswerReport'][_0x10b031('0x1e')]),_0x37e813[_0x10b031('0x2f')]=_[_0x10b031('0x4')](_0x52dccd['query']),_0x37e813[_0x10b031('0xb')]=_['intersection'](_0x37e813[_0x10b031('0x12')],_0x37e813[_0x10b031('0x2f')]),_0x5ca453['attributes']=_[_0x10b031('0x23')](_0x37e813[_0x10b031('0x12')],qs[_0x10b031('0x21')](_0x52dccd[_0x10b031('0x2f')]['fields'])),_0x5ca453[_0x10b031('0x2c')]=_0x5ca453[_0x10b031('0x2c')][_0x10b031('0x2b')]?_0x5ca453[_0x10b031('0x2c')]:_0x37e813[_0x10b031('0x12')],_0x52dccd[_0x10b031('0x2f')][_0x10b031('0x32')]&&(_0x5ca453[_0x10b031('0x5')]=[{'all':!![]}]),_0x5ca453=_[_0x10b031('0x8')]({},_0x5ca453,_0x52dccd[_0x10b031('0x22')]),db[_0x10b031('0x17')]['findOne'](_0x5ca453)[_0x10b031('0x1c')](handleEntityNotFound(_0x13be7c,null))[_0x10b031('0x1c')](respondWithResult(_0x13be7c,null))[_0x10b031('0xf')](handleError(_0x13be7c,null));},exports[_0xacf6c4('0x2e')]=function(_0x6e238b,_0x11503a){const _0x1c7227=_0xacf6c4;return db[_0x1c7227('0x17')][_0x1c7227('0x2e')](_0x6e238b[_0x1c7227('0x31')],{})['then'](respondWithResult(_0x11503a,0xc9))[_0x1c7227('0xf')](handleError(_0x11503a,null));},exports[_0xacf6c4('0x11')]=function(_0xa9fb2a,_0x567e2a){const _0x443d63=_0xacf6c4;return _0xa9fb2a[_0x443d63('0x31')]['id']&&delete _0xa9fb2a[_0x443d63('0x31')]['id'],db[_0x443d63('0x17')][_0x443d63('0xc')]({'where':{'id':_0xa9fb2a[_0x443d63('0x19')]['id']}})[_0x443d63('0x1c')](handleEntityNotFound(_0x567e2a,null))[_0x443d63('0x1c')](saveUpdates(_0xa9fb2a[_0x443d63('0x31')],null))['then'](respondWithResult(_0x567e2a,null))[_0x443d63('0xf')](handleError(_0x567e2a,null));},exports[_0xacf6c4('0x18')]=function(_0x2a7c47,_0x3b7f79){const _0x4ff8e8=_0xacf6c4;return db['JscriptyAnswerReport']['findOne']({'where':{'id':_0x2a7c47[_0x4ff8e8('0x19')]['id']}})['then'](handleEntityNotFound(_0x3b7f79,null))[_0x4ff8e8('0x1c')](removeEntity(_0x3b7f79,null))['catch'](handleError(_0x3b7f79,null));},exports['describe']=function(_0xd6aea0,_0x11dbd4){const _0x3baae6=_0xacf6c4;return db['JscriptyAnswerReport'][_0x3baae6('0xa')]()[_0x3baae6('0x1c')](respondWithResult(_0x11dbd4,null))[_0x3baae6('0xf')](handleError(_0x11dbd4,null));};