Built motion from commit 52c8a02d.|2.6.29
[motion2.git] / server / api / analyticExtractedReport / analyticExtractedReport.controller.js
index e7240aa..8669e12 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x13f9=['to-csv','ejs','fs-extra','squel','crypto','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../mysqldb','sendStatus','status','end','json','offset','undefined','count','limit','set','Content-Range','apply','reject','save','update','then','destroy','get','ExtractedReports','UserProfileResource','error','stack','send','map','AnalyticExtractedReport','rawAttributes','model','name','query','filters','intersection','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where','pick','filter','merge','includeAll','rows','catch','show','params','keys','options','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','download','basename','savename','existsSync','join','root','server/files/reports','ValidationError','Report\x20not\x20found\x20or\x20empty','exists','format','output','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','path','sox'];(function(_0x122096,_0x60c295){var _0x3d1966=function(_0x3d569e){while(--_0x3d569e){_0x122096['push'](_0x122096['shift']());}};_0x3d1966(++_0x60c295);}(_0x13f9,0x111));var _0x913f=function(_0x167cc1,_0x56ef5a){_0x167cc1=_0x167cc1-0x0;var _0x10bc4b=_0x13f9[_0x167cc1];return _0x10bc4b;};'use strict';var emlformat=require(_0x913f('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x913f('0x1'));var jsonpatch=require(_0x913f('0x2'));var rp=require(_0x913f('0x3'));var moment=require(_0x913f('0x4'));var BPromise=require(_0x913f('0x5'));var Mustache=require(_0x913f('0x6'));var util=require('util');var path=require(_0x913f('0x7'));var sox=require(_0x913f('0x8'));var csv=require(_0x913f('0x9'));var ejs=require(_0x913f('0xa'));var fs=require('fs');var fs_extra=require(_0x913f('0xb'));var _=require('lodash');var squel=require(_0x913f('0xc'));var crypto=require(_0x913f('0xd'));var jsforce=require(_0x913f('0xe'));var deskjs=require(_0x913f('0xf'));var toCsv=require(_0x913f('0x9'));var querystring=require(_0x913f('0x10'));var Papa=require('papaparse');var Redis=require(_0x913f('0x11'));var authService=require(_0x913f('0x12'));var qs=require(_0x913f('0x13'));var as=require(_0x913f('0x14'));var hardwareService=require(_0x913f('0x15'));var logger=require(_0x913f('0x16'))(_0x913f('0x17'));var utils=require(_0x913f('0x18'));var config=require(_0x913f('0x19'));var licenseUtil=require('../../config/license/util');var db=require(_0x913f('0x1a'))['db'];function respondWithStatusCode(_0x314193,_0x1599e8){_0x1599e8=_0x1599e8||0xcc;return function(_0x3b5f28){if(_0x3b5f28){return _0x314193[_0x913f('0x1b')](_0x1599e8);}return _0x314193[_0x913f('0x1c')](_0x1599e8)[_0x913f('0x1d')]();};}function respondWithResult(_0x4d9623,_0x11fa5d){_0x11fa5d=_0x11fa5d||0xc8;return function(_0x515313){if(_0x515313){return _0x4d9623[_0x913f('0x1c')](_0x11fa5d)[_0x913f('0x1e')](_0x515313);}};}function respondWithFilteredResult(_0x29a5d7,_0x49741f){return function(_0x3fc036){if(_0x3fc036){var _0x2a2613=typeof _0x49741f[_0x913f('0x1f')]===_0x913f('0x20')&&typeof _0x49741f['limit']==='undefined';var _0x496757=_0x3fc036[_0x913f('0x21')];var _0x400efd=_0x2a2613?0x0:_0x49741f[_0x913f('0x1f')];var _0x12260d=_0x2a2613?_0x3fc036[_0x913f('0x21')]:_0x49741f[_0x913f('0x1f')]+_0x49741f[_0x913f('0x22')];var _0x35e072;if(_0x12260d>=_0x496757){_0x12260d=_0x496757;_0x35e072=0xc8;}else{_0x35e072=0xce;}_0x29a5d7[_0x913f('0x1c')](_0x35e072);return _0x29a5d7[_0x913f('0x23')](_0x913f('0x24'),_0x400efd+'-'+_0x12260d+'/'+_0x496757)['json'](_0x3fc036);}return null;};}function patchUpdates(_0x403493){return function(_0xf5c204){try{jsonpatch[_0x913f('0x25')](_0xf5c204,_0x403493,!![]);}catch(_0x4bca30){return BPromise[_0x913f('0x26')](_0x4bca30);}return _0xf5c204[_0x913f('0x27')]();};}function saveUpdates(_0x30d2e2,_0xdaa146){return function(_0xa7083c){if(_0xa7083c){return _0xa7083c[_0x913f('0x28')](_0x30d2e2)[_0x913f('0x29')](function(_0x30e010){return _0x30e010;});}return null;};}function removeEntity(_0x3c1b9f,_0x35de63){return function(_0x378ea2){if(_0x378ea2){return _0x378ea2[_0x913f('0x2a')]()['then'](function(){var _0x57c3bf=_0x378ea2[_0x913f('0x2b')]({'plain':!![]});var _0x19c8be=_0x913f('0x2c');return db[_0x913f('0x2d')]['destroy']({'where':{'type':_0x19c8be,'resourceId':_0x57c3bf['id']}})[_0x913f('0x29')](function(){return _0x378ea2;});})['then'](function(){_0x3c1b9f[_0x913f('0x1c')](0xcc)[_0x913f('0x1d')]();});}};}function handleEntityNotFound(_0x34adda,_0x465f8b){return function(_0x1db481){if(!_0x1db481){_0x34adda['sendStatus'](0x194);}return _0x1db481;};}function handleError(_0x485369,_0x15ba24){_0x15ba24=_0x15ba24||0x1f4;return function(_0x3260c0){logger[_0x913f('0x2e')](_0x3260c0[_0x913f('0x2f')]);if(_0x3260c0['name']){delete _0x3260c0['name'];}_0x485369[_0x913f('0x1c')](_0x15ba24)[_0x913f('0x30')](_0x3260c0);};}exports['index']=function(_0x2d4f18,_0x56f61a){var _0x4f81b0={},_0x45a467={},_0x3c4535={'count':0x0,'rows':[]};var _0x2ad431=_[_0x913f('0x31')](db[_0x913f('0x32')][_0x913f('0x33')],function(_0x1c05df){return{'name':_0x1c05df['fieldName'],'type':_0x1c05df['type']['key']};});_0x45a467[_0x913f('0x34')]=_[_0x913f('0x31')](_0x2ad431,_0x913f('0x35'));_0x45a467[_0x913f('0x36')]=_['keys'](_0x2d4f18['query']);_0x45a467[_0x913f('0x37')]=_[_0x913f('0x38')](_0x45a467[_0x913f('0x34')],_0x45a467[_0x913f('0x36')]);_0x4f81b0[_0x913f('0x39')]=_[_0x913f('0x38')](_0x45a467[_0x913f('0x34')],qs[_0x913f('0x3a')](_0x2d4f18['query'][_0x913f('0x3a')]));_0x4f81b0[_0x913f('0x39')]=_0x4f81b0[_0x913f('0x39')][_0x913f('0x3b')]?_0x4f81b0[_0x913f('0x39')]:_0x45a467['model'];if(!_0x2d4f18[_0x913f('0x36')][_0x913f('0x3c')](_0x913f('0x3d'))){_0x4f81b0[_0x913f('0x22')]=qs[_0x913f('0x22')](_0x2d4f18[_0x913f('0x36')][_0x913f('0x22')]);_0x4f81b0[_0x913f('0x1f')]=qs[_0x913f('0x1f')](_0x2d4f18[_0x913f('0x36')][_0x913f('0x1f')]);}_0x4f81b0[_0x913f('0x3e')]=qs[_0x913f('0x3f')](_0x2d4f18['query'][_0x913f('0x3f')]);_0x4f81b0[_0x913f('0x40')]=qs[_0x913f('0x37')](_[_0x913f('0x41')](_0x2d4f18[_0x913f('0x36')],_0x45a467['filters']),_0x2ad431);if(_0x2d4f18['query'][_0x913f('0x42')]){_0x4f81b0[_0x913f('0x40')]=_[_0x913f('0x43')](_0x4f81b0[_0x913f('0x40')],{'$or':_[_0x913f('0x31')](_0x2ad431,function(_0x15a1fa){if(_0x15a1fa['type']!=='VIRTUAL'){var _0x1990c5={};_0x1990c5[_0x15a1fa['name']]={'$like':'%'+_0x2d4f18[_0x913f('0x36')][_0x913f('0x42')]+'%'};return _0x1990c5;}})});}_0x4f81b0=_[_0x913f('0x43')]({},_0x4f81b0,_0x2d4f18['options']);var _0x57368a={'where':_0x4f81b0['where']};return db[_0x913f('0x32')][_0x913f('0x21')](_0x57368a)['then'](function(_0x13efee){_0x3c4535['count']=_0x13efee;if(_0x2d4f18[_0x913f('0x36')][_0x913f('0x44')]){_0x4f81b0['include']=[{'all':!![]}];}return db['AnalyticExtractedReport']['findAll'](_0x4f81b0);})['then'](function(_0x388594){_0x3c4535[_0x913f('0x45')]=_0x388594;return _0x3c4535;})[_0x913f('0x29')](respondWithFilteredResult(_0x56f61a,_0x4f81b0))[_0x913f('0x46')](handleError(_0x56f61a,null));};exports[_0x913f('0x47')]=function(_0x5d405f,_0xa25475){var _0x4d2cac={'raw':!![],'where':{'id':_0x5d405f[_0x913f('0x48')]['id']}},_0x1dd529={};_0x1dd529[_0x913f('0x34')]=_[_0x913f('0x49')](db[_0x913f('0x32')][_0x913f('0x33')]);_0x1dd529[_0x913f('0x36')]=_[_0x913f('0x49')](_0x5d405f[_0x913f('0x36')]);_0x1dd529[_0x913f('0x37')]=_[_0x913f('0x38')](_0x1dd529[_0x913f('0x34')],_0x1dd529[_0x913f('0x36')]);_0x4d2cac[_0x913f('0x39')]=_[_0x913f('0x38')](_0x1dd529[_0x913f('0x34')],qs['fields'](_0x5d405f[_0x913f('0x36')]['fields']));_0x4d2cac['attributes']=_0x4d2cac[_0x913f('0x39')][_0x913f('0x3b')]?_0x4d2cac[_0x913f('0x39')]:_0x1dd529[_0x913f('0x34')];if(_0x5d405f[_0x913f('0x36')][_0x913f('0x44')]){_0x4d2cac['include']=[{'all':!![]}];}_0x4d2cac=_[_0x913f('0x43')]({},_0x4d2cac,_0x5d405f[_0x913f('0x4a')]);return db[_0x913f('0x32')][_0x913f('0x4b')](_0x4d2cac)[_0x913f('0x29')](handleEntityNotFound(_0xa25475,null))[_0x913f('0x29')](respondWithResult(_0xa25475,null))[_0x913f('0x46')](handleError(_0xa25475,null));};exports[_0x913f('0x4c')]=function(_0x581468,_0x3cabc9){return db['AnalyticExtractedReport'][_0x913f('0x4c')](_0x581468[_0x913f('0x4d')],{})['then'](function(_0x1b1f7b){var _0x3cb630=_0x581468['user'][_0x913f('0x2b')]({'plain':!![]});if(!_0x3cb630)throw new Error(_0x913f('0x4e'));if(_0x3cb630['role']==='user'){var _0x333382=_0x1b1f7b[_0x913f('0x2b')]({'plain':!![]});var _0x5aa2ca='ExtractedReports';return db[_0x913f('0x4f')][_0x913f('0x4b')]({'where':{'name':_0x5aa2ca,'userProfileId':_0x3cb630[_0x913f('0x50')]},'raw':!![]})['then'](function(_0x19dd8b){if(_0x19dd8b&&_0x19dd8b['autoAssociation']===0x0){return db[_0x913f('0x2d')][_0x913f('0x4c')]({'name':_0x333382[_0x913f('0x35')],'resourceId':_0x333382['id'],'type':_0x19dd8b[_0x913f('0x35')],'sectionId':_0x19dd8b['id']},{})[_0x913f('0x29')](function(){return _0x1b1f7b;});}else{return _0x1b1f7b;}})['catch'](function(_0x5510d7){logger[_0x913f('0x2e')](_0x913f('0x51'),_0x5510d7);throw _0x5510d7;});}return _0x1b1f7b;})[_0x913f('0x29')](respondWithResult(_0x3cabc9,0xc9))[_0x913f('0x46')](handleError(_0x3cabc9,null));};exports['update']=function(_0x3a3bb9,_0x2180ba){if(_0x3a3bb9[_0x913f('0x4d')]['id']){delete _0x3a3bb9[_0x913f('0x4d')]['id'];}return db[_0x913f('0x32')]['find']({'where':{'id':_0x3a3bb9['params']['id']}})[_0x913f('0x29')](handleEntityNotFound(_0x2180ba,null))[_0x913f('0x29')](saveUpdates(_0x3a3bb9[_0x913f('0x4d')],null))['then'](respondWithResult(_0x2180ba,null))['catch'](handleError(_0x2180ba,null));};exports['destroy']=function(_0x353592,_0x23408b){return db[_0x913f('0x32')][_0x913f('0x4b')]({'where':{'id':_0x353592[_0x913f('0x48')]['id']}})[_0x913f('0x29')](handleEntityNotFound(_0x23408b,null))[_0x913f('0x29')](removeEntity(_0x23408b,null))[_0x913f('0x46')](handleError(_0x23408b,null));};exports[_0x913f('0x52')]=function(_0x5dca1c,_0x2961c9,_0x1df12a){return db['AnalyticExtractedReport']['find']({'where':{'id':_0x5dca1c['params']['id']},'attributes':['name',_0x913f('0x53'),_0x913f('0x54'),'output'],'raw':!![]})[_0x913f('0x29')](handleEntityNotFound(_0x2961c9,null))[_0x913f('0x29')](function(_0xeaee14){if(_0xeaee14){if(!fs[_0x913f('0x55')](path[_0x913f('0x56')](config[_0x913f('0x57')],_0x913f('0x58'),_0xeaee14[_0x913f('0x54')]))){throw new db['Sequelize'][(_0x913f('0x59'))](_0x913f('0x5a'));}if(_0x5dca1c[_0x913f('0x36')][_0x913f('0x5b')]){return _0x2961c9['sendStatus'](0xc8);}return _0x2961c9[_0x913f('0x52')](path['join'](config['root'],_0x913f('0x58'),_0xeaee14[_0x913f('0x54')]),util[_0x913f('0x5c')]('%s.%s',_0xeaee14[_0x913f('0x53')]||_0xeaee14[_0x913f('0x35')],_0xeaee14[_0x913f('0x5d')]['toLowerCase']()));}})[_0x913f('0x46')](handleError(_0x2961c9,null));};
\ No newline at end of file
+var _0x3a74=['download','basename','savename','existsSync','join','server/files/reports','Sequelize','ValidationError','Report\x20not\x20found\x20or\x20empty','exists','root','format','%s.%s','output','toLowerCase','eml-format','rimraf','zip-dir','fast-json-patch','moment','bluebird','mustache','util','path','sox','to-csv','ejs','fs-extra','lodash','squel','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','json','offset','undefined','limit','count','Content-Range','apply','reject','save','then','destroy','get','ExtractedReports','UserProfileResource','error','stack','name','send','index','map','AnalyticExtractedReport','rawAttributes','fieldName','key','query','filters','model','attributes','intersection','fields','hasOwnProperty','order','sort','where','pick','filter','merge','VIRTUAL','includeAll','catch','show','params','keys','include','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','update'];(function(_0x2fe0df,_0x1f78e3){var _0x4b832e=function(_0x1042d5){while(--_0x1042d5){_0x2fe0df['push'](_0x2fe0df['shift']());}};_0x4b832e(++_0x1f78e3);}(_0x3a74,0x138));var _0x43a7=function(_0x5cceb8,_0xa8e57a){_0x5cceb8=_0x5cceb8-0x0;var _0xeaf4be=_0x3a74[_0x5cceb8];return _0xeaf4be;};'use strict';var emlformat=require(_0x43a7('0x0'));var rimraf=require(_0x43a7('0x1'));var zipdir=require(_0x43a7('0x2'));var jsonpatch=require(_0x43a7('0x3'));var rp=require('request-promise');var moment=require(_0x43a7('0x4'));var BPromise=require(_0x43a7('0x5'));var Mustache=require(_0x43a7('0x6'));var util=require(_0x43a7('0x7'));var path=require(_0x43a7('0x8'));var sox=require(_0x43a7('0x9'));var csv=require(_0x43a7('0xa'));var ejs=require(_0x43a7('0xb'));var fs=require('fs');var fs_extra=require(_0x43a7('0xc'));var _=require(_0x43a7('0xd'));var squel=require(_0x43a7('0xe'));var crypto=require('crypto');var jsforce=require(_0x43a7('0xf'));var deskjs=require(_0x43a7('0x10'));var toCsv=require('to-csv');var querystring=require(_0x43a7('0x11'));var Papa=require('papaparse');var Redis=require(_0x43a7('0x12'));var authService=require(_0x43a7('0x13'));var qs=require(_0x43a7('0x14'));var as=require(_0x43a7('0x15'));var hardwareService=require(_0x43a7('0x16'));var logger=require(_0x43a7('0x17'))(_0x43a7('0x18'));var utils=require('../../config/utils');var config=require(_0x43a7('0x19'));var licenseUtil=require(_0x43a7('0x1a'));var db=require(_0x43a7('0x1b'))['db'];function respondWithStatusCode(_0x404d9a,_0x152806){_0x152806=_0x152806||0xcc;return function(_0x59b094){if(_0x59b094){return _0x404d9a[_0x43a7('0x1c')](_0x152806);}return _0x404d9a[_0x43a7('0x1d')](_0x152806)[_0x43a7('0x1e')]();};}function respondWithResult(_0x3a6df7,_0x21f563){_0x21f563=_0x21f563||0xc8;return function(_0x43f65a){if(_0x43f65a){return _0x3a6df7[_0x43a7('0x1d')](_0x21f563)[_0x43a7('0x1f')](_0x43f65a);}};}function respondWithFilteredResult(_0x4a88a8,_0x2b372d){return function(_0x5c2194){if(_0x5c2194){var _0x188ab3=typeof _0x2b372d[_0x43a7('0x20')]===_0x43a7('0x21')&&typeof _0x2b372d[_0x43a7('0x22')]===_0x43a7('0x21');var _0x44d9b8=_0x5c2194[_0x43a7('0x23')];var _0x564d56=_0x188ab3?0x0:_0x2b372d[_0x43a7('0x20')];var _0x5075c6=_0x188ab3?_0x5c2194['count']:_0x2b372d[_0x43a7('0x20')]+_0x2b372d[_0x43a7('0x22')];var _0x4a7bec;if(_0x5075c6>=_0x44d9b8){_0x5075c6=_0x44d9b8;_0x4a7bec=0xc8;}else{_0x4a7bec=0xce;}_0x4a88a8[_0x43a7('0x1d')](_0x4a7bec);return _0x4a88a8['set'](_0x43a7('0x24'),_0x564d56+'-'+_0x5075c6+'/'+_0x44d9b8)['json'](_0x5c2194);}return null;};}function patchUpdates(_0x5eb2a9){return function(_0x63107){try{jsonpatch[_0x43a7('0x25')](_0x63107,_0x5eb2a9,!![]);}catch(_0xa301e2){return BPromise[_0x43a7('0x26')](_0xa301e2);}return _0x63107[_0x43a7('0x27')]();};}function saveUpdates(_0x4fbd35,_0x938cb0){return function(_0x46978f){if(_0x46978f){return _0x46978f['update'](_0x4fbd35)[_0x43a7('0x28')](function(_0x82ab96){return _0x82ab96;});}return null;};}function removeEntity(_0x464fff,_0x2ad871){return function(_0x17c4dd){if(_0x17c4dd){return _0x17c4dd[_0x43a7('0x29')]()[_0x43a7('0x28')](function(){var _0x10ee70=_0x17c4dd[_0x43a7('0x2a')]({'plain':!![]});var _0xcb1d70=_0x43a7('0x2b');return db[_0x43a7('0x2c')][_0x43a7('0x29')]({'where':{'type':_0xcb1d70,'resourceId':_0x10ee70['id']}})[_0x43a7('0x28')](function(){return _0x17c4dd;});})['then'](function(){_0x464fff[_0x43a7('0x1d')](0xcc)[_0x43a7('0x1e')]();});}};}function handleEntityNotFound(_0xce4b4,_0x3cb983){return function(_0x341af3){if(!_0x341af3){_0xce4b4[_0x43a7('0x1c')](0x194);}return _0x341af3;};}function handleError(_0x5b8e6c,_0x2ea195){_0x2ea195=_0x2ea195||0x1f4;return function(_0x4da4cc){logger[_0x43a7('0x2d')](_0x4da4cc[_0x43a7('0x2e')]);if(_0x4da4cc['name']){delete _0x4da4cc[_0x43a7('0x2f')];}_0x5b8e6c['status'](_0x2ea195)[_0x43a7('0x30')](_0x4da4cc);};}exports[_0x43a7('0x31')]=function(_0xe13c14,_0x2ddb2e){var _0x140814={},_0x14fec1={},_0x100fa2={'count':0x0,'rows':[]};var _0x379d04=_[_0x43a7('0x32')](db[_0x43a7('0x33')][_0x43a7('0x34')],function(_0xa3bb0c){return{'name':_0xa3bb0c[_0x43a7('0x35')],'type':_0xa3bb0c['type'][_0x43a7('0x36')]};});_0x14fec1['model']=_[_0x43a7('0x32')](_0x379d04,'name');_0x14fec1[_0x43a7('0x37')]=_['keys'](_0xe13c14['query']);_0x14fec1[_0x43a7('0x38')]=_['intersection'](_0x14fec1[_0x43a7('0x39')],_0x14fec1[_0x43a7('0x37')]);_0x140814[_0x43a7('0x3a')]=_[_0x43a7('0x3b')](_0x14fec1[_0x43a7('0x39')],qs[_0x43a7('0x3c')](_0xe13c14[_0x43a7('0x37')]['fields']));_0x140814[_0x43a7('0x3a')]=_0x140814[_0x43a7('0x3a')]['length']?_0x140814[_0x43a7('0x3a')]:_0x14fec1['model'];if(!_0xe13c14['query'][_0x43a7('0x3d')]('nolimit')){_0x140814[_0x43a7('0x22')]=qs[_0x43a7('0x22')](_0xe13c14[_0x43a7('0x37')][_0x43a7('0x22')]);_0x140814[_0x43a7('0x20')]=qs[_0x43a7('0x20')](_0xe13c14[_0x43a7('0x37')][_0x43a7('0x20')]);}_0x140814[_0x43a7('0x3e')]=qs[_0x43a7('0x3f')](_0xe13c14['query'][_0x43a7('0x3f')]);_0x140814[_0x43a7('0x40')]=qs[_0x43a7('0x38')](_[_0x43a7('0x41')](_0xe13c14[_0x43a7('0x37')],_0x14fec1['filters']),_0x379d04);if(_0xe13c14[_0x43a7('0x37')][_0x43a7('0x42')]){_0x140814[_0x43a7('0x40')]=_[_0x43a7('0x43')](_0x140814[_0x43a7('0x40')],{'$or':_['map'](_0x379d04,function(_0x165443){if(_0x165443['type']!==_0x43a7('0x44')){var _0x35b4cb={};_0x35b4cb[_0x165443['name']]={'$like':'%'+_0xe13c14[_0x43a7('0x37')][_0x43a7('0x42')]+'%'};return _0x35b4cb;}})});}_0x140814=_[_0x43a7('0x43')]({},_0x140814,_0xe13c14['options']);var _0x4463c7={'where':_0x140814['where']};return db[_0x43a7('0x33')][_0x43a7('0x23')](_0x4463c7)[_0x43a7('0x28')](function(_0x3c69d9){_0x100fa2[_0x43a7('0x23')]=_0x3c69d9;if(_0xe13c14[_0x43a7('0x37')][_0x43a7('0x45')]){_0x140814['include']=[{'all':!![]}];}return db[_0x43a7('0x33')]['findAll'](_0x140814);})[_0x43a7('0x28')](function(_0x39a896){_0x100fa2['rows']=_0x39a896;return _0x100fa2;})[_0x43a7('0x28')](respondWithFilteredResult(_0x2ddb2e,_0x140814))[_0x43a7('0x46')](handleError(_0x2ddb2e,null));};exports[_0x43a7('0x47')]=function(_0x4374ed,_0x78c963){var _0x28049d={'raw':!![],'where':{'id':_0x4374ed[_0x43a7('0x48')]['id']}},_0x329f34={};_0x329f34[_0x43a7('0x39')]=_[_0x43a7('0x49')](db[_0x43a7('0x33')][_0x43a7('0x34')]);_0x329f34['query']=_[_0x43a7('0x49')](_0x4374ed[_0x43a7('0x37')]);_0x329f34[_0x43a7('0x38')]=_[_0x43a7('0x3b')](_0x329f34[_0x43a7('0x39')],_0x329f34[_0x43a7('0x37')]);_0x28049d[_0x43a7('0x3a')]=_['intersection'](_0x329f34[_0x43a7('0x39')],qs['fields'](_0x4374ed['query'][_0x43a7('0x3c')]));_0x28049d['attributes']=_0x28049d[_0x43a7('0x3a')]['length']?_0x28049d[_0x43a7('0x3a')]:_0x329f34['model'];if(_0x4374ed[_0x43a7('0x37')][_0x43a7('0x45')]){_0x28049d[_0x43a7('0x4a')]=[{'all':!![]}];}_0x28049d=_['merge']({},_0x28049d,_0x4374ed['options']);return db[_0x43a7('0x33')][_0x43a7('0x4b')](_0x28049d)[_0x43a7('0x28')](handleEntityNotFound(_0x78c963,null))['then'](respondWithResult(_0x78c963,null))[_0x43a7('0x46')](handleError(_0x78c963,null));};exports[_0x43a7('0x4c')]=function(_0x38c750,_0x53eb26){return db[_0x43a7('0x33')][_0x43a7('0x4c')](_0x38c750[_0x43a7('0x4d')],{})[_0x43a7('0x28')](function(_0x26438e){var _0x132733=_0x38c750['user'][_0x43a7('0x2a')]({'plain':!![]});if(!_0x132733)throw new Error(_0x43a7('0x4e'));if(_0x132733[_0x43a7('0x4f')]==='user'){var _0x3a9db4=_0x26438e['get']({'plain':!![]});var _0x10eb79=_0x43a7('0x2b');return db[_0x43a7('0x50')][_0x43a7('0x4b')]({'where':{'name':_0x10eb79,'userProfileId':_0x132733['userProfileId']},'raw':!![]})[_0x43a7('0x28')](function(_0x2d0d3a){if(_0x2d0d3a&&_0x2d0d3a[_0x43a7('0x51')]===0x0){return db['UserProfileResource']['create']({'name':_0x3a9db4['name'],'resourceId':_0x3a9db4['id'],'type':_0x2d0d3a['name'],'sectionId':_0x2d0d3a['id']},{})[_0x43a7('0x28')](function(){return _0x26438e;});}else{return _0x26438e;}})[_0x43a7('0x46')](function(_0x2f665e){logger[_0x43a7('0x2d')](_0x43a7('0x52'),_0x2f665e);throw _0x2f665e;});}return _0x26438e;})[_0x43a7('0x28')](respondWithResult(_0x53eb26,0xc9))[_0x43a7('0x46')](handleError(_0x53eb26,null));};exports[_0x43a7('0x53')]=function(_0x5630de,_0x11b2ac){if(_0x5630de[_0x43a7('0x4d')]['id']){delete _0x5630de[_0x43a7('0x4d')]['id'];}return db[_0x43a7('0x33')]['find']({'where':{'id':_0x5630de[_0x43a7('0x48')]['id']}})[_0x43a7('0x28')](handleEntityNotFound(_0x11b2ac,null))[_0x43a7('0x28')](saveUpdates(_0x5630de['body'],null))['then'](respondWithResult(_0x11b2ac,null))[_0x43a7('0x46')](handleError(_0x11b2ac,null));};exports[_0x43a7('0x29')]=function(_0x3fe3a2,_0x1417b7){return db[_0x43a7('0x33')][_0x43a7('0x4b')]({'where':{'id':_0x3fe3a2[_0x43a7('0x48')]['id']}})[_0x43a7('0x28')](handleEntityNotFound(_0x1417b7,null))[_0x43a7('0x28')](removeEntity(_0x1417b7,null))['catch'](handleError(_0x1417b7,null));};exports[_0x43a7('0x54')]=function(_0xd57b76,_0x60c6e8,_0x490c10){return db[_0x43a7('0x33')][_0x43a7('0x4b')]({'where':{'id':_0xd57b76['params']['id']},'attributes':[_0x43a7('0x2f'),_0x43a7('0x55'),_0x43a7('0x56'),'output'],'raw':!![]})['then'](handleEntityNotFound(_0x60c6e8,null))[_0x43a7('0x28')](function(_0x2bc4ef){if(_0x2bc4ef){if(!fs[_0x43a7('0x57')](path[_0x43a7('0x58')](config['root'],_0x43a7('0x59'),_0x2bc4ef[_0x43a7('0x56')]))){throw new db[(_0x43a7('0x5a'))][(_0x43a7('0x5b'))](_0x43a7('0x5c'));}if(_0xd57b76[_0x43a7('0x37')][_0x43a7('0x5d')]){return _0x60c6e8[_0x43a7('0x1c')](0xc8);}return _0x60c6e8['download'](path[_0x43a7('0x58')](config[_0x43a7('0x5e')],_0x43a7('0x59'),_0x2bc4ef[_0x43a7('0x56')]),util[_0x43a7('0x5f')](_0x43a7('0x60'),_0x2bc4ef[_0x43a7('0x55')]||_0x2bc4ef[_0x43a7('0x2f')],_0x2bc4ef[_0x43a7('0x61')][_0x43a7('0x62')]()));}})[_0x43a7('0x46')](handleError(_0x60c6e8,null));};
\ No newline at end of file