Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / interval / interval.controller.js
index 4e53cba..59654f9 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x3fcc=['filter','options','includeAll','include','findAll','rows','params','intersection','merge','find','catch','create','body','user','get','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','error','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','addInterval','IntervalId','getIntervals','findOne','rawAttributes','pick','addIntervals','sequelize','transaction','bulkCreate','rimraf','zip-dir','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','ejs','lodash','crypto','jsforce','desk.js','papaparse','ioredis','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../components/extensions/rewrite','sendStatus','end','json','offset','limit','undefined','count','status','set','Content-Range','apply','reject','update','destroy','then','Intervals','UserProfileResource','stack','name','send','index','map','Interval','fieldName','type','key','model','query','keys','filters','attributes','fields','length','hasOwnProperty','nolimit','order','sort','where'];(function(_0x479b33,_0x49671f){var _0x45e817=function(_0x36dd56){while(--_0x36dd56){_0x479b33['push'](_0x479b33['shift']());}};_0x45e817(++_0x49671f);}(_0x3fcc,0x19c));var _0xc3fc=function(_0x41c3e2,_0x6cbd75){_0x41c3e2=_0x41c3e2-0x0;var _0x109c89=_0x3fcc[_0x41c3e2];return _0x109c89;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0xc3fc('0x0'));var zipdir=require(_0xc3fc('0x1'));var jsonpatch=require('fast-json-patch');var rp=require(_0xc3fc('0x2'));var moment=require(_0xc3fc('0x3'));var BPromise=require(_0xc3fc('0x4'));var Mustache=require(_0xc3fc('0x5'));var util=require(_0xc3fc('0x6'));var path=require(_0xc3fc('0x7'));var sox=require(_0xc3fc('0x8'));var csv=require(_0xc3fc('0x9'));var ejs=require(_0xc3fc('0xa'));var fs=require('fs');var fs_extra=require('fs-extra');var _=require(_0xc3fc('0xb'));var squel=require('squel');var crypto=require(_0xc3fc('0xc'));var jsforce=require(_0xc3fc('0xd'));var deskjs=require(_0xc3fc('0xe'));var toCsv=require('to-csv');var querystring=require('querystring');var Papa=require(_0xc3fc('0xf'));var Redis=require(_0xc3fc('0x10'));var authService=require('../../components/auth/service');var qs=require(_0xc3fc('0x11'));var as=require(_0xc3fc('0x12'));var hardwareService=require(_0xc3fc('0x13'));var logger=require(_0xc3fc('0x14'))('api');var utils=require(_0xc3fc('0x15'));var config=require(_0xc3fc('0x16'));var licenseUtil=require(_0xc3fc('0x17'));var db=require('../../mysqldb')['db'];var extensions=require(_0xc3fc('0x18'));function respondWithStatusCode(_0x5264bc,_0x28f495){_0x28f495=_0x28f495||0xcc;return function(_0x3d948f){if(_0x3d948f){return _0x5264bc[_0xc3fc('0x19')](_0x28f495);}return _0x5264bc['status'](_0x28f495)[_0xc3fc('0x1a')]();};}function respondWithResult(_0x4fcd7a,_0x2dbf14){_0x2dbf14=_0x2dbf14||0xc8;return function(_0x5bc4e3){if(_0x5bc4e3){return _0x4fcd7a['status'](_0x2dbf14)[_0xc3fc('0x1b')](_0x5bc4e3);}};}function respondWithFilteredResult(_0x21a0a1,_0x45c4ae){return function(_0x54d474){if(_0x54d474){var _0x2af1a4=typeof _0x45c4ae[_0xc3fc('0x1c')]==='undefined'&&typeof _0x45c4ae[_0xc3fc('0x1d')]===_0xc3fc('0x1e');var _0x4fded5=_0x54d474[_0xc3fc('0x1f')];var _0x21f2f7=_0x2af1a4?0x0:_0x45c4ae[_0xc3fc('0x1c')];var _0x342609=_0x2af1a4?_0x54d474[_0xc3fc('0x1f')]:_0x45c4ae[_0xc3fc('0x1c')]+_0x45c4ae[_0xc3fc('0x1d')];var _0x258802;if(_0x342609>=_0x4fded5){_0x342609=_0x4fded5;_0x258802=0xc8;}else{_0x258802=0xce;}_0x21a0a1[_0xc3fc('0x20')](_0x258802);return _0x21a0a1[_0xc3fc('0x21')](_0xc3fc('0x22'),_0x21f2f7+'-'+_0x342609+'/'+_0x4fded5)[_0xc3fc('0x1b')](_0x54d474);}return null;};}function patchUpdates(_0x252a8d){return function(_0x1e18d1){try{jsonpatch[_0xc3fc('0x23')](_0x1e18d1,_0x252a8d,!![]);}catch(_0x58f8c2){return BPromise[_0xc3fc('0x24')](_0x58f8c2);}return _0x1e18d1['save']();};}function saveUpdates(_0x2e228a,_0x49bdbe){return function(_0xf8b3ef){if(_0xf8b3ef){return _0xf8b3ef[_0xc3fc('0x25')](_0x2e228a)['then'](function(_0x4a6d74){return _0x4a6d74;});}return null;};}function removeEntity(_0x545e17,_0x523420){return function(_0x1d6504){if(_0x1d6504){return _0x1d6504[_0xc3fc('0x26')]()[_0xc3fc('0x27')](function(){var _0x356826=_0x1d6504['get']({'plain':!![]});var _0x5b0bd3=_0xc3fc('0x28');return db[_0xc3fc('0x29')][_0xc3fc('0x26')]({'where':{'type':_0x5b0bd3,'resourceId':_0x356826['id']}})[_0xc3fc('0x27')](function(){return _0x1d6504;});})[_0xc3fc('0x27')](function(){_0x545e17[_0xc3fc('0x20')](0xcc)[_0xc3fc('0x1a')]();});}};}function handleEntityNotFound(_0x33cbc7,_0x37fdff){return function(_0x2e983b){if(!_0x2e983b){_0x33cbc7[_0xc3fc('0x19')](0x194);}return _0x2e983b;};}function handleError(_0x45dc34,_0x5d9963){_0x5d9963=_0x5d9963||0x1f4;return function(_0xbe4b77){logger['error'](_0xbe4b77[_0xc3fc('0x2a')]);if(_0xbe4b77[_0xc3fc('0x2b')]){delete _0xbe4b77[_0xc3fc('0x2b')];}_0x45dc34['status'](_0x5d9963)[_0xc3fc('0x2c')](_0xbe4b77);};}exports[_0xc3fc('0x2d')]=function(_0x5f2851,_0x3864e8){var _0x15a84b={},_0x35ac72={},_0x5a8152={'count':0x0,'rows':[]};var _0x19f052=_[_0xc3fc('0x2e')](db[_0xc3fc('0x2f')]['rawAttributes'],function(_0x2d7224){return{'name':_0x2d7224[_0xc3fc('0x30')],'type':_0x2d7224[_0xc3fc('0x31')][_0xc3fc('0x32')]};});_0x35ac72[_0xc3fc('0x33')]=_[_0xc3fc('0x2e')](_0x19f052,_0xc3fc('0x2b'));_0x35ac72[_0xc3fc('0x34')]=_[_0xc3fc('0x35')](_0x5f2851['query']);_0x35ac72[_0xc3fc('0x36')]=_['intersection'](_0x35ac72['model'],_0x35ac72[_0xc3fc('0x34')]);_0x15a84b[_0xc3fc('0x37')]=_['intersection'](_0x35ac72[_0xc3fc('0x33')],qs[_0xc3fc('0x38')](_0x5f2851['query'][_0xc3fc('0x38')]));_0x15a84b['attributes']=_0x15a84b['attributes'][_0xc3fc('0x39')]?_0x15a84b[_0xc3fc('0x37')]:_0x35ac72[_0xc3fc('0x33')];if(!_0x5f2851[_0xc3fc('0x34')][_0xc3fc('0x3a')](_0xc3fc('0x3b'))){_0x15a84b[_0xc3fc('0x1d')]=qs['limit'](_0x5f2851[_0xc3fc('0x34')]['limit']);_0x15a84b[_0xc3fc('0x1c')]=qs['offset'](_0x5f2851[_0xc3fc('0x34')]['offset']);}_0x15a84b[_0xc3fc('0x3c')]=qs[_0xc3fc('0x3d')](_0x5f2851[_0xc3fc('0x34')]['sort']);_0x15a84b[_0xc3fc('0x3e')]=qs['filters'](_['pick'](_0x5f2851['query'],_0x35ac72[_0xc3fc('0x36')]),_0x19f052);if(_0x5f2851['query'][_0xc3fc('0x3f')]){_0x15a84b[_0xc3fc('0x3e')]=_['merge'](_0x15a84b[_0xc3fc('0x3e')],{'$or':_[_0xc3fc('0x2e')](_0x19f052,function(_0x3166cf){if(_0x3166cf[_0xc3fc('0x31')]!=='VIRTUAL'){var _0x28f81d={};_0x28f81d[_0x3166cf[_0xc3fc('0x2b')]]={'$like':'%'+_0x5f2851[_0xc3fc('0x34')]['filter']+'%'};return _0x28f81d;}})});}_0x15a84b=_['merge']({},_0x15a84b,_0x5f2851[_0xc3fc('0x40')]);var _0x1efbfc={'where':_0x15a84b[_0xc3fc('0x3e')]};return db[_0xc3fc('0x2f')][_0xc3fc('0x1f')](_0x1efbfc)[_0xc3fc('0x27')](function(_0x686d4b){_0x5a8152[_0xc3fc('0x1f')]=_0x686d4b;if(_0x5f2851['query'][_0xc3fc('0x41')]){_0x15a84b[_0xc3fc('0x42')]=[{'all':!![]}];}return db[_0xc3fc('0x2f')][_0xc3fc('0x43')](_0x15a84b);})[_0xc3fc('0x27')](function(_0xeb5ab9){_0x5a8152[_0xc3fc('0x44')]=_0xeb5ab9;return _0x5a8152;})[_0xc3fc('0x27')](respondWithFilteredResult(_0x3864e8,_0x15a84b))['catch'](handleError(_0x3864e8,null));};exports['show']=function(_0xc7544c,_0x470cda){var _0x5116a9={'raw':!![],'where':{'id':_0xc7544c[_0xc3fc('0x45')]['id']}},_0x313f2a={};_0x313f2a['model']=_[_0xc3fc('0x35')](db['Interval']['rawAttributes']);_0x313f2a[_0xc3fc('0x34')]=_[_0xc3fc('0x35')](_0xc7544c[_0xc3fc('0x34')]);_0x313f2a[_0xc3fc('0x36')]=_[_0xc3fc('0x46')](_0x313f2a[_0xc3fc('0x33')],_0x313f2a[_0xc3fc('0x34')]);_0x5116a9['attributes']=_[_0xc3fc('0x46')](_0x313f2a[_0xc3fc('0x33')],qs[_0xc3fc('0x38')](_0xc7544c[_0xc3fc('0x34')]['fields']));_0x5116a9[_0xc3fc('0x37')]=_0x5116a9[_0xc3fc('0x37')]['length']?_0x5116a9['attributes']:_0x313f2a[_0xc3fc('0x33')];if(_0xc7544c[_0xc3fc('0x34')][_0xc3fc('0x41')]){_0x5116a9[_0xc3fc('0x42')]=[{'all':!![]}];}_0x5116a9=_[_0xc3fc('0x47')]({},_0x5116a9,_0xc7544c[_0xc3fc('0x40')]);return db['Interval'][_0xc3fc('0x48')](_0x5116a9)[_0xc3fc('0x27')](handleEntityNotFound(_0x470cda,null))['then'](respondWithResult(_0x470cda,null))[_0xc3fc('0x49')](handleError(_0x470cda,null));};exports['create']=function(_0x5d99c0,_0x1e240b){return db[_0xc3fc('0x2f')][_0xc3fc('0x4a')](_0x5d99c0[_0xc3fc('0x4b')],{})['then'](function(_0xb847f9){var _0x205092=_0x5d99c0[_0xc3fc('0x4c')][_0xc3fc('0x4d')]({'plain':!![]});if(!_0x205092)throw new Error(_0xc3fc('0x4e'));if(_0x205092[_0xc3fc('0x4f')]==='user'){var _0x26a9f5=_0xb847f9[_0xc3fc('0x4d')]({'plain':!![]});var _0x3d056b=_0xc3fc('0x28');return db[_0xc3fc('0x50')][_0xc3fc('0x48')]({'where':{'name':_0x3d056b,'userProfileId':_0x205092[_0xc3fc('0x51')]},'raw':!![]})[_0xc3fc('0x27')](function(_0x1e5389){if(_0x1e5389&&_0x1e5389[_0xc3fc('0x52')]===0x0){return db['UserProfileResource'][_0xc3fc('0x4a')]({'name':_0x26a9f5[_0xc3fc('0x2b')],'resourceId':_0x26a9f5['id'],'type':_0x1e5389[_0xc3fc('0x2b')],'sectionId':_0x1e5389['id']},{})['then'](function(){return _0xb847f9;});}else{return _0xb847f9;}})[_0xc3fc('0x49')](function(_0x529bdb){logger[_0xc3fc('0x53')](_0xc3fc('0x54'),_0x529bdb);throw _0x529bdb;});}return _0xb847f9;})[_0xc3fc('0x27')](respondWithResult(_0x1e240b,0xc9))[_0xc3fc('0x49')](handleError(_0x1e240b,null));};exports[_0xc3fc('0x25')]=function(_0x27f035,_0x1ad795){if(_0x27f035[_0xc3fc('0x4b')]['id']){delete _0x27f035[_0xc3fc('0x4b')]['id'];}return db[_0xc3fc('0x2f')]['find']({'where':{'id':_0x27f035[_0xc3fc('0x45')]['id']}})[_0xc3fc('0x27')](handleEntityNotFound(_0x1ad795,null))[_0xc3fc('0x27')](saveUpdates(_0x27f035['body'],null))['then'](respondWithResult(_0x1ad795,null))[_0xc3fc('0x49')](handleError(_0x1ad795,null));};exports[_0xc3fc('0x26')]=function(_0x4139ca,_0x206905){return db[_0xc3fc('0x2f')][_0xc3fc('0x48')]({'where':{'id':_0x4139ca[_0xc3fc('0x45')]['id']}})[_0xc3fc('0x27')](handleEntityNotFound(_0x206905,null))[_0xc3fc('0x27')](removeEntity(_0x206905,null))[_0xc3fc('0x49')](handleError(_0x206905,null));};exports[_0xc3fc('0x55')]=function(_0x1657d5,_0x15bfc5,_0x3de028){if(_0x1657d5[_0xc3fc('0x4b')]['id']){delete _0x1657d5[_0xc3fc('0x4b')]['id'];}return db[_0xc3fc('0x2f')]['find']({'where':{'id':_0x1657d5[_0xc3fc('0x45')]['id']}})[_0xc3fc('0x27')](handleEntityNotFound(_0x15bfc5,null))[_0xc3fc('0x27')](function(_0x2f3a47){if(_0x2f3a47){_0x1657d5['body'][_0xc3fc('0x56')]=_0x2f3a47['id'];return db[_0xc3fc('0x2f')][_0xc3fc('0x4a')](_0x1657d5[_0xc3fc('0x4b')]);}})[_0xc3fc('0x27')](respondWithResult(_0x15bfc5,null))[_0xc3fc('0x49')](handleError(_0x15bfc5,null));};exports[_0xc3fc('0x57')]=function(_0x50f98f,_0x4859e4,_0x1097c5){var _0x5f193a={};var _0x47cedb={};var _0xf4d637;var _0x212544;return db[_0xc3fc('0x2f')][_0xc3fc('0x58')]({'where':{'id':_0x50f98f[_0xc3fc('0x45')]['id']}})[_0xc3fc('0x27')](handleEntityNotFound(_0x4859e4,null))[_0xc3fc('0x27')](function(_0x46b751){if(_0x46b751){_0xf4d637=_0x46b751;_0x47cedb[_0xc3fc('0x33')]=_[_0xc3fc('0x35')](db[_0xc3fc('0x2f')][_0xc3fc('0x59')]);_0x47cedb['query']=_['keys'](_0x50f98f['query']);_0x47cedb['filters']=_[_0xc3fc('0x46')](_0x47cedb[_0xc3fc('0x33')],_0x47cedb[_0xc3fc('0x34')]);_0x5f193a['attributes']=_[_0xc3fc('0x46')](_0x47cedb['model'],qs[_0xc3fc('0x38')](_0x50f98f['query'][_0xc3fc('0x38')]));_0x5f193a[_0xc3fc('0x37')]=_0x5f193a[_0xc3fc('0x37')]['length']?_0x5f193a[_0xc3fc('0x37')]:_0x47cedb['model'];_0x5f193a[_0xc3fc('0x3c')]=qs[_0xc3fc('0x3d')](_0x50f98f[_0xc3fc('0x34')][_0xc3fc('0x3d')]);_0x5f193a[_0xc3fc('0x3e')]=qs['filters'](_[_0xc3fc('0x5a')](_0x50f98f[_0xc3fc('0x34')],_0x47cedb[_0xc3fc('0x36')]));if(_0x50f98f[_0xc3fc('0x34')]['filter']){_0x5f193a['where']=_[_0xc3fc('0x47')](_0x5f193a[_0xc3fc('0x3e')],{'$or':_['map'](_0x5f193a['attributes'],function(_0x2fd02c){var _0x240130={};_0x240130[_0x2fd02c]={'$like':'%'+_0x50f98f[_0xc3fc('0x34')][_0xc3fc('0x3f')]+'%'};return _0x240130;})});}_0x5f193a=_[_0xc3fc('0x47')]({},_0x5f193a,_0x50f98f['options']);return _0xf4d637[_0xc3fc('0x57')](_0x5f193a);}})[_0xc3fc('0x27')](function(_0x40a932){if(_0x40a932){_0x212544=_0x40a932[_0xc3fc('0x39')];if(!_0x50f98f[_0xc3fc('0x34')][_0xc3fc('0x3a')]('nolimit')){_0x5f193a[_0xc3fc('0x1d')]=qs[_0xc3fc('0x1d')](_0x50f98f['query'][_0xc3fc('0x1d')]);_0x5f193a[_0xc3fc('0x1c')]=qs[_0xc3fc('0x1c')](_0x50f98f['query']['offset']);}return _0xf4d637['getIntervals'](_0x5f193a);}})[_0xc3fc('0x27')](function(_0x21af75){if(_0x21af75){return _0x21af75?{'count':_0x212544,'rows':_0x21af75}:null;}})['then'](respondWithResult(_0x4859e4,null))[_0xc3fc('0x49')](handleError(_0x4859e4,null));};exports[_0xc3fc('0x5b')]=function(_0x35529e,_0x4fb2eb,_0xef151){return db[_0xc3fc('0x2f')][_0xc3fc('0x58')]({'where':{'id':_0x35529e[_0xc3fc('0x45')]['id']}})[_0xc3fc('0x27')](handleEntityNotFound(_0x4fb2eb,null))['then'](function(_0x1b976c){if(_0x1b976c){return db[_0xc3fc('0x5c')][_0xc3fc('0x5d')](function(_0x4375a6){return db[_0xc3fc('0x2f')][_0xc3fc('0x26')]({'where':{'IntervalId':_0x35529e['params']['id']},'transaction':_0x4375a6})[_0xc3fc('0x27')](function(_0x4ed092){var _0x37e0de=_[_0xc3fc('0x2e')](_0x35529e[_0xc3fc('0x4b')],function(_0x35ec50){delete _0x35ec50['id'];_0x35ec50[_0xc3fc('0x56')]=_0x35529e[_0xc3fc('0x45')]['id'];return _0x35ec50;});return db[_0xc3fc('0x2f')][_0xc3fc('0x5e')](_0x37e0de,{'transaction':_0x4375a6});});})[_0xc3fc('0x27')](function(){return db[_0xc3fc('0x2f')]['findAll']({'where':{'IntervalId':_0x35529e[_0xc3fc('0x45')]['id']}});});}})[_0xc3fc('0x27')](respondWithResult(_0x4fb2eb,null))[_0xc3fc('0x49')](handleError(_0x4fb2eb,null));};
\ No newline at end of file
+var _0x766e=['undefined','limit','count','set','apply','save','update','destroy','then','get','Intervals','sendStatus','error','stack','name','send','map','Interval','rawAttributes','fieldName','type','key','query','keys','attributes','intersection','length','order','sort','where','filters','filter','merge','options','include','rows','show','model','fields','find','catch','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','autoAssociation','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','addInterval','IntervalId','getIntervals','findOne','pick','hasOwnProperty','addIntervals','sequelize','transaction','findAll','fast-json-patch','util','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','../../components/extensions/rewrite','status','end','json','offset'];(function(_0x44c92e,_0x1a2d3a){var _0x59d8f7=function(_0xd3a89b){while(--_0xd3a89b){_0x44c92e['push'](_0x44c92e['shift']());}};_0x59d8f7(++_0x1a2d3a);}(_0x766e,0x1ea));var _0xe766=function(_0x32ee10,_0x29ade5){_0x32ee10=_0x32ee10-0x0;var _0x39ec1b=_0x766e[_0x32ee10];return _0x39ec1b;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xe766('0x0'));var rp=require('request-promise');var moment=require('moment');var BPromise=require('bluebird');var Mustache=require('mustache');var util=require(_0xe766('0x1'));var path=require('path');var sox=require(_0xe766('0x2'));var csv=require('to-csv');var ejs=require(_0xe766('0x3'));var fs=require('fs');var fs_extra=require(_0xe766('0x4'));var _=require(_0xe766('0x5'));var squel=require(_0xe766('0x6'));var crypto=require(_0xe766('0x7'));var jsforce=require(_0xe766('0x8'));var deskjs=require(_0xe766('0x9'));var toCsv=require(_0xe766('0xa'));var querystring=require('querystring');var Papa=require('papaparse');var Redis=require('ioredis');var authService=require(_0xe766('0xb'));var qs=require(_0xe766('0xc'));var as=require(_0xe766('0xd'));var hardwareService=require(_0xe766('0xe'));var logger=require(_0xe766('0xf'))(_0xe766('0x10'));var utils=require(_0xe766('0x11'));var config=require(_0xe766('0x12'));var licenseUtil=require(_0xe766('0x13'));var db=require(_0xe766('0x14'))['db'];var extensions=require(_0xe766('0x15'));function respondWithStatusCode(_0x5b398f,_0x18deb8){_0x18deb8=_0x18deb8||0xcc;return function(_0x2d6c85){if(_0x2d6c85){return _0x5b398f['sendStatus'](_0x18deb8);}return _0x5b398f[_0xe766('0x16')](_0x18deb8)[_0xe766('0x17')]();};}function respondWithResult(_0x3536d4,_0x1ea422){_0x1ea422=_0x1ea422||0xc8;return function(_0x41a4c6){if(_0x41a4c6){return _0x3536d4[_0xe766('0x16')](_0x1ea422)[_0xe766('0x18')](_0x41a4c6);}};}function respondWithFilteredResult(_0x1f1bd3,_0x3f78f5){return function(_0x46e8ed){if(_0x46e8ed){var _0x335d14=typeof _0x3f78f5[_0xe766('0x19')]===_0xe766('0x1a')&&typeof _0x3f78f5[_0xe766('0x1b')]===_0xe766('0x1a');var _0xdd002a=_0x46e8ed[_0xe766('0x1c')];var _0xd78150=_0x335d14?0x0:_0x3f78f5[_0xe766('0x19')];var _0x146d10=_0x335d14?_0x46e8ed['count']:_0x3f78f5[_0xe766('0x19')]+_0x3f78f5['limit'];var _0xb2f071;if(_0x146d10>=_0xdd002a){_0x146d10=_0xdd002a;_0xb2f071=0xc8;}else{_0xb2f071=0xce;}_0x1f1bd3[_0xe766('0x16')](_0xb2f071);return _0x1f1bd3[_0xe766('0x1d')]('Content-Range',_0xd78150+'-'+_0x146d10+'/'+_0xdd002a)['json'](_0x46e8ed);}return null;};}function patchUpdates(_0x471439){return function(_0xc57dd1){try{jsonpatch[_0xe766('0x1e')](_0xc57dd1,_0x471439,!![]);}catch(_0x2e1a61){return BPromise['reject'](_0x2e1a61);}return _0xc57dd1[_0xe766('0x1f')]();};}function saveUpdates(_0x4264e6,_0x1d8bc0){return function(_0x2ade2c){if(_0x2ade2c){return _0x2ade2c[_0xe766('0x20')](_0x4264e6)['then'](function(_0x583158){return _0x583158;});}return null;};}function removeEntity(_0x456b01,_0x336981){return function(_0x49a32d){if(_0x49a32d){return _0x49a32d[_0xe766('0x21')]()[_0xe766('0x22')](function(){var _0x31721b=_0x49a32d[_0xe766('0x23')]({'plain':!![]});var _0x5b137b=_0xe766('0x24');return db['UserProfileResource']['destroy']({'where':{'type':_0x5b137b,'resourceId':_0x31721b['id']}})['then'](function(){return _0x49a32d;});})['then'](function(){_0x456b01[_0xe766('0x16')](0xcc)['end']();});}};}function handleEntityNotFound(_0x21c09a,_0xba6f26){return function(_0x27c1ad){if(!_0x27c1ad){_0x21c09a[_0xe766('0x25')](0x194);}return _0x27c1ad;};}function handleError(_0x79ac22,_0x27e70d){_0x27e70d=_0x27e70d||0x1f4;return function(_0x45a549){logger[_0xe766('0x26')](_0x45a549[_0xe766('0x27')]);if(_0x45a549[_0xe766('0x28')]){delete _0x45a549[_0xe766('0x28')];}_0x79ac22[_0xe766('0x16')](_0x27e70d)[_0xe766('0x29')](_0x45a549);};}exports['index']=function(_0x58bcef,_0x475ac3){var _0x35f451={},_0xeb04a6={},_0x45b594={'count':0x0,'rows':[]};var _0x97464=_[_0xe766('0x2a')](db[_0xe766('0x2b')][_0xe766('0x2c')],function(_0x2bc7f0){return{'name':_0x2bc7f0[_0xe766('0x2d')],'type':_0x2bc7f0[_0xe766('0x2e')][_0xe766('0x2f')]};});_0xeb04a6['model']=_[_0xe766('0x2a')](_0x97464,_0xe766('0x28'));_0xeb04a6[_0xe766('0x30')]=_[_0xe766('0x31')](_0x58bcef[_0xe766('0x30')]);_0xeb04a6['filters']=_['intersection'](_0xeb04a6['model'],_0xeb04a6[_0xe766('0x30')]);_0x35f451[_0xe766('0x32')]=_[_0xe766('0x33')](_0xeb04a6['model'],qs['fields'](_0x58bcef[_0xe766('0x30')]['fields']));_0x35f451[_0xe766('0x32')]=_0x35f451[_0xe766('0x32')][_0xe766('0x34')]?_0x35f451[_0xe766('0x32')]:_0xeb04a6['model'];if(!_0x58bcef['query']['hasOwnProperty']('nolimit')){_0x35f451[_0xe766('0x1b')]=qs[_0xe766('0x1b')](_0x58bcef[_0xe766('0x30')][_0xe766('0x1b')]);_0x35f451[_0xe766('0x19')]=qs[_0xe766('0x19')](_0x58bcef[_0xe766('0x30')]['offset']);}_0x35f451[_0xe766('0x35')]=qs[_0xe766('0x36')](_0x58bcef[_0xe766('0x30')][_0xe766('0x36')]);_0x35f451[_0xe766('0x37')]=qs[_0xe766('0x38')](_['pick'](_0x58bcef['query'],_0xeb04a6['filters']),_0x97464);if(_0x58bcef[_0xe766('0x30')][_0xe766('0x39')]){_0x35f451[_0xe766('0x37')]=_[_0xe766('0x3a')](_0x35f451[_0xe766('0x37')],{'$or':_[_0xe766('0x2a')](_0x97464,function(_0x1d0cdc){if(_0x1d0cdc[_0xe766('0x2e')]!=='VIRTUAL'){var _0x4cdb1e={};_0x4cdb1e[_0x1d0cdc[_0xe766('0x28')]]={'$like':'%'+_0x58bcef['query'][_0xe766('0x39')]+'%'};return _0x4cdb1e;}})});}_0x35f451=_['merge']({},_0x35f451,_0x58bcef[_0xe766('0x3b')]);var _0xafce08={'where':_0x35f451[_0xe766('0x37')]};return db[_0xe766('0x2b')][_0xe766('0x1c')](_0xafce08)[_0xe766('0x22')](function(_0x514ae2){_0x45b594[_0xe766('0x1c')]=_0x514ae2;if(_0x58bcef[_0xe766('0x30')]['includeAll']){_0x35f451[_0xe766('0x3c')]=[{'all':!![]}];}return db[_0xe766('0x2b')]['findAll'](_0x35f451);})['then'](function(_0x31b91f){_0x45b594[_0xe766('0x3d')]=_0x31b91f;return _0x45b594;})[_0xe766('0x22')](respondWithFilteredResult(_0x475ac3,_0x35f451))['catch'](handleError(_0x475ac3,null));};exports[_0xe766('0x3e')]=function(_0x462a94,_0x411fd6){var _0x4cd9de={'raw':!![],'where':{'id':_0x462a94['params']['id']}},_0x4ed6d2={};_0x4ed6d2['model']=_[_0xe766('0x31')](db[_0xe766('0x2b')][_0xe766('0x2c')]);_0x4ed6d2[_0xe766('0x30')]=_[_0xe766('0x31')](_0x462a94[_0xe766('0x30')]);_0x4ed6d2[_0xe766('0x38')]=_['intersection'](_0x4ed6d2[_0xe766('0x3f')],_0x4ed6d2[_0xe766('0x30')]);_0x4cd9de[_0xe766('0x32')]=_[_0xe766('0x33')](_0x4ed6d2['model'],qs[_0xe766('0x40')](_0x462a94[_0xe766('0x30')][_0xe766('0x40')]));_0x4cd9de[_0xe766('0x32')]=_0x4cd9de[_0xe766('0x32')][_0xe766('0x34')]?_0x4cd9de['attributes']:_0x4ed6d2[_0xe766('0x3f')];if(_0x462a94[_0xe766('0x30')]['includeAll']){_0x4cd9de['include']=[{'all':!![]}];}_0x4cd9de=_[_0xe766('0x3a')]({},_0x4cd9de,_0x462a94[_0xe766('0x3b')]);return db[_0xe766('0x2b')][_0xe766('0x41')](_0x4cd9de)[_0xe766('0x22')](handleEntityNotFound(_0x411fd6,null))[_0xe766('0x22')](respondWithResult(_0x411fd6,null))[_0xe766('0x42')](handleError(_0x411fd6,null));};exports[_0xe766('0x43')]=function(_0x1fe0e0,_0x3acc36){return db[_0xe766('0x2b')]['create'](_0x1fe0e0[_0xe766('0x44')],{})[_0xe766('0x22')](function(_0x140b92){var _0x33d682=_0x1fe0e0[_0xe766('0x45')][_0xe766('0x23')]({'plain':!![]});if(!_0x33d682)throw new Error(_0xe766('0x46'));if(_0x33d682[_0xe766('0x47')]===_0xe766('0x45')){var _0x2da1ff=_0x140b92[_0xe766('0x23')]({'plain':!![]});var _0x525b28=_0xe766('0x24');return db[_0xe766('0x48')][_0xe766('0x41')]({'where':{'name':_0x525b28,'userProfileId':_0x33d682['userProfileId']},'raw':!![]})[_0xe766('0x22')](function(_0x317292){if(_0x317292&&_0x317292[_0xe766('0x49')]===0x0){return db['UserProfileResource'][_0xe766('0x43')]({'name':_0x2da1ff[_0xe766('0x28')],'resourceId':_0x2da1ff['id'],'type':_0x317292[_0xe766('0x28')],'sectionId':_0x317292['id']},{})['then'](function(){return _0x140b92;});}else{return _0x140b92;}})[_0xe766('0x42')](function(_0x267581){logger[_0xe766('0x26')](_0xe766('0x4a'),_0x267581);throw _0x267581;});}return _0x140b92;})[_0xe766('0x22')](respondWithResult(_0x3acc36,0xc9))[_0xe766('0x42')](handleError(_0x3acc36,null));};exports[_0xe766('0x20')]=function(_0x568a3b,_0xbfa122){if(_0x568a3b[_0xe766('0x44')]['id']){delete _0x568a3b[_0xe766('0x44')]['id'];}return db[_0xe766('0x2b')]['find']({'where':{'id':_0x568a3b['params']['id']}})[_0xe766('0x22')](handleEntityNotFound(_0xbfa122,null))[_0xe766('0x22')](saveUpdates(_0x568a3b[_0xe766('0x44')],null))['then'](respondWithResult(_0xbfa122,null))['catch'](handleError(_0xbfa122,null));};exports[_0xe766('0x21')]=function(_0x6dff58,_0x786759){return db['Interval'][_0xe766('0x41')]({'where':{'id':_0x6dff58[_0xe766('0x4b')]['id']}})[_0xe766('0x22')](handleEntityNotFound(_0x786759,null))[_0xe766('0x22')](removeEntity(_0x786759,null))[_0xe766('0x42')](handleError(_0x786759,null));};exports[_0xe766('0x4c')]=function(_0x18cd7a,_0x5e6d4e,_0xdd19b6){if(_0x18cd7a[_0xe766('0x44')]['id']){delete _0x18cd7a[_0xe766('0x44')]['id'];}return db[_0xe766('0x2b')][_0xe766('0x41')]({'where':{'id':_0x18cd7a[_0xe766('0x4b')]['id']}})[_0xe766('0x22')](handleEntityNotFound(_0x5e6d4e,null))[_0xe766('0x22')](function(_0x44ea46){if(_0x44ea46){_0x18cd7a[_0xe766('0x44')][_0xe766('0x4d')]=_0x44ea46['id'];return db[_0xe766('0x2b')][_0xe766('0x43')](_0x18cd7a[_0xe766('0x44')]);}})['then'](respondWithResult(_0x5e6d4e,null))[_0xe766('0x42')](handleError(_0x5e6d4e,null));};exports[_0xe766('0x4e')]=function(_0x25caa9,_0x649209,_0x5dc27c){var _0x349a48={};var _0xc49a88={};var _0x24d6fb;var _0x449ae9;return db[_0xe766('0x2b')][_0xe766('0x4f')]({'where':{'id':_0x25caa9[_0xe766('0x4b')]['id']}})[_0xe766('0x22')](handleEntityNotFound(_0x649209,null))[_0xe766('0x22')](function(_0x5ec4c4){if(_0x5ec4c4){_0x24d6fb=_0x5ec4c4;_0xc49a88[_0xe766('0x3f')]=_['keys'](db['Interval'][_0xe766('0x2c')]);_0xc49a88[_0xe766('0x30')]=_[_0xe766('0x31')](_0x25caa9[_0xe766('0x30')]);_0xc49a88[_0xe766('0x38')]=_[_0xe766('0x33')](_0xc49a88[_0xe766('0x3f')],_0xc49a88['query']);_0x349a48[_0xe766('0x32')]=_[_0xe766('0x33')](_0xc49a88[_0xe766('0x3f')],qs[_0xe766('0x40')](_0x25caa9[_0xe766('0x30')][_0xe766('0x40')]));_0x349a48[_0xe766('0x32')]=_0x349a48[_0xe766('0x32')]['length']?_0x349a48['attributes']:_0xc49a88[_0xe766('0x3f')];_0x349a48['order']=qs[_0xe766('0x36')](_0x25caa9[_0xe766('0x30')]['sort']);_0x349a48[_0xe766('0x37')]=qs[_0xe766('0x38')](_[_0xe766('0x50')](_0x25caa9['query'],_0xc49a88['filters']));if(_0x25caa9[_0xe766('0x30')][_0xe766('0x39')]){_0x349a48[_0xe766('0x37')]=_[_0xe766('0x3a')](_0x349a48[_0xe766('0x37')],{'$or':_[_0xe766('0x2a')](_0x349a48[_0xe766('0x32')],function(_0x5a717c){var _0xa54d36={};_0xa54d36[_0x5a717c]={'$like':'%'+_0x25caa9[_0xe766('0x30')][_0xe766('0x39')]+'%'};return _0xa54d36;})});}_0x349a48=_['merge']({},_0x349a48,_0x25caa9[_0xe766('0x3b')]);return _0x24d6fb[_0xe766('0x4e')](_0x349a48);}})[_0xe766('0x22')](function(_0x1b478f){if(_0x1b478f){_0x449ae9=_0x1b478f[_0xe766('0x34')];if(!_0x25caa9['query'][_0xe766('0x51')]('nolimit')){_0x349a48[_0xe766('0x1b')]=qs[_0xe766('0x1b')](_0x25caa9['query']['limit']);_0x349a48['offset']=qs[_0xe766('0x19')](_0x25caa9[_0xe766('0x30')][_0xe766('0x19')]);}return _0x24d6fb[_0xe766('0x4e')](_0x349a48);}})['then'](function(_0x4c9375){if(_0x4c9375){return _0x4c9375?{'count':_0x449ae9,'rows':_0x4c9375}:null;}})[_0xe766('0x22')](respondWithResult(_0x649209,null))[_0xe766('0x42')](handleError(_0x649209,null));};exports[_0xe766('0x52')]=function(_0xd7169d,_0x3a75e7,_0x41da8a){return db[_0xe766('0x2b')][_0xe766('0x4f')]({'where':{'id':_0xd7169d[_0xe766('0x4b')]['id']}})[_0xe766('0x22')](handleEntityNotFound(_0x3a75e7,null))['then'](function(_0x51d6c8){if(_0x51d6c8){return db[_0xe766('0x53')][_0xe766('0x54')](function(_0x796219){return db[_0xe766('0x2b')][_0xe766('0x21')]({'where':{'IntervalId':_0xd7169d[_0xe766('0x4b')]['id']},'transaction':_0x796219})['then'](function(_0x36cec2){var _0x1209e0=_[_0xe766('0x2a')](_0xd7169d['body'],function(_0xc6314c){delete _0xc6314c['id'];_0xc6314c[_0xe766('0x4d')]=_0xd7169d[_0xe766('0x4b')]['id'];return _0xc6314c;});return db[_0xe766('0x2b')]['bulkCreate'](_0x1209e0,{'transaction':_0x796219});});})[_0xe766('0x22')](function(){return db['Interval'][_0xe766('0x55')]({'where':{'IntervalId':_0xd7169d[_0xe766('0x4b')]['id']}});});}})[_0xe766('0x22')](respondWithResult(_0x3a75e7,null))[_0xe766('0x42')](handleError(_0x3a75e7,null));};
\ No newline at end of file