Built motion from commit 3e059bc2.|2.5.32
[motion2.git] / server / api / jscriptyAnswerReport / jscriptyAnswerReport.controller.js
index a07254f..b35a8a6 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x466d=['model','attributes','fields','nolimit','order','sort','where','pick','filter','merge','type','VIRTUAL','count','includeAll','rows','catch','show','params','length','include','options','find','create','body','describe','rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','ejs','crypto','jsforce','desk.js','to-csv','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','sendStatus','status','offset','limit','set','Content-Range','apply','reject','save','then','destroy','error','name','index','map','JscriptyAnswerReport','rawAttributes','key','query','keys','filters','intersection'];(function(_0x56cb80,_0x1ed34c){var _0x30e910=function(_0xc01d9c){while(--_0xc01d9c){_0x56cb80['push'](_0x56cb80['shift']());}};_0x30e910(++_0x1ed34c);}(_0x466d,0xeb));var _0xd466=function(_0x1bbc08,_0x444008){_0x1bbc08=_0x1bbc08-0x0;var _0x5d825b=_0x466d[_0x1bbc08];return _0x5d825b;};'use strict';var pdf=require('html-pdf');var emlformat=require('eml-format');var rimraf=require(_0xd466('0x0'));var zipdir=require(_0xd466('0x1'));var jsonpatch=require(_0xd466('0x2'));var rp=require(_0xd466('0x3'));var moment=require(_0xd466('0x4'));var BPromise=require('bluebird');var Mustache=require(_0xd466('0x5'));var util=require(_0xd466('0x6'));var path=require(_0xd466('0x7'));var sox=require('sox');var csv=require('to-csv');var ejs=require(_0xd466('0x8'));var fs=require('fs');var _=require('lodash');var squel=require('squel');var crypto=require(_0xd466('0x9'));var jsforce=require(_0xd466('0xa'));var deskjs=require(_0xd466('0xb'));var toCsv=require(_0xd466('0xc'));var querystring=require(_0xd466('0xd'));var Papa=require(_0xd466('0xe'));var Redis=require(_0xd466('0xf'));var authService=require(_0xd466('0x10'));var qs=require(_0xd466('0x11'));var as=require(_0xd466('0x12'));var hardwareService=require(_0xd466('0x13'));var logger=require(_0xd466('0x14'))(_0xd466('0x15'));var utils=require('../../config/utils');var config=require(_0xd466('0x16'));var licenseUtil=require('../../config/license/util');var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x5c6042,_0x18e95c){_0x18e95c=_0x18e95c||0xcc;return function(_0x1d308f){if(_0x1d308f){return _0x5c6042[_0xd466('0x17')](_0x18e95c);}return _0x5c6042['status'](_0x18e95c)['end']();};}function respondWithResult(_0x31730b,_0x8e3762){_0x8e3762=_0x8e3762||0xc8;return function(_0x4e72e8){if(_0x4e72e8){return _0x31730b[_0xd466('0x18')](_0x8e3762)['json'](_0x4e72e8);}};}function respondWithFilteredResult(_0x200f58,_0xf1715a){return function(_0x11ea31){if(_0x11ea31){var _0x30426f=_0x11ea31['count'],_0x3d5e77=_0xf1715a[_0xd466('0x19')],_0x176ee1=_0xf1715a[_0xd466('0x19')]+_0xf1715a[_0xd466('0x1a')],_0x3f6477;if(_0x176ee1>=_0x30426f){_0x176ee1=_0x30426f;_0x3f6477=0xc8;}else{_0x3f6477=0xce;}_0x200f58[_0xd466('0x18')](_0x3f6477);return _0x200f58[_0xd466('0x1b')](_0xd466('0x1c'),_0x3d5e77+'-'+_0x176ee1+'/'+_0x30426f)['json'](_0x11ea31);}return null;};}function patchUpdates(_0x3e2ae1){return function(_0x4022c7){try{jsonpatch[_0xd466('0x1d')](_0x4022c7,_0x3e2ae1,!![]);}catch(_0x362215){return BPromise[_0xd466('0x1e')](_0x362215);}return _0x4022c7[_0xd466('0x1f')]();};}function saveUpdates(_0x4ece70,_0x22a2b2){return function(_0x9172e4){if(_0x9172e4){return _0x9172e4['update'](_0x4ece70)[_0xd466('0x20')](function(_0x117e86){return _0x117e86;});}return null;};}function removeEntity(_0x1a2454,_0x1954f0){return function(_0x4a80c8){if(_0x4a80c8){return _0x4a80c8[_0xd466('0x21')]()[_0xd466('0x20')](function(){_0x1a2454[_0xd466('0x18')](0xcc)['end']();});}};}function handleEntityNotFound(_0x1ad351,_0x46cf6f){return function(_0x3f410e){if(!_0x3f410e){_0x1ad351[_0xd466('0x17')](0x194);}return _0x3f410e;};}function handleError(_0x39e611,_0x288aa9){_0x288aa9=_0x288aa9||0x1f4;return function(_0x3a284f){logger[_0xd466('0x22')](_0x3a284f['stack']);if(_0x3a284f[_0xd466('0x23')]){delete _0x3a284f['name'];}_0x39e611[_0xd466('0x18')](_0x288aa9)['send'](_0x3a284f);};}exports[_0xd466('0x24')]=function(_0x2a70d2,_0x14224a){var _0xf3076c={},_0x42e503={},_0x43e0e5={'count':0x0,'rows':[]};var _0x26d080=_[_0xd466('0x25')](db[_0xd466('0x26')][_0xd466('0x27')],function(_0x1435bb){return{'name':_0x1435bb['fieldName'],'type':_0x1435bb['type'][_0xd466('0x28')]};});_0x42e503['model']=_[_0xd466('0x25')](_0x26d080,'name');_0x42e503[_0xd466('0x29')]=_[_0xd466('0x2a')](_0x2a70d2['query']);_0x42e503[_0xd466('0x2b')]=_[_0xd466('0x2c')](_0x42e503[_0xd466('0x2d')],_0x42e503[_0xd466('0x29')]);_0xf3076c[_0xd466('0x2e')]=_[_0xd466('0x2c')](_0x42e503[_0xd466('0x2d')],qs['fields'](_0x2a70d2[_0xd466('0x29')][_0xd466('0x2f')]));_0xf3076c[_0xd466('0x2e')]=_0xf3076c['attributes']['length']?_0xf3076c['attributes']:_0x42e503[_0xd466('0x2d')];if(!_0x2a70d2['query']['hasOwnProperty'](_0xd466('0x30'))){_0xf3076c[_0xd466('0x1a')]=qs[_0xd466('0x1a')](_0x2a70d2['query']['limit']);_0xf3076c[_0xd466('0x19')]=qs[_0xd466('0x19')](_0x2a70d2[_0xd466('0x29')][_0xd466('0x19')]);}_0xf3076c[_0xd466('0x31')]=qs['sort'](_0x2a70d2[_0xd466('0x29')][_0xd466('0x32')]);_0xf3076c[_0xd466('0x33')]=qs[_0xd466('0x2b')](_[_0xd466('0x34')](_0x2a70d2[_0xd466('0x29')],_0x42e503[_0xd466('0x2b')]),_0x26d080);if(_0x2a70d2[_0xd466('0x29')][_0xd466('0x35')]){_0xf3076c[_0xd466('0x33')]=_[_0xd466('0x36')](_0xf3076c['where'],{'$or':_['map'](_0x26d080,function(_0x23faa7){if(_0x23faa7[_0xd466('0x37')]!==_0xd466('0x38')){var _0x5d51e6={};_0x5d51e6[_0x23faa7['name']]={'$like':'%'+_0x2a70d2['query'][_0xd466('0x35')]+'%'};return _0x5d51e6;}})});}_0xf3076c=_['merge']({},_0xf3076c,_0x2a70d2['options']);var _0x32c0db={'where':_0xf3076c['where']};return db[_0xd466('0x26')]['count'](_0x32c0db)[_0xd466('0x20')](function(_0xf40aaa){_0x43e0e5[_0xd466('0x39')]=_0xf40aaa;if(_0x2a70d2['query'][_0xd466('0x3a')]){_0xf3076c['include']=[{'all':!![]}];}return db['JscriptyAnswerReport']['findAll'](_0xf3076c);})[_0xd466('0x20')](function(_0x3c2947){_0x43e0e5[_0xd466('0x3b')]=_0x3c2947;return _0x43e0e5;})['then'](respondWithFilteredResult(_0x14224a,_0xf3076c))[_0xd466('0x3c')](handleError(_0x14224a,null));};exports[_0xd466('0x3d')]=function(_0x34da7a,_0x53e478){var _0x667336={'raw':!![],'where':{'id':_0x34da7a[_0xd466('0x3e')]['id']}},_0x2ee75a={};_0x2ee75a['model']=_['keys'](db['JscriptyAnswerReport'][_0xd466('0x27')]);_0x2ee75a[_0xd466('0x29')]=_[_0xd466('0x2a')](_0x34da7a[_0xd466('0x29')]);_0x2ee75a[_0xd466('0x2b')]=_[_0xd466('0x2c')](_0x2ee75a[_0xd466('0x2d')],_0x2ee75a[_0xd466('0x29')]);_0x667336[_0xd466('0x2e')]=_[_0xd466('0x2c')](_0x2ee75a[_0xd466('0x2d')],qs[_0xd466('0x2f')](_0x34da7a['query'][_0xd466('0x2f')]));_0x667336['attributes']=_0x667336[_0xd466('0x2e')][_0xd466('0x3f')]?_0x667336[_0xd466('0x2e')]:_0x2ee75a[_0xd466('0x2d')];if(_0x34da7a[_0xd466('0x29')][_0xd466('0x3a')]){_0x667336[_0xd466('0x40')]=[{'all':!![]}];}_0x667336=_['merge']({},_0x667336,_0x34da7a[_0xd466('0x41')]);return db[_0xd466('0x26')][_0xd466('0x42')](_0x667336)[_0xd466('0x20')](handleEntityNotFound(_0x53e478,null))[_0xd466('0x20')](respondWithResult(_0x53e478,null))['catch'](handleError(_0x53e478,null));};exports[_0xd466('0x43')]=function(_0x40ebee,_0xe6790f){return db[_0xd466('0x26')]['create'](_0x40ebee[_0xd466('0x44')],{})[_0xd466('0x20')](respondWithResult(_0xe6790f,0xc9))[_0xd466('0x3c')](handleError(_0xe6790f,null));};exports['update']=function(_0xabb1d9,_0x3672d6){if(_0xabb1d9[_0xd466('0x44')]['id']){delete _0xabb1d9['body']['id'];}return db['JscriptyAnswerReport']['find']({'where':{'id':_0xabb1d9[_0xd466('0x3e')]['id']}})['then'](handleEntityNotFound(_0x3672d6,null))['then'](saveUpdates(_0xabb1d9[_0xd466('0x44')],null))[_0xd466('0x20')](respondWithResult(_0x3672d6,null))[_0xd466('0x3c')](handleError(_0x3672d6,null));};exports[_0xd466('0x21')]=function(_0x3a4249,_0x51fd04){return db[_0xd466('0x26')][_0xd466('0x42')]({'where':{'id':_0x3a4249[_0xd466('0x3e')]['id']}})[_0xd466('0x20')](handleEntityNotFound(_0x51fd04,null))[_0xd466('0x20')](removeEntity(_0x51fd04,null))[_0xd466('0x3c')](handleError(_0x51fd04,null));};exports[_0xd466('0x45')]=function(_0x305f39,_0x14c343){return db[_0xd466('0x26')][_0xd466('0x45')]()['then'](respondWithResult(_0x14c343,null))[_0xd466('0x3c')](handleError(_0x14c343,null));};
\ No newline at end of file
+var _0xed1f=['where','pick','filter','merge','options','includeAll','include','findAll','rows','then','catch','show','params','keys','create','body','find','describe','eml-format','rimraf','request-promise','bluebird','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','crypto','jsforce','querystring','papaparse','../../components/auth/service','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','sendStatus','status','end','offset','undefined','limit','count','set','Content-Range','apply','reject','save','update','destroy','error','name','index','map','JscriptyAnswerReport','fieldName','type','model','query','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','sort'];(function(_0x1b74d3,_0x4a18c0){var _0x31cb88=function(_0x1a2a0e){while(--_0x1a2a0e){_0x1b74d3['push'](_0x1b74d3['shift']());}};_0x31cb88(++_0x4a18c0);}(_0xed1f,0x170));var _0xfed1=function(_0x5ddaac,_0x2697a8){_0x5ddaac=_0x5ddaac-0x0;var _0x2a9c58=_0xed1f[_0x5ddaac];return _0x2a9c58;};'use strict';var emlformat=require(_0xfed1('0x0'));var rimraf=require(_0xfed1('0x1'));var zipdir=require('zip-dir');var jsonpatch=require('fast-json-patch');var rp=require(_0xfed1('0x2'));var moment=require('moment');var BPromise=require(_0xfed1('0x3'));var Mustache=require('mustache');var util=require(_0xfed1('0x4'));var path=require(_0xfed1('0x5'));var sox=require(_0xfed1('0x6'));var csv=require(_0xfed1('0x7'));var ejs=require(_0xfed1('0x8'));var fs=require('fs');var fs_extra=require(_0xfed1('0x9'));var _=require(_0xfed1('0xa'));var squel=require(_0xfed1('0xb'));var crypto=require(_0xfed1('0xc'));var jsforce=require(_0xfed1('0xd'));var deskjs=require('desk.js');var toCsv=require(_0xfed1('0x7'));var querystring=require(_0xfed1('0xe'));var Papa=require(_0xfed1('0xf'));var Redis=require('ioredis');var authService=require(_0xfed1('0x10'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xfed1('0x11'));var logger=require(_0xfed1('0x12'))('api');var utils=require('../../config/utils');var config=require(_0xfed1('0x13'));var licenseUtil=require(_0xfed1('0x14'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x56555a,_0x4e2e26){_0x4e2e26=_0x4e2e26||0xcc;return function(_0x250eb5){if(_0x250eb5){return _0x56555a[_0xfed1('0x15')](_0x4e2e26);}return _0x56555a[_0xfed1('0x16')](_0x4e2e26)[_0xfed1('0x17')]();};}function respondWithResult(_0x58277d,_0x3bb8f7){_0x3bb8f7=_0x3bb8f7||0xc8;return function(_0x3754c2){if(_0x3754c2){return _0x58277d['status'](_0x3bb8f7)['json'](_0x3754c2);}};}function respondWithFilteredResult(_0x176227,_0x38f652){return function(_0x306567){if(_0x306567){var _0x5ed220=typeof _0x38f652[_0xfed1('0x18')]===_0xfed1('0x19')&&typeof _0x38f652[_0xfed1('0x1a')]===_0xfed1('0x19');var _0x5ab809=_0x306567[_0xfed1('0x1b')];var _0x4c492e=_0x5ed220?0x0:_0x38f652[_0xfed1('0x18')];var _0x2b4cd7=_0x5ed220?_0x306567[_0xfed1('0x1b')]:_0x38f652[_0xfed1('0x18')]+_0x38f652[_0xfed1('0x1a')];var _0x2926ac;if(_0x2b4cd7>=_0x5ab809){_0x2b4cd7=_0x5ab809;_0x2926ac=0xc8;}else{_0x2926ac=0xce;}_0x176227[_0xfed1('0x16')](_0x2926ac);return _0x176227[_0xfed1('0x1c')](_0xfed1('0x1d'),_0x4c492e+'-'+_0x2b4cd7+'/'+_0x5ab809)['json'](_0x306567);}return null;};}function patchUpdates(_0xd7bfb7){return function(_0x491497){try{jsonpatch[_0xfed1('0x1e')](_0x491497,_0xd7bfb7,!![]);}catch(_0x3e5ada){return BPromise[_0xfed1('0x1f')](_0x3e5ada);}return _0x491497[_0xfed1('0x20')]();};}function saveUpdates(_0x1eb9cd,_0x4610fd){return function(_0x1748f5){if(_0x1748f5){return _0x1748f5[_0xfed1('0x21')](_0x1eb9cd)['then'](function(_0x578aaa){return _0x578aaa;});}return null;};}function removeEntity(_0xa6d6cf,_0x5c9385){return function(_0x36a818){if(_0x36a818){return _0x36a818[_0xfed1('0x22')]()['then'](function(){_0xa6d6cf[_0xfed1('0x16')](0xcc)[_0xfed1('0x17')]();});}};}function handleEntityNotFound(_0x472dbc,_0x5bce5d){return function(_0x1e8c3e){if(!_0x1e8c3e){_0x472dbc[_0xfed1('0x15')](0x194);}return _0x1e8c3e;};}function handleError(_0x5ec9c4,_0xa04122){_0xa04122=_0xa04122||0x1f4;return function(_0x40da7f){logger[_0xfed1('0x23')](_0x40da7f['stack']);if(_0x40da7f[_0xfed1('0x24')]){delete _0x40da7f[_0xfed1('0x24')];}_0x5ec9c4[_0xfed1('0x16')](_0xa04122)['send'](_0x40da7f);};}exports[_0xfed1('0x25')]=function(_0x46cf02,_0x411182){var _0x1867f6={},_0x221bf7={},_0x27635f={'count':0x0,'rows':[]};var _0x57e741=_[_0xfed1('0x26')](db[_0xfed1('0x27')]['rawAttributes'],function(_0x34e47b){return{'name':_0x34e47b[_0xfed1('0x28')],'type':_0x34e47b[_0xfed1('0x29')]['key']};});_0x221bf7[_0xfed1('0x2a')]=_[_0xfed1('0x26')](_0x57e741,_0xfed1('0x24'));_0x221bf7[_0xfed1('0x2b')]=_['keys'](_0x46cf02[_0xfed1('0x2b')]);_0x221bf7[_0xfed1('0x2c')]=_[_0xfed1('0x2d')](_0x221bf7[_0xfed1('0x2a')],_0x221bf7[_0xfed1('0x2b')]);_0x1867f6['attributes']=_[_0xfed1('0x2d')](_0x221bf7[_0xfed1('0x2a')],qs[_0xfed1('0x2e')](_0x46cf02[_0xfed1('0x2b')][_0xfed1('0x2e')]));_0x1867f6[_0xfed1('0x2f')]=_0x1867f6[_0xfed1('0x2f')][_0xfed1('0x30')]?_0x1867f6['attributes']:_0x221bf7['model'];if(!_0x46cf02['query'][_0xfed1('0x31')](_0xfed1('0x32'))){_0x1867f6['limit']=qs[_0xfed1('0x1a')](_0x46cf02['query']['limit']);_0x1867f6['offset']=qs[_0xfed1('0x18')](_0x46cf02[_0xfed1('0x2b')][_0xfed1('0x18')]);}_0x1867f6['order']=qs['sort'](_0x46cf02[_0xfed1('0x2b')][_0xfed1('0x33')]);_0x1867f6[_0xfed1('0x34')]=qs[_0xfed1('0x2c')](_[_0xfed1('0x35')](_0x46cf02[_0xfed1('0x2b')],_0x221bf7[_0xfed1('0x2c')]),_0x57e741);if(_0x46cf02['query'][_0xfed1('0x36')]){_0x1867f6['where']=_[_0xfed1('0x37')](_0x1867f6[_0xfed1('0x34')],{'$or':_['map'](_0x57e741,function(_0x3adf16){if(_0x3adf16[_0xfed1('0x29')]!=='VIRTUAL'){var _0x32e493={};_0x32e493[_0x3adf16[_0xfed1('0x24')]]={'$like':'%'+_0x46cf02['query']['filter']+'%'};return _0x32e493;}})});}_0x1867f6=_[_0xfed1('0x37')]({},_0x1867f6,_0x46cf02[_0xfed1('0x38')]);var _0x3ec842={'where':_0x1867f6[_0xfed1('0x34')]};return db['JscriptyAnswerReport'][_0xfed1('0x1b')](_0x3ec842)['then'](function(_0x44ef72){_0x27635f['count']=_0x44ef72;if(_0x46cf02[_0xfed1('0x2b')][_0xfed1('0x39')]){_0x1867f6[_0xfed1('0x3a')]=[{'all':!![]}];}return db[_0xfed1('0x27')][_0xfed1('0x3b')](_0x1867f6);})['then'](function(_0x3edf0d){_0x27635f[_0xfed1('0x3c')]=_0x3edf0d;return _0x27635f;})[_0xfed1('0x3d')](respondWithFilteredResult(_0x411182,_0x1867f6))[_0xfed1('0x3e')](handleError(_0x411182,null));};exports[_0xfed1('0x3f')]=function(_0x5bff16,_0x2bc41f){var _0x1bac62={'raw':!![],'where':{'id':_0x5bff16[_0xfed1('0x40')]['id']}},_0x799206={};_0x799206[_0xfed1('0x2a')]=_[_0xfed1('0x41')](db[_0xfed1('0x27')]['rawAttributes']);_0x799206[_0xfed1('0x2b')]=_['keys'](_0x5bff16[_0xfed1('0x2b')]);_0x799206[_0xfed1('0x2c')]=_[_0xfed1('0x2d')](_0x799206[_0xfed1('0x2a')],_0x799206[_0xfed1('0x2b')]);_0x1bac62[_0xfed1('0x2f')]=_[_0xfed1('0x2d')](_0x799206['model'],qs[_0xfed1('0x2e')](_0x5bff16[_0xfed1('0x2b')]['fields']));_0x1bac62[_0xfed1('0x2f')]=_0x1bac62[_0xfed1('0x2f')][_0xfed1('0x30')]?_0x1bac62[_0xfed1('0x2f')]:_0x799206['model'];if(_0x5bff16[_0xfed1('0x2b')][_0xfed1('0x39')]){_0x1bac62[_0xfed1('0x3a')]=[{'all':!![]}];}_0x1bac62=_['merge']({},_0x1bac62,_0x5bff16['options']);return db['JscriptyAnswerReport']['find'](_0x1bac62)[_0xfed1('0x3d')](handleEntityNotFound(_0x2bc41f,null))[_0xfed1('0x3d')](respondWithResult(_0x2bc41f,null))[_0xfed1('0x3e')](handleError(_0x2bc41f,null));};exports[_0xfed1('0x42')]=function(_0x94bf5c,_0x5c9aab){return db['JscriptyAnswerReport'][_0xfed1('0x42')](_0x94bf5c[_0xfed1('0x43')],{})[_0xfed1('0x3d')](respondWithResult(_0x5c9aab,0xc9))['catch'](handleError(_0x5c9aab,null));};exports['update']=function(_0x6c2337,_0x181063){if(_0x6c2337[_0xfed1('0x43')]['id']){delete _0x6c2337[_0xfed1('0x43')]['id'];}return db[_0xfed1('0x27')][_0xfed1('0x44')]({'where':{'id':_0x6c2337['params']['id']}})[_0xfed1('0x3d')](handleEntityNotFound(_0x181063,null))['then'](saveUpdates(_0x6c2337[_0xfed1('0x43')],null))[_0xfed1('0x3d')](respondWithResult(_0x181063,null))['catch'](handleError(_0x181063,null));};exports['destroy']=function(_0x3c4d59,_0x47d49b){return db[_0xfed1('0x27')][_0xfed1('0x44')]({'where':{'id':_0x3c4d59['params']['id']}})[_0xfed1('0x3d')](handleEntityNotFound(_0x47d49b,null))[_0xfed1('0x3d')](removeEntity(_0x47d49b,null))['catch'](handleError(_0x47d49b,null));};exports[_0xfed1('0x45')]=function(_0x4683e7,_0x5120cd){return db['JscriptyAnswerReport'][_0xfed1('0x45')]()[_0xfed1('0x3d')](respondWithResult(_0x5120cd,null))[_0xfed1('0x3e')](handleError(_0x5120cd,null));};
\ No newline at end of file