Built motion from commit 10af8726.|2.6.34
[motion2.git] / server / api / intSugarcrmConfiguration / intSugarcrmConfiguration.controller.js
index bc516ff..4ca8318 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xf403=['rimraf','zip-dir','fast-json-patch','request-promise','moment','mustache','util','sox','ejs','fs-extra','lodash','squel','crypto','jsforce','desk.js','to-csv','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','json','undefined','count','offset','limit','set','Content-Range','reject','save','update','then','destroy','end','name','send','SugarcrmConfiguration','rawAttributes','fieldName','type','key','model','map','query','keys','filters','intersection','fields','attributes','length','hasOwnProperty','nolimit','sort','pick','filter','where','merge','options','findAll','rows','params','includeAll','include','catch','create','body','find','findOne','order','getFields','SugarcrmField','getSubjects','getDescriptions'];(function(_0x3dd64c,_0x24763e){var _0x537931=function(_0x30c12b){while(--_0x30c12b){_0x3dd64c['push'](_0x3dd64c['shift']());}};_0x537931(++_0x24763e);}(_0xf403,0x1ec));var _0x3f40=function(_0x599b4c,_0x20c1e9){_0x599b4c=_0x599b4c-0x0;var _0x8f82c4=_0xf403[_0x599b4c];return _0x8f82c4;};'use strict';var emlformat=require('eml-format');var rimraf=require(_0x3f40('0x0'));var zipdir=require(_0x3f40('0x1'));var jsonpatch=require(_0x3f40('0x2'));var rp=require(_0x3f40('0x3'));var moment=require(_0x3f40('0x4'));var BPromise=require('bluebird');var Mustache=require(_0x3f40('0x5'));var util=require(_0x3f40('0x6'));var path=require('path');var sox=require(_0x3f40('0x7'));var csv=require('to-csv');var ejs=require(_0x3f40('0x8'));var fs=require('fs');var fs_extra=require(_0x3f40('0x9'));var _=require(_0x3f40('0xa'));var squel=require(_0x3f40('0xb'));var crypto=require(_0x3f40('0xc'));var jsforce=require(_0x3f40('0xd'));var deskjs=require(_0x3f40('0xe'));var toCsv=require(_0x3f40('0xf'));var querystring=require('querystring');var Papa=require(_0x3f40('0x10'));var Redis=require(_0x3f40('0x11'));var authService=require(_0x3f40('0x12'));var qs=require(_0x3f40('0x13'));var as=require(_0x3f40('0x14'));var hardwareService=require(_0x3f40('0x15'));var logger=require(_0x3f40('0x16'))(_0x3f40('0x17'));var utils=require(_0x3f40('0x18'));var config=require(_0x3f40('0x19'));var licenseUtil=require(_0x3f40('0x1a'));var db=require(_0x3f40('0x1b'))['db'];function respondWithStatusCode(_0x273795,_0xa49bc1){_0xa49bc1=_0xa49bc1||0xcc;return function(_0x4b5b7f){if(_0x4b5b7f){return _0x273795[_0x3f40('0x1c')](_0xa49bc1);}return _0x273795[_0x3f40('0x1d')](_0xa49bc1)['end']();};}function respondWithResult(_0x52ccd7,_0xaa0cfd){_0xaa0cfd=_0xaa0cfd||0xc8;return function(_0x589e5b){if(_0x589e5b){return _0x52ccd7[_0x3f40('0x1d')](_0xaa0cfd)[_0x3f40('0x1e')](_0x589e5b);}};}function respondWithFilteredResult(_0x190cd2,_0x2a4cfd){return function(_0x10319e){if(_0x10319e){var _0x561c1f=typeof _0x2a4cfd['offset']===_0x3f40('0x1f')&&typeof _0x2a4cfd['limit']===_0x3f40('0x1f');var _0x30ed7a=_0x10319e[_0x3f40('0x20')];var _0x277182=_0x561c1f?0x0:_0x2a4cfd[_0x3f40('0x21')];var _0x13253b=_0x561c1f?_0x10319e[_0x3f40('0x20')]:_0x2a4cfd[_0x3f40('0x21')]+_0x2a4cfd[_0x3f40('0x22')];var _0x42399c;if(_0x13253b>=_0x30ed7a){_0x13253b=_0x30ed7a;_0x42399c=0xc8;}else{_0x42399c=0xce;}_0x190cd2[_0x3f40('0x1d')](_0x42399c);return _0x190cd2[_0x3f40('0x23')](_0x3f40('0x24'),_0x277182+'-'+_0x13253b+'/'+_0x30ed7a)['json'](_0x10319e);}return null;};}function patchUpdates(_0x6deda7){return function(_0x114a78){try{jsonpatch['apply'](_0x114a78,_0x6deda7,!![]);}catch(_0x105063){return BPromise[_0x3f40('0x25')](_0x105063);}return _0x114a78[_0x3f40('0x26')]();};}function saveUpdates(_0x19425c,_0x5a2dcd){return function(_0xa2d3a7){if(_0xa2d3a7){return _0xa2d3a7[_0x3f40('0x27')](_0x19425c)[_0x3f40('0x28')](function(_0x309295){return _0x309295;});}return null;};}function removeEntity(_0x5447dc,_0x164abb){return function(_0x2afe44){if(_0x2afe44){return _0x2afe44[_0x3f40('0x29')]()['then'](function(){_0x5447dc[_0x3f40('0x1d')](0xcc)[_0x3f40('0x2a')]();});}};}function handleEntityNotFound(_0x269448,_0x50f3ad){return function(_0x4a8af4){if(!_0x4a8af4){_0x269448[_0x3f40('0x1c')](0x194);}return _0x4a8af4;};}function handleError(_0x72044d,_0x1e49ea){_0x1e49ea=_0x1e49ea||0x1f4;return function(_0x1d38af){logger['error'](_0x1d38af['stack']);if(_0x1d38af['name']){delete _0x1d38af[_0x3f40('0x2b')];}_0x72044d['status'](_0x1e49ea)[_0x3f40('0x2c')](_0x1d38af);};}exports['index']=function(_0x4fdaba,_0x2182f1){var _0x34ca93={},_0x26a017={},_0x332a14={'count':0x0,'rows':[]};var _0x1a58ef=_['map'](db[_0x3f40('0x2d')][_0x3f40('0x2e')],function(_0x246e37){return{'name':_0x246e37[_0x3f40('0x2f')],'type':_0x246e37[_0x3f40('0x30')][_0x3f40('0x31')]};});_0x26a017[_0x3f40('0x32')]=_[_0x3f40('0x33')](_0x1a58ef,_0x3f40('0x2b'));_0x26a017[_0x3f40('0x34')]=_[_0x3f40('0x35')](_0x4fdaba['query']);_0x26a017[_0x3f40('0x36')]=_[_0x3f40('0x37')](_0x26a017[_0x3f40('0x32')],_0x26a017[_0x3f40('0x34')]);_0x34ca93['attributes']=_[_0x3f40('0x37')](_0x26a017[_0x3f40('0x32')],qs[_0x3f40('0x38')](_0x4fdaba['query'][_0x3f40('0x38')]));_0x34ca93['attributes']=_0x34ca93[_0x3f40('0x39')][_0x3f40('0x3a')]?_0x34ca93['attributes']:_0x26a017['model'];if(!_0x4fdaba['query'][_0x3f40('0x3b')](_0x3f40('0x3c'))){_0x34ca93[_0x3f40('0x22')]=qs[_0x3f40('0x22')](_0x4fdaba[_0x3f40('0x34')]['limit']);_0x34ca93['offset']=qs[_0x3f40('0x21')](_0x4fdaba['query']['offset']);}_0x34ca93['order']=qs['sort'](_0x4fdaba[_0x3f40('0x34')][_0x3f40('0x3d')]);_0x34ca93['where']=qs[_0x3f40('0x36')](_[_0x3f40('0x3e')](_0x4fdaba['query'],_0x26a017[_0x3f40('0x36')]),_0x1a58ef);if(_0x4fdaba[_0x3f40('0x34')][_0x3f40('0x3f')]){_0x34ca93[_0x3f40('0x40')]=_[_0x3f40('0x41')](_0x34ca93['where'],{'$or':_[_0x3f40('0x33')](_0x1a58ef,function(_0xa8462){if(_0xa8462[_0x3f40('0x30')]!=='VIRTUAL'){var _0x2857e3={};_0x2857e3[_0xa8462['name']]={'$like':'%'+_0x4fdaba[_0x3f40('0x34')][_0x3f40('0x3f')]+'%'};return _0x2857e3;}})});}_0x34ca93=_[_0x3f40('0x41')]({},_0x34ca93,_0x4fdaba[_0x3f40('0x42')]);var _0x1366c9={'where':_0x34ca93[_0x3f40('0x40')]};return db[_0x3f40('0x2d')][_0x3f40('0x20')](_0x1366c9)[_0x3f40('0x28')](function(_0x2b44d2){_0x332a14['count']=_0x2b44d2;if(_0x4fdaba[_0x3f40('0x34')]['includeAll']){_0x34ca93['include']=[{'all':!![]}];}return db[_0x3f40('0x2d')][_0x3f40('0x43')](_0x34ca93);})[_0x3f40('0x28')](function(_0x424ff8){_0x332a14[_0x3f40('0x44')]=_0x424ff8;return _0x332a14;})[_0x3f40('0x28')](respondWithFilteredResult(_0x2182f1,_0x34ca93))['catch'](handleError(_0x2182f1,null));};exports['show']=function(_0x540375,_0xdd2f44){var _0x29fdee={'raw':![],'where':{'id':_0x540375[_0x3f40('0x45')]['id']}},_0x4b9d3f={};_0x4b9d3f['model']=_['keys'](db[_0x3f40('0x2d')][_0x3f40('0x2e')]);_0x4b9d3f[_0x3f40('0x34')]=_[_0x3f40('0x35')](_0x540375[_0x3f40('0x34')]);_0x4b9d3f[_0x3f40('0x36')]=_[_0x3f40('0x37')](_0x4b9d3f[_0x3f40('0x32')],_0x4b9d3f[_0x3f40('0x34')]);_0x29fdee[_0x3f40('0x39')]=_[_0x3f40('0x37')](_0x4b9d3f[_0x3f40('0x32')],qs[_0x3f40('0x38')](_0x540375['query']['fields']));_0x29fdee['attributes']=_0x29fdee[_0x3f40('0x39')][_0x3f40('0x3a')]?_0x29fdee[_0x3f40('0x39')]:_0x4b9d3f[_0x3f40('0x32')];if(_0x540375['query'][_0x3f40('0x46')]){_0x29fdee[_0x3f40('0x47')]=[{'all':!![]}];}_0x29fdee=_[_0x3f40('0x41')]({},_0x29fdee,_0x540375[_0x3f40('0x42')]);return db[_0x3f40('0x2d')]['find'](_0x29fdee)[_0x3f40('0x28')](handleEntityNotFound(_0xdd2f44,null))[_0x3f40('0x28')](respondWithResult(_0xdd2f44,null))[_0x3f40('0x48')](handleError(_0xdd2f44,null));};exports['create']=function(_0x122bcc,_0x24e8d6){return db[_0x3f40('0x2d')][_0x3f40('0x49')](_0x122bcc[_0x3f40('0x4a')],{})['then'](respondWithResult(_0x24e8d6,0xc9))[_0x3f40('0x48')](handleError(_0x24e8d6,null));};exports[_0x3f40('0x27')]=function(_0x45bdd6,_0x103ce6){if(_0x45bdd6[_0x3f40('0x4a')]['id']){delete _0x45bdd6[_0x3f40('0x4a')]['id'];}return db[_0x3f40('0x2d')][_0x3f40('0x4b')]({'where':{'id':_0x45bdd6[_0x3f40('0x45')]['id']}})[_0x3f40('0x28')](handleEntityNotFound(_0x103ce6,null))[_0x3f40('0x28')](saveUpdates(_0x45bdd6[_0x3f40('0x4a')],null))[_0x3f40('0x28')](respondWithResult(_0x103ce6,null))['catch'](handleError(_0x103ce6,null));};exports[_0x3f40('0x29')]=function(_0x3ae4b4,_0x22bd2d){return db['SugarcrmConfiguration'][_0x3f40('0x4b')]({'where':{'id':_0x3ae4b4[_0x3f40('0x45')]['id']}})[_0x3f40('0x28')](handleEntityNotFound(_0x22bd2d,null))[_0x3f40('0x28')](removeEntity(_0x22bd2d,null))[_0x3f40('0x48')](handleError(_0x22bd2d,null));};exports['getFields']=function(_0x41739d,_0x452fbb,_0x57d2c7){var _0x5d8074={};var _0x4770fd={};var _0x5a2568;var _0x56f7ce;return db['SugarcrmConfiguration'][_0x3f40('0x4c')]({'where':{'id':_0x41739d[_0x3f40('0x45')]['id']}})[_0x3f40('0x28')](handleEntityNotFound(_0x452fbb,null))['then'](function(_0x3829a8){if(_0x3829a8){_0x5a2568=_0x3829a8;_0x4770fd[_0x3f40('0x32')]=_[_0x3f40('0x35')](db['SugarcrmField'][_0x3f40('0x2e')]);_0x4770fd[_0x3f40('0x34')]=_[_0x3f40('0x35')](_0x41739d[_0x3f40('0x34')]);_0x4770fd['filters']=_['intersection'](_0x4770fd['model'],_0x4770fd[_0x3f40('0x34')]);_0x5d8074['attributes']=_[_0x3f40('0x37')](_0x4770fd[_0x3f40('0x32')],qs[_0x3f40('0x38')](_0x41739d['query']['fields']));_0x5d8074[_0x3f40('0x39')]=_0x5d8074[_0x3f40('0x39')][_0x3f40('0x3a')]?_0x5d8074['attributes']:_0x4770fd[_0x3f40('0x32')];_0x5d8074[_0x3f40('0x4d')]=qs[_0x3f40('0x3d')](_0x41739d[_0x3f40('0x34')][_0x3f40('0x3d')]);_0x5d8074['where']=qs[_0x3f40('0x36')](_[_0x3f40('0x3e')](_0x41739d[_0x3f40('0x34')],_0x4770fd['filters']));if(_0x41739d['query']['filter']){_0x5d8074[_0x3f40('0x40')]=_['merge'](_0x5d8074['where'],{'$or':_[_0x3f40('0x33')](_0x5d8074['attributes'],function(_0x3284e7){var _0x173313={};_0x173313[_0x3284e7]={'$like':'%'+_0x41739d[_0x3f40('0x34')]['filter']+'%'};return _0x173313;})});}_0x5d8074=_['merge']({},_0x5d8074,_0x41739d[_0x3f40('0x42')]);return _0x5a2568[_0x3f40('0x4e')](_0x5d8074);}})[_0x3f40('0x28')](function(_0x823fff){if(_0x823fff){_0x56f7ce=_0x823fff[_0x3f40('0x3a')];if(!_0x41739d[_0x3f40('0x34')][_0x3f40('0x3b')]('nolimit')){_0x5d8074[_0x3f40('0x22')]=qs['limit'](_0x41739d[_0x3f40('0x34')][_0x3f40('0x22')]);_0x5d8074[_0x3f40('0x21')]=qs['offset'](_0x41739d[_0x3f40('0x34')][_0x3f40('0x21')]);}return _0x5a2568['getFields'](_0x5d8074);}})[_0x3f40('0x28')](function(_0x551056){if(_0x551056){return _0x551056?{'count':_0x56f7ce,'rows':_0x551056}:null;}})[_0x3f40('0x28')](respondWithResult(_0x452fbb,null))['catch'](handleError(_0x452fbb,null));};exports['getSubjects']=function(_0x3b6d3a,_0x4a2b4c,_0x326664){var _0x4e5372={};var _0x3b4214={};var _0x3a50d5;var _0x3259bb;return db[_0x3f40('0x2d')][_0x3f40('0x4c')]({'where':{'id':_0x3b6d3a[_0x3f40('0x45')]['id']}})['then'](handleEntityNotFound(_0x4a2b4c,null))[_0x3f40('0x28')](function(_0x26a869){if(_0x26a869){_0x3a50d5=_0x26a869;_0x3b4214[_0x3f40('0x32')]=_[_0x3f40('0x35')](db[_0x3f40('0x4f')][_0x3f40('0x2e')]);_0x3b4214[_0x3f40('0x34')]=_['keys'](_0x3b6d3a[_0x3f40('0x34')]);_0x3b4214['filters']=_[_0x3f40('0x37')](_0x3b4214['model'],_0x3b4214[_0x3f40('0x34')]);_0x4e5372[_0x3f40('0x39')]=_[_0x3f40('0x37')](_0x3b4214[_0x3f40('0x32')],qs[_0x3f40('0x38')](_0x3b6d3a[_0x3f40('0x34')][_0x3f40('0x38')]));_0x4e5372['attributes']=_0x4e5372[_0x3f40('0x39')]['length']?_0x4e5372[_0x3f40('0x39')]:_0x3b4214[_0x3f40('0x32')];_0x4e5372['order']=qs['sort'](_0x3b6d3a['query'][_0x3f40('0x3d')]);_0x4e5372[_0x3f40('0x40')]=qs[_0x3f40('0x36')](_[_0x3f40('0x3e')](_0x3b6d3a[_0x3f40('0x34')],_0x3b4214[_0x3f40('0x36')]));if(_0x3b6d3a[_0x3f40('0x34')][_0x3f40('0x3f')]){_0x4e5372[_0x3f40('0x40')]=_['merge'](_0x4e5372[_0x3f40('0x40')],{'$or':_[_0x3f40('0x33')](_0x4e5372[_0x3f40('0x39')],function(_0x37e398){var _0x3adca9={};_0x3adca9[_0x37e398]={'$like':'%'+_0x3b6d3a[_0x3f40('0x34')]['filter']+'%'};return _0x3adca9;})});}_0x4e5372=_[_0x3f40('0x41')]({},_0x4e5372,_0x3b6d3a[_0x3f40('0x42')]);return _0x3a50d5[_0x3f40('0x50')](_0x4e5372);}})['then'](function(_0x267d7c){if(_0x267d7c){_0x3259bb=_0x267d7c[_0x3f40('0x3a')];if(!_0x3b6d3a[_0x3f40('0x34')][_0x3f40('0x3b')](_0x3f40('0x3c'))){_0x4e5372['limit']=qs[_0x3f40('0x22')](_0x3b6d3a[_0x3f40('0x34')][_0x3f40('0x22')]);_0x4e5372[_0x3f40('0x21')]=qs[_0x3f40('0x21')](_0x3b6d3a[_0x3f40('0x34')]['offset']);}return _0x3a50d5[_0x3f40('0x50')](_0x4e5372);}})[_0x3f40('0x28')](function(_0x3290bc){if(_0x3290bc){return _0x3290bc?{'count':_0x3259bb,'rows':_0x3290bc}:null;}})[_0x3f40('0x28')](respondWithResult(_0x4a2b4c,null))['catch'](handleError(_0x4a2b4c,null));};exports[_0x3f40('0x51')]=function(_0x576623,_0x5b00ed,_0x5e6739){var _0x2a8700={};var _0x2f419f={};var _0x31dbdb;var _0x5bde61;return db[_0x3f40('0x2d')][_0x3f40('0x4c')]({'where':{'id':_0x576623[_0x3f40('0x45')]['id']}})[_0x3f40('0x28')](handleEntityNotFound(_0x5b00ed,null))['then'](function(_0x58ab58){if(_0x58ab58){_0x31dbdb=_0x58ab58;_0x2f419f[_0x3f40('0x32')]=_['keys'](db['SugarcrmField']['rawAttributes']);_0x2f419f['query']=_[_0x3f40('0x35')](_0x576623[_0x3f40('0x34')]);_0x2f419f[_0x3f40('0x36')]=_[_0x3f40('0x37')](_0x2f419f[_0x3f40('0x32')],_0x2f419f[_0x3f40('0x34')]);_0x2a8700[_0x3f40('0x39')]=_[_0x3f40('0x37')](_0x2f419f['model'],qs[_0x3f40('0x38')](_0x576623['query']['fields']));_0x2a8700[_0x3f40('0x39')]=_0x2a8700[_0x3f40('0x39')][_0x3f40('0x3a')]?_0x2a8700[_0x3f40('0x39')]:_0x2f419f[_0x3f40('0x32')];_0x2a8700[_0x3f40('0x4d')]=qs['sort'](_0x576623[_0x3f40('0x34')][_0x3f40('0x3d')]);_0x2a8700['where']=qs['filters'](_['pick'](_0x576623[_0x3f40('0x34')],_0x2f419f[_0x3f40('0x36')]));if(_0x576623[_0x3f40('0x34')][_0x3f40('0x3f')]){_0x2a8700[_0x3f40('0x40')]=_[_0x3f40('0x41')](_0x2a8700[_0x3f40('0x40')],{'$or':_['map'](_0x2a8700[_0x3f40('0x39')],function(_0x3094b3){var _0x51fa47={};_0x51fa47[_0x3094b3]={'$like':'%'+_0x576623[_0x3f40('0x34')][_0x3f40('0x3f')]+'%'};return _0x51fa47;})});}_0x2a8700=_[_0x3f40('0x41')]({},_0x2a8700,_0x576623[_0x3f40('0x42')]);return _0x31dbdb[_0x3f40('0x51')](_0x2a8700);}})[_0x3f40('0x28')](function(_0x3c6f05){if(_0x3c6f05){_0x5bde61=_0x3c6f05[_0x3f40('0x3a')];if(!_0x576623[_0x3f40('0x34')]['hasOwnProperty'](_0x3f40('0x3c'))){_0x2a8700[_0x3f40('0x22')]=qs[_0x3f40('0x22')](_0x576623[_0x3f40('0x34')][_0x3f40('0x22')]);_0x2a8700['offset']=qs[_0x3f40('0x21')](_0x576623[_0x3f40('0x34')][_0x3f40('0x21')]);}return _0x31dbdb[_0x3f40('0x51')](_0x2a8700);}})[_0x3f40('0x28')](function(_0x49ea08){if(_0x49ea08){return _0x49ea08?{'count':_0x5bde61,'rows':_0x49ea08}:null;}})[_0x3f40('0x28')](respondWithResult(_0x5b00ed,null))[_0x3f40('0x48')](handleError(_0x5b00ed,null));};
\ No newline at end of file
+var _0x3659=['includeAll','include','findAll','rows','catch','show','params','keys','length','find','create','body','getFields','findOne','SugarcrmField','getSubjects','getDescriptions','zip-dir','fast-json-patch','request-promise','moment','mustache','util','path','fs-extra','crypto','to-csv','querystring','papaparse','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','api','../../config/utils','../../config/environment','../../config/license/util','sendStatus','status','json','offset','undefined','count','set','Content-Range','apply','reject','update','then','destroy','end','name','send','index','map','SugarcrmConfiguration','rawAttributes','fieldName','type','key','model','query','filters','attributes','intersection','fields','hasOwnProperty','nolimit','limit','order','sort','where','pick','VIRTUAL','filter','merge','options'];(function(_0xa464c9,_0x7c86d8){var _0x3d73c4=function(_0x5c2056){while(--_0x5c2056){_0xa464c9['push'](_0xa464c9['shift']());}};_0x3d73c4(++_0x7c86d8);}(_0x3659,0x1e5));var _0x9365=function(_0x119705,_0xba9427){_0x119705=_0x119705-0x0;var _0x2affc2=_0x3659[_0x119705];return _0x2affc2;};'use strict';var emlformat=require('eml-format');var rimraf=require('rimraf');var zipdir=require(_0x9365('0x0'));var jsonpatch=require(_0x9365('0x1'));var rp=require(_0x9365('0x2'));var moment=require(_0x9365('0x3'));var BPromise=require('bluebird');var Mustache=require(_0x9365('0x4'));var util=require(_0x9365('0x5'));var path=require(_0x9365('0x6'));var sox=require('sox');var csv=require('to-csv');var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x9365('0x7'));var _=require('lodash');var squel=require('squel');var crypto=require(_0x9365('0x8'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require(_0x9365('0x9'));var querystring=require(_0x9365('0xa'));var Papa=require(_0x9365('0xb'));var Redis=require('ioredis');var authService=require(_0x9365('0xc'));var qs=require(_0x9365('0xd'));var as=require(_0x9365('0xe'));var hardwareService=require(_0x9365('0xf'));var logger=require(_0x9365('0x10'))(_0x9365('0x11'));var utils=require(_0x9365('0x12'));var config=require(_0x9365('0x13'));var licenseUtil=require(_0x9365('0x14'));var db=require('../../mysqldb')['db'];function respondWithStatusCode(_0x134bca,_0x188c5c){_0x188c5c=_0x188c5c||0xcc;return function(_0x455308){if(_0x455308){return _0x134bca[_0x9365('0x15')](_0x188c5c);}return _0x134bca[_0x9365('0x16')](_0x188c5c)['end']();};}function respondWithResult(_0x3c3ef1,_0x3a7073){_0x3a7073=_0x3a7073||0xc8;return function(_0x24cc8e){if(_0x24cc8e){return _0x3c3ef1[_0x9365('0x16')](_0x3a7073)[_0x9365('0x17')](_0x24cc8e);}};}function respondWithFilteredResult(_0x3d2df9,_0x1d2d45){return function(_0x44d44b){if(_0x44d44b){var _0x55aca7=typeof _0x1d2d45[_0x9365('0x18')]===_0x9365('0x19')&&typeof _0x1d2d45['limit']===_0x9365('0x19');var _0x157f52=_0x44d44b[_0x9365('0x1a')];var _0x394215=_0x55aca7?0x0:_0x1d2d45[_0x9365('0x18')];var _0x5ab440=_0x55aca7?_0x44d44b[_0x9365('0x1a')]:_0x1d2d45[_0x9365('0x18')]+_0x1d2d45['limit'];var _0x391d24;if(_0x5ab440>=_0x157f52){_0x5ab440=_0x157f52;_0x391d24=0xc8;}else{_0x391d24=0xce;}_0x3d2df9[_0x9365('0x16')](_0x391d24);return _0x3d2df9[_0x9365('0x1b')](_0x9365('0x1c'),_0x394215+'-'+_0x5ab440+'/'+_0x157f52)[_0x9365('0x17')](_0x44d44b);}return null;};}function patchUpdates(_0x1d9d37){return function(_0x2d5006){try{jsonpatch[_0x9365('0x1d')](_0x2d5006,_0x1d9d37,!![]);}catch(_0x3dcd28){return BPromise[_0x9365('0x1e')](_0x3dcd28);}return _0x2d5006['save']();};}function saveUpdates(_0x5969a7,_0x23198a){return function(_0x2dbc51){if(_0x2dbc51){return _0x2dbc51[_0x9365('0x1f')](_0x5969a7)[_0x9365('0x20')](function(_0x570d83){return _0x570d83;});}return null;};}function removeEntity(_0x152605,_0x50cb64){return function(_0x34cf7b){if(_0x34cf7b){return _0x34cf7b[_0x9365('0x21')]()['then'](function(){_0x152605[_0x9365('0x16')](0xcc)[_0x9365('0x22')]();});}};}function handleEntityNotFound(_0x46474b,_0x1633cf){return function(_0x247520){if(!_0x247520){_0x46474b[_0x9365('0x15')](0x194);}return _0x247520;};}function handleError(_0x4f7337,_0x4a90f0){_0x4a90f0=_0x4a90f0||0x1f4;return function(_0x5c75e4){logger['error'](_0x5c75e4['stack']);if(_0x5c75e4[_0x9365('0x23')]){delete _0x5c75e4[_0x9365('0x23')];}_0x4f7337[_0x9365('0x16')](_0x4a90f0)[_0x9365('0x24')](_0x5c75e4);};}exports[_0x9365('0x25')]=function(_0xb2495a,_0x4aba1d){var _0x5e714f={},_0xae9a63={},_0x195102={'count':0x0,'rows':[]};var _0x2b5c56=_[_0x9365('0x26')](db[_0x9365('0x27')][_0x9365('0x28')],function(_0x3aa719){return{'name':_0x3aa719[_0x9365('0x29')],'type':_0x3aa719[_0x9365('0x2a')][_0x9365('0x2b')]};});_0xae9a63[_0x9365('0x2c')]=_[_0x9365('0x26')](_0x2b5c56,_0x9365('0x23'));_0xae9a63['query']=_['keys'](_0xb2495a[_0x9365('0x2d')]);_0xae9a63[_0x9365('0x2e')]=_['intersection'](_0xae9a63[_0x9365('0x2c')],_0xae9a63[_0x9365('0x2d')]);_0x5e714f[_0x9365('0x2f')]=_[_0x9365('0x30')](_0xae9a63[_0x9365('0x2c')],qs[_0x9365('0x31')](_0xb2495a[_0x9365('0x2d')][_0x9365('0x31')]));_0x5e714f[_0x9365('0x2f')]=_0x5e714f[_0x9365('0x2f')]['length']?_0x5e714f[_0x9365('0x2f')]:_0xae9a63['model'];if(!_0xb2495a['query'][_0x9365('0x32')](_0x9365('0x33'))){_0x5e714f[_0x9365('0x34')]=qs[_0x9365('0x34')](_0xb2495a['query'][_0x9365('0x34')]);_0x5e714f[_0x9365('0x18')]=qs[_0x9365('0x18')](_0xb2495a[_0x9365('0x2d')][_0x9365('0x18')]);}_0x5e714f[_0x9365('0x35')]=qs[_0x9365('0x36')](_0xb2495a[_0x9365('0x2d')]['sort']);_0x5e714f[_0x9365('0x37')]=qs[_0x9365('0x2e')](_[_0x9365('0x38')](_0xb2495a[_0x9365('0x2d')],_0xae9a63[_0x9365('0x2e')]),_0x2b5c56);if(_0xb2495a[_0x9365('0x2d')]['filter']){_0x5e714f[_0x9365('0x37')]=_['merge'](_0x5e714f['where'],{'$or':_['map'](_0x2b5c56,function(_0x527306){if(_0x527306[_0x9365('0x2a')]!==_0x9365('0x39')){var _0x164b5d={};_0x164b5d[_0x527306['name']]={'$like':'%'+_0xb2495a[_0x9365('0x2d')][_0x9365('0x3a')]+'%'};return _0x164b5d;}})});}_0x5e714f=_[_0x9365('0x3b')]({},_0x5e714f,_0xb2495a[_0x9365('0x3c')]);var _0x10bbb2={'where':_0x5e714f['where']};return db[_0x9365('0x27')][_0x9365('0x1a')](_0x10bbb2)[_0x9365('0x20')](function(_0x2cb6ec){_0x195102['count']=_0x2cb6ec;if(_0xb2495a[_0x9365('0x2d')][_0x9365('0x3d')]){_0x5e714f[_0x9365('0x3e')]=[{'all':!![]}];}return db[_0x9365('0x27')][_0x9365('0x3f')](_0x5e714f);})['then'](function(_0x3232cd){_0x195102[_0x9365('0x40')]=_0x3232cd;return _0x195102;})[_0x9365('0x20')](respondWithFilteredResult(_0x4aba1d,_0x5e714f))[_0x9365('0x41')](handleError(_0x4aba1d,null));};exports[_0x9365('0x42')]=function(_0x3979de,_0x1db10d){var _0x1eb201={'raw':![],'where':{'id':_0x3979de[_0x9365('0x43')]['id']}},_0xdf17a3={};_0xdf17a3[_0x9365('0x2c')]=_[_0x9365('0x44')](db[_0x9365('0x27')][_0x9365('0x28')]);_0xdf17a3[_0x9365('0x2d')]=_[_0x9365('0x44')](_0x3979de[_0x9365('0x2d')]);_0xdf17a3[_0x9365('0x2e')]=_[_0x9365('0x30')](_0xdf17a3[_0x9365('0x2c')],_0xdf17a3[_0x9365('0x2d')]);_0x1eb201[_0x9365('0x2f')]=_[_0x9365('0x30')](_0xdf17a3['model'],qs['fields'](_0x3979de[_0x9365('0x2d')]['fields']));_0x1eb201['attributes']=_0x1eb201['attributes'][_0x9365('0x45')]?_0x1eb201[_0x9365('0x2f')]:_0xdf17a3[_0x9365('0x2c')];if(_0x3979de[_0x9365('0x2d')]['includeAll']){_0x1eb201[_0x9365('0x3e')]=[{'all':!![]}];}_0x1eb201=_[_0x9365('0x3b')]({},_0x1eb201,_0x3979de['options']);return db[_0x9365('0x27')][_0x9365('0x46')](_0x1eb201)['then'](handleEntityNotFound(_0x1db10d,null))[_0x9365('0x20')](respondWithResult(_0x1db10d,null))[_0x9365('0x41')](handleError(_0x1db10d,null));};exports['create']=function(_0x382b52,_0xe28991){return db[_0x9365('0x27')][_0x9365('0x47')](_0x382b52[_0x9365('0x48')],{})[_0x9365('0x20')](respondWithResult(_0xe28991,0xc9))[_0x9365('0x41')](handleError(_0xe28991,null));};exports['update']=function(_0x532112,_0x28c40c){if(_0x532112[_0x9365('0x48')]['id']){delete _0x532112['body']['id'];}return db[_0x9365('0x27')][_0x9365('0x46')]({'where':{'id':_0x532112[_0x9365('0x43')]['id']}})[_0x9365('0x20')](handleEntityNotFound(_0x28c40c,null))['then'](saveUpdates(_0x532112[_0x9365('0x48')],null))[_0x9365('0x20')](respondWithResult(_0x28c40c,null))[_0x9365('0x41')](handleError(_0x28c40c,null));};exports[_0x9365('0x21')]=function(_0x1dc6f2,_0x336613){return db[_0x9365('0x27')][_0x9365('0x46')]({'where':{'id':_0x1dc6f2[_0x9365('0x43')]['id']}})[_0x9365('0x20')](handleEntityNotFound(_0x336613,null))['then'](removeEntity(_0x336613,null))[_0x9365('0x41')](handleError(_0x336613,null));};exports[_0x9365('0x49')]=function(_0x4fdc3e,_0x4cc7ef,_0x42c959){var _0xd0e4d7={};var _0x56ee81={};var _0x25f0aa;var _0x3c247f;return db[_0x9365('0x27')][_0x9365('0x4a')]({'where':{'id':_0x4fdc3e[_0x9365('0x43')]['id']}})[_0x9365('0x20')](handleEntityNotFound(_0x4cc7ef,null))[_0x9365('0x20')](function(_0x33c7a6){if(_0x33c7a6){_0x25f0aa=_0x33c7a6;_0x56ee81[_0x9365('0x2c')]=_[_0x9365('0x44')](db[_0x9365('0x4b')][_0x9365('0x28')]);_0x56ee81[_0x9365('0x2d')]=_['keys'](_0x4fdc3e[_0x9365('0x2d')]);_0x56ee81[_0x9365('0x2e')]=_[_0x9365('0x30')](_0x56ee81[_0x9365('0x2c')],_0x56ee81[_0x9365('0x2d')]);_0xd0e4d7['attributes']=_[_0x9365('0x30')](_0x56ee81[_0x9365('0x2c')],qs[_0x9365('0x31')](_0x4fdc3e[_0x9365('0x2d')][_0x9365('0x31')]));_0xd0e4d7[_0x9365('0x2f')]=_0xd0e4d7[_0x9365('0x2f')]['length']?_0xd0e4d7['attributes']:_0x56ee81[_0x9365('0x2c')];_0xd0e4d7[_0x9365('0x35')]=qs[_0x9365('0x36')](_0x4fdc3e[_0x9365('0x2d')][_0x9365('0x36')]);_0xd0e4d7[_0x9365('0x37')]=qs[_0x9365('0x2e')](_[_0x9365('0x38')](_0x4fdc3e[_0x9365('0x2d')],_0x56ee81['filters']));if(_0x4fdc3e[_0x9365('0x2d')]['filter']){_0xd0e4d7['where']=_['merge'](_0xd0e4d7[_0x9365('0x37')],{'$or':_[_0x9365('0x26')](_0xd0e4d7[_0x9365('0x2f')],function(_0x12642c){var _0x1e9252={};_0x1e9252[_0x12642c]={'$like':'%'+_0x4fdc3e[_0x9365('0x2d')]['filter']+'%'};return _0x1e9252;})});}_0xd0e4d7=_[_0x9365('0x3b')]({},_0xd0e4d7,_0x4fdc3e[_0x9365('0x3c')]);return _0x25f0aa['getFields'](_0xd0e4d7);}})['then'](function(_0x33c0c3){if(_0x33c0c3){_0x3c247f=_0x33c0c3[_0x9365('0x45')];if(!_0x4fdc3e[_0x9365('0x2d')][_0x9365('0x32')](_0x9365('0x33'))){_0xd0e4d7[_0x9365('0x34')]=qs[_0x9365('0x34')](_0x4fdc3e[_0x9365('0x2d')][_0x9365('0x34')]);_0xd0e4d7[_0x9365('0x18')]=qs[_0x9365('0x18')](_0x4fdc3e[_0x9365('0x2d')][_0x9365('0x18')]);}return _0x25f0aa['getFields'](_0xd0e4d7);}})['then'](function(_0x3113d2){if(_0x3113d2){return _0x3113d2?{'count':_0x3c247f,'rows':_0x3113d2}:null;}})[_0x9365('0x20')](respondWithResult(_0x4cc7ef,null))[_0x9365('0x41')](handleError(_0x4cc7ef,null));};exports[_0x9365('0x4c')]=function(_0x22aafe,_0x5eaed9,_0x1eb8d0){var _0x521c34={};var _0x1f1eaf={};var _0x449618;var _0x2edd56;return db[_0x9365('0x27')][_0x9365('0x4a')]({'where':{'id':_0x22aafe['params']['id']}})[_0x9365('0x20')](handleEntityNotFound(_0x5eaed9,null))[_0x9365('0x20')](function(_0x385f38){if(_0x385f38){_0x449618=_0x385f38;_0x1f1eaf[_0x9365('0x2c')]=_[_0x9365('0x44')](db[_0x9365('0x4b')][_0x9365('0x28')]);_0x1f1eaf[_0x9365('0x2d')]=_[_0x9365('0x44')](_0x22aafe['query']);_0x1f1eaf[_0x9365('0x2e')]=_[_0x9365('0x30')](_0x1f1eaf[_0x9365('0x2c')],_0x1f1eaf[_0x9365('0x2d')]);_0x521c34[_0x9365('0x2f')]=_[_0x9365('0x30')](_0x1f1eaf['model'],qs[_0x9365('0x31')](_0x22aafe[_0x9365('0x2d')][_0x9365('0x31')]));_0x521c34[_0x9365('0x2f')]=_0x521c34['attributes'][_0x9365('0x45')]?_0x521c34[_0x9365('0x2f')]:_0x1f1eaf[_0x9365('0x2c')];_0x521c34[_0x9365('0x35')]=qs['sort'](_0x22aafe['query']['sort']);_0x521c34[_0x9365('0x37')]=qs['filters'](_[_0x9365('0x38')](_0x22aafe[_0x9365('0x2d')],_0x1f1eaf[_0x9365('0x2e')]));if(_0x22aafe[_0x9365('0x2d')][_0x9365('0x3a')]){_0x521c34['where']=_[_0x9365('0x3b')](_0x521c34[_0x9365('0x37')],{'$or':_[_0x9365('0x26')](_0x521c34[_0x9365('0x2f')],function(_0x5d046b){var _0x20e6f2={};_0x20e6f2[_0x5d046b]={'$like':'%'+_0x22aafe[_0x9365('0x2d')][_0x9365('0x3a')]+'%'};return _0x20e6f2;})});}_0x521c34=_[_0x9365('0x3b')]({},_0x521c34,_0x22aafe[_0x9365('0x3c')]);return _0x449618[_0x9365('0x4c')](_0x521c34);}})[_0x9365('0x20')](function(_0x104717){if(_0x104717){_0x2edd56=_0x104717[_0x9365('0x45')];if(!_0x22aafe['query'][_0x9365('0x32')](_0x9365('0x33'))){_0x521c34[_0x9365('0x34')]=qs['limit'](_0x22aafe[_0x9365('0x2d')][_0x9365('0x34')]);_0x521c34[_0x9365('0x18')]=qs[_0x9365('0x18')](_0x22aafe[_0x9365('0x2d')][_0x9365('0x18')]);}return _0x449618[_0x9365('0x4c')](_0x521c34);}})['then'](function(_0x249e8d){if(_0x249e8d){return _0x249e8d?{'count':_0x2edd56,'rows':_0x249e8d}:null;}})[_0x9365('0x20')](respondWithResult(_0x5eaed9,null))[_0x9365('0x41')](handleError(_0x5eaed9,null));};exports['getDescriptions']=function(_0x118709,_0x43ecaa,_0x10f851){var _0x364f40={};var _0x26c8c7={};var _0x4be7d0;var _0x3b1072;return db[_0x9365('0x27')][_0x9365('0x4a')]({'where':{'id':_0x118709[_0x9365('0x43')]['id']}})[_0x9365('0x20')](handleEntityNotFound(_0x43ecaa,null))[_0x9365('0x20')](function(_0x3aaecb){if(_0x3aaecb){_0x4be7d0=_0x3aaecb;_0x26c8c7[_0x9365('0x2c')]=_[_0x9365('0x44')](db[_0x9365('0x4b')][_0x9365('0x28')]);_0x26c8c7[_0x9365('0x2d')]=_[_0x9365('0x44')](_0x118709[_0x9365('0x2d')]);_0x26c8c7[_0x9365('0x2e')]=_[_0x9365('0x30')](_0x26c8c7['model'],_0x26c8c7[_0x9365('0x2d')]);_0x364f40[_0x9365('0x2f')]=_[_0x9365('0x30')](_0x26c8c7[_0x9365('0x2c')],qs[_0x9365('0x31')](_0x118709[_0x9365('0x2d')][_0x9365('0x31')]));_0x364f40[_0x9365('0x2f')]=_0x364f40[_0x9365('0x2f')][_0x9365('0x45')]?_0x364f40[_0x9365('0x2f')]:_0x26c8c7[_0x9365('0x2c')];_0x364f40[_0x9365('0x35')]=qs['sort'](_0x118709[_0x9365('0x2d')][_0x9365('0x36')]);_0x364f40[_0x9365('0x37')]=qs['filters'](_[_0x9365('0x38')](_0x118709[_0x9365('0x2d')],_0x26c8c7[_0x9365('0x2e')]));if(_0x118709[_0x9365('0x2d')][_0x9365('0x3a')]){_0x364f40[_0x9365('0x37')]=_['merge'](_0x364f40[_0x9365('0x37')],{'$or':_['map'](_0x364f40[_0x9365('0x2f')],function(_0x4180cc){var _0x35ca56={};_0x35ca56[_0x4180cc]={'$like':'%'+_0x118709[_0x9365('0x2d')][_0x9365('0x3a')]+'%'};return _0x35ca56;})});}_0x364f40=_[_0x9365('0x3b')]({},_0x364f40,_0x118709[_0x9365('0x3c')]);return _0x4be7d0[_0x9365('0x4d')](_0x364f40);}})['then'](function(_0x3d9748){if(_0x3d9748){_0x3b1072=_0x3d9748[_0x9365('0x45')];if(!_0x118709[_0x9365('0x2d')]['hasOwnProperty']('nolimit')){_0x364f40[_0x9365('0x34')]=qs[_0x9365('0x34')](_0x118709[_0x9365('0x2d')][_0x9365('0x34')]);_0x364f40['offset']=qs[_0x9365('0x18')](_0x118709[_0x9365('0x2d')][_0x9365('0x18')]);}return _0x4be7d0[_0x9365('0x4d')](_0x364f40);}})[_0x9365('0x20')](function(_0x187433){if(_0x187433){return _0x187433?{'count':_0x3b1072,'rows':_0x187433}:null;}})['then'](respondWithResult(_0x43ecaa,null))['catch'](handleError(_0x43ecaa,null));};
\ No newline at end of file