758d3791495c948ed3420b83c26151a7457245fe
[motion2.git] / server / api / intDeskConfiguration / intDeskConfiguration.controller.js
1 // *************************************************************************
2 // *                                                                       *
3 // * xCALLY Motion -  The Omnichannel Contact Center                       *
4 // * Copyright (c) Xenialab s.r.l. All Rights Reserved                     *
5 // *                                                                       *
6 // *************************************************************************
7 // *                                                                       *
8 // * Email: info@xcally.com                                                *
9 // * Website: https://www.xcally.com                                       *
10 // *                                                                       *
11 // *************************************************************************
12 // *                                                                       *
13 // * The SOFTWARE PRODUCT is protected by copyright laws and international *
14 // * copyright treaties, as well as other intellectual property laws and   *
15 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                         *
16 // *                                                                       *
17 // *************************************************************************
18 var _0xeac0=['options','DeskConfiguration','includeAll','include','rows','params','keys','find','create','body','catch','findOne','DeskField','order','filter','merge','getFields','getSubjects','getDescriptions','getTags','Tag','setTags','ids','eml-format','zip-dir','fast-json-patch','request-promise','moment','bluebird','mustache','util','path','sox','to-csv','fs-extra','lodash','jsforce','desk.js','querystring','ioredis','../../components/auth/service','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','offset','undefined','count','limit','Content-Range','json','save','update','then','destroy','error','name','send','index','map','rawAttributes','fieldName','type','key','query','filters','intersection','model','attributes','fields','length','hasOwnProperty','nolimit','sort','pick','where','VIRTUAL'];(function(_0x4a9fb1,_0x273043){var _0x348672=function(_0x142b69){while(--_0x142b69){_0x4a9fb1['push'](_0x4a9fb1['shift']());}};_0x348672(++_0x273043);}(_0xeac0,0x15f));var _0x0eac=function(_0x1ad5d6,_0x43c143){_0x1ad5d6=_0x1ad5d6-0x0;var _0x275261=_0xeac0[_0x1ad5d6];return _0x275261;};'use strict';var emlformat=require(_0x0eac('0x0'));var rimraf=require('rimraf');var zipdir=require(_0x0eac('0x1'));var jsonpatch=require(_0x0eac('0x2'));var rp=require(_0x0eac('0x3'));var moment=require(_0x0eac('0x4'));var BPromise=require(_0x0eac('0x5'));var Mustache=require(_0x0eac('0x6'));var util=require(_0x0eac('0x7'));var path=require(_0x0eac('0x8'));var sox=require(_0x0eac('0x9'));var csv=require(_0x0eac('0xa'));var ejs=require('ejs');var fs=require('fs');var fs_extra=require(_0x0eac('0xb'));var _=require(_0x0eac('0xc'));var squel=require('squel');var crypto=require('crypto');var jsforce=require(_0x0eac('0xd'));var deskjs=require(_0x0eac('0xe'));var toCsv=require(_0x0eac('0xa'));var querystring=require(_0x0eac('0xf'));var Papa=require('papaparse');var Redis=require(_0x0eac('0x10'));var authService=require(_0x0eac('0x11'));var qs=require('../../components/parsers/qs');var as=require(_0x0eac('0x12'));var hardwareService=require(_0x0eac('0x13'));var logger=require(_0x0eac('0x14'))('api');var utils=require('../../config/utils');var config=require(_0x0eac('0x15'));var licenseUtil=require(_0x0eac('0x16'));var db=require(_0x0eac('0x17'))['db'];function respondWithStatusCode(_0x421594,_0x4add61){_0x4add61=_0x4add61||0xcc;return function(_0x57a164){if(_0x57a164){return _0x421594[_0x0eac('0x18')](_0x4add61);}return _0x421594[_0x0eac('0x19')](_0x4add61)[_0x0eac('0x1a')]();};}function respondWithResult(_0xd38858,_0x22fc5c){_0x22fc5c=_0x22fc5c||0xc8;return function(_0xf32707){if(_0xf32707){return _0xd38858[_0x0eac('0x19')](_0x22fc5c)['json'](_0xf32707);}};}function respondWithFilteredResult(_0x569c47,_0xa52fae){return function(_0x263423){if(_0x263423){var _0x59a9bc=typeof _0xa52fae[_0x0eac('0x1b')]===_0x0eac('0x1c')&&typeof _0xa52fae['limit']==='undefined';var _0x3f3831=_0x263423[_0x0eac('0x1d')];var _0x21db27=_0x59a9bc?0x0:_0xa52fae['offset'];var _0x576eec=_0x59a9bc?_0x263423[_0x0eac('0x1d')]:_0xa52fae[_0x0eac('0x1b')]+_0xa52fae[_0x0eac('0x1e')];var _0x1f7e89;if(_0x576eec>=_0x3f3831){_0x576eec=_0x3f3831;_0x1f7e89=0xc8;}else{_0x1f7e89=0xce;}_0x569c47[_0x0eac('0x19')](_0x1f7e89);return _0x569c47['set'](_0x0eac('0x1f'),_0x21db27+'-'+_0x576eec+'/'+_0x3f3831)[_0x0eac('0x20')](_0x263423);}return null;};}function patchUpdates(_0x54ccbf){return function(_0x71b702){try{jsonpatch['apply'](_0x71b702,_0x54ccbf,!![]);}catch(_0x297316){return BPromise['reject'](_0x297316);}return _0x71b702[_0x0eac('0x21')]();};}function saveUpdates(_0x579d12,_0x4b63de){return function(_0x41ee6b){if(_0x41ee6b){return _0x41ee6b[_0x0eac('0x22')](_0x579d12)[_0x0eac('0x23')](function(_0x290c58){return _0x290c58;});}return null;};}function removeEntity(_0x4f0464,_0x25cbf0){return function(_0x4943d5){if(_0x4943d5){return _0x4943d5[_0x0eac('0x24')]()[_0x0eac('0x23')](function(){_0x4f0464[_0x0eac('0x19')](0xcc)[_0x0eac('0x1a')]();});}};}function handleEntityNotFound(_0x143c20,_0x55ddf7){return function(_0x5aba80){if(!_0x5aba80){_0x143c20[_0x0eac('0x18')](0x194);}return _0x5aba80;};}function handleError(_0x4163e9,_0x5d6ded){_0x5d6ded=_0x5d6ded||0x1f4;return function(_0x5a799d){logger[_0x0eac('0x25')](_0x5a799d['stack']);if(_0x5a799d[_0x0eac('0x26')]){delete _0x5a799d[_0x0eac('0x26')];}_0x4163e9['status'](_0x5d6ded)[_0x0eac('0x27')](_0x5a799d);};}exports[_0x0eac('0x28')]=function(_0x242742,_0x220eb7){var _0x2d24a7={},_0x45bd5a={},_0x2c343e={'count':0x0,'rows':[]};var _0xe2c3f4=_[_0x0eac('0x29')](db['DeskConfiguration'][_0x0eac('0x2a')],function(_0x40cfec){return{'name':_0x40cfec[_0x0eac('0x2b')],'type':_0x40cfec[_0x0eac('0x2c')][_0x0eac('0x2d')]};});_0x45bd5a['model']=_[_0x0eac('0x29')](_0xe2c3f4,_0x0eac('0x26'));_0x45bd5a['query']=_['keys'](_0x242742[_0x0eac('0x2e')]);_0x45bd5a[_0x0eac('0x2f')]=_[_0x0eac('0x30')](_0x45bd5a[_0x0eac('0x31')],_0x45bd5a[_0x0eac('0x2e')]);_0x2d24a7[_0x0eac('0x32')]=_[_0x0eac('0x30')](_0x45bd5a['model'],qs[_0x0eac('0x33')](_0x242742[_0x0eac('0x2e')][_0x0eac('0x33')]));_0x2d24a7[_0x0eac('0x32')]=_0x2d24a7['attributes'][_0x0eac('0x34')]?_0x2d24a7[_0x0eac('0x32')]:_0x45bd5a[_0x0eac('0x31')];if(!_0x242742['query'][_0x0eac('0x35')](_0x0eac('0x36'))){_0x2d24a7['limit']=qs[_0x0eac('0x1e')](_0x242742['query'][_0x0eac('0x1e')]);_0x2d24a7['offset']=qs['offset'](_0x242742[_0x0eac('0x2e')][_0x0eac('0x1b')]);}_0x2d24a7['order']=qs[_0x0eac('0x37')](_0x242742['query'][_0x0eac('0x37')]);_0x2d24a7['where']=qs[_0x0eac('0x2f')](_[_0x0eac('0x38')](_0x242742[_0x0eac('0x2e')],_0x45bd5a[_0x0eac('0x2f')]),_0xe2c3f4);if(_0x242742[_0x0eac('0x2e')]['filter']){_0x2d24a7[_0x0eac('0x39')]=_['merge'](_0x2d24a7[_0x0eac('0x39')],{'$or':_['map'](_0xe2c3f4,function(_0xdb3808){if(_0xdb3808[_0x0eac('0x2c')]!==_0x0eac('0x3a')){var _0x2fb05b={};_0x2fb05b[_0xdb3808['name']]={'$like':'%'+_0x242742['query']['filter']+'%'};return _0x2fb05b;}})});}_0x2d24a7=_['merge']({},_0x2d24a7,_0x242742[_0x0eac('0x3b')]);var _0x45a510={'where':_0x2d24a7[_0x0eac('0x39')]};return db[_0x0eac('0x3c')]['count'](_0x45a510)['then'](function(_0x28e0e3){_0x2c343e[_0x0eac('0x1d')]=_0x28e0e3;if(_0x242742[_0x0eac('0x2e')][_0x0eac('0x3d')]){_0x2d24a7[_0x0eac('0x3e')]=[{'all':!![]}];}return db['DeskConfiguration']['findAll'](_0x2d24a7);})[_0x0eac('0x23')](function(_0x551898){_0x2c343e[_0x0eac('0x3f')]=_0x551898;return _0x2c343e;})[_0x0eac('0x23')](respondWithFilteredResult(_0x220eb7,_0x2d24a7))['catch'](handleError(_0x220eb7,null));};exports['show']=function(_0x4de9f2,_0x589041){var _0x43b350={'raw':![],'where':{'id':_0x4de9f2[_0x0eac('0x40')]['id']}},_0x356fe7={};_0x356fe7[_0x0eac('0x31')]=_[_0x0eac('0x41')](db[_0x0eac('0x3c')][_0x0eac('0x2a')]);_0x356fe7[_0x0eac('0x2e')]=_['keys'](_0x4de9f2[_0x0eac('0x2e')]);_0x356fe7['filters']=_['intersection'](_0x356fe7[_0x0eac('0x31')],_0x356fe7[_0x0eac('0x2e')]);_0x43b350[_0x0eac('0x32')]=_[_0x0eac('0x30')](_0x356fe7[_0x0eac('0x31')],qs[_0x0eac('0x33')](_0x4de9f2[_0x0eac('0x2e')]['fields']));_0x43b350['attributes']=_0x43b350[_0x0eac('0x32')][_0x0eac('0x34')]?_0x43b350[_0x0eac('0x32')]:_0x356fe7[_0x0eac('0x31')];if(_0x4de9f2[_0x0eac('0x2e')]['includeAll']){_0x43b350[_0x0eac('0x3e')]=[{'all':!![]}];}_0x43b350=_['merge']({},_0x43b350,_0x4de9f2[_0x0eac('0x3b')]);return db[_0x0eac('0x3c')][_0x0eac('0x42')](_0x43b350)[_0x0eac('0x23')](handleEntityNotFound(_0x589041,null))[_0x0eac('0x23')](respondWithResult(_0x589041,null))['catch'](handleError(_0x589041,null));};exports[_0x0eac('0x43')]=function(_0x354d71,_0x5e386e){return db[_0x0eac('0x3c')][_0x0eac('0x43')](_0x354d71[_0x0eac('0x44')],{})[_0x0eac('0x23')](respondWithResult(_0x5e386e,0xc9))[_0x0eac('0x45')](handleError(_0x5e386e,null));};exports[_0x0eac('0x22')]=function(_0x7692d3,_0x3d13bc){if(_0x7692d3[_0x0eac('0x44')]['id']){delete _0x7692d3[_0x0eac('0x44')]['id'];}return db[_0x0eac('0x3c')][_0x0eac('0x42')]({'where':{'id':_0x7692d3[_0x0eac('0x40')]['id']}})['then'](handleEntityNotFound(_0x3d13bc,null))[_0x0eac('0x23')](saveUpdates(_0x7692d3['body'],null))[_0x0eac('0x23')](respondWithResult(_0x3d13bc,null))[_0x0eac('0x45')](handleError(_0x3d13bc,null));};exports[_0x0eac('0x24')]=function(_0x2f2288,_0x2e2f55){return db['DeskConfiguration']['find']({'where':{'id':_0x2f2288['params']['id']}})[_0x0eac('0x23')](handleEntityNotFound(_0x2e2f55,null))['then'](removeEntity(_0x2e2f55,null))[_0x0eac('0x45')](handleError(_0x2e2f55,null));};exports['getFields']=function(_0x353257,_0x835669,_0x3b6b6c){var _0x341f5b={};var _0x55f039={};var _0x4a06d5;var _0x1b8af3;return db[_0x0eac('0x3c')][_0x0eac('0x46')]({'where':{'id':_0x353257[_0x0eac('0x40')]['id']}})[_0x0eac('0x23')](handleEntityNotFound(_0x835669,null))['then'](function(_0x377c76){if(_0x377c76){_0x4a06d5=_0x377c76;_0x55f039[_0x0eac('0x31')]=_[_0x0eac('0x41')](db[_0x0eac('0x47')][_0x0eac('0x2a')]);_0x55f039[_0x0eac('0x2e')]=_[_0x0eac('0x41')](_0x353257[_0x0eac('0x2e')]);_0x55f039[_0x0eac('0x2f')]=_['intersection'](_0x55f039[_0x0eac('0x31')],_0x55f039[_0x0eac('0x2e')]);_0x341f5b[_0x0eac('0x32')]=_[_0x0eac('0x30')](_0x55f039[_0x0eac('0x31')],qs[_0x0eac('0x33')](_0x353257[_0x0eac('0x2e')][_0x0eac('0x33')]));_0x341f5b['attributes']=_0x341f5b['attributes']['length']?_0x341f5b['attributes']:_0x55f039[_0x0eac('0x31')];_0x341f5b[_0x0eac('0x48')]=qs['sort'](_0x353257['query'][_0x0eac('0x37')]);_0x341f5b[_0x0eac('0x39')]=qs[_0x0eac('0x2f')](_[_0x0eac('0x38')](_0x353257[_0x0eac('0x2e')],_0x55f039[_0x0eac('0x2f')]));if(_0x353257['query'][_0x0eac('0x49')]){_0x341f5b[_0x0eac('0x39')]=_[_0x0eac('0x4a')](_0x341f5b[_0x0eac('0x39')],{'$or':_[_0x0eac('0x29')](_0x341f5b['attributes'],function(_0x1ddd3f){var _0x3fc6ff={};_0x3fc6ff[_0x1ddd3f]={'$like':'%'+_0x353257[_0x0eac('0x2e')][_0x0eac('0x49')]+'%'};return _0x3fc6ff;})});}_0x341f5b=_[_0x0eac('0x4a')]({},_0x341f5b,_0x353257['options']);return _0x4a06d5[_0x0eac('0x4b')](_0x341f5b);}})[_0x0eac('0x23')](function(_0x4276f9){if(_0x4276f9){_0x1b8af3=_0x4276f9[_0x0eac('0x34')];if(!_0x353257['query']['hasOwnProperty']('nolimit')){_0x341f5b[_0x0eac('0x1e')]=qs[_0x0eac('0x1e')](_0x353257[_0x0eac('0x2e')][_0x0eac('0x1e')]);_0x341f5b[_0x0eac('0x1b')]=qs[_0x0eac('0x1b')](_0x353257[_0x0eac('0x2e')][_0x0eac('0x1b')]);}return _0x4a06d5[_0x0eac('0x4b')](_0x341f5b);}})['then'](function(_0x138d5d){if(_0x138d5d){return _0x138d5d?{'count':_0x1b8af3,'rows':_0x138d5d}:null;}})[_0x0eac('0x23')](respondWithResult(_0x835669,null))[_0x0eac('0x45')](handleError(_0x835669,null));};exports[_0x0eac('0x4c')]=function(_0xf50fbb,_0xacd2ca,_0x4fd23c){var _0x4fa87e={};var _0x49eaee={};var _0x4b69ba;var _0x4f8642;return db[_0x0eac('0x3c')][_0x0eac('0x46')]({'where':{'id':_0xf50fbb['params']['id']}})[_0x0eac('0x23')](handleEntityNotFound(_0xacd2ca,null))[_0x0eac('0x23')](function(_0x893ec1){if(_0x893ec1){_0x4b69ba=_0x893ec1;_0x49eaee[_0x0eac('0x31')]=_[_0x0eac('0x41')](db[_0x0eac('0x47')][_0x0eac('0x2a')]);_0x49eaee['query']=_[_0x0eac('0x41')](_0xf50fbb[_0x0eac('0x2e')]);_0x49eaee[_0x0eac('0x2f')]=_[_0x0eac('0x30')](_0x49eaee['model'],_0x49eaee[_0x0eac('0x2e')]);_0x4fa87e[_0x0eac('0x32')]=_['intersection'](_0x49eaee[_0x0eac('0x31')],qs[_0x0eac('0x33')](_0xf50fbb[_0x0eac('0x2e')][_0x0eac('0x33')]));_0x4fa87e[_0x0eac('0x32')]=_0x4fa87e[_0x0eac('0x32')][_0x0eac('0x34')]?_0x4fa87e[_0x0eac('0x32')]:_0x49eaee[_0x0eac('0x31')];_0x4fa87e[_0x0eac('0x48')]=qs[_0x0eac('0x37')](_0xf50fbb[_0x0eac('0x2e')][_0x0eac('0x37')]);_0x4fa87e['where']=qs[_0x0eac('0x2f')](_[_0x0eac('0x38')](_0xf50fbb['query'],_0x49eaee[_0x0eac('0x2f')]));if(_0xf50fbb['query'][_0x0eac('0x49')]){_0x4fa87e[_0x0eac('0x39')]=_[_0x0eac('0x4a')](_0x4fa87e['where'],{'$or':_[_0x0eac('0x29')](_0x4fa87e[_0x0eac('0x32')],function(_0x1e903f){var _0x2a6ea1={};_0x2a6ea1[_0x1e903f]={'$like':'%'+_0xf50fbb[_0x0eac('0x2e')]['filter']+'%'};return _0x2a6ea1;})});}_0x4fa87e=_[_0x0eac('0x4a')]({},_0x4fa87e,_0xf50fbb[_0x0eac('0x3b')]);return _0x4b69ba[_0x0eac('0x4c')](_0x4fa87e);}})[_0x0eac('0x23')](function(_0xf5152b){if(_0xf5152b){_0x4f8642=_0xf5152b[_0x0eac('0x34')];if(!_0xf50fbb[_0x0eac('0x2e')][_0x0eac('0x35')]('nolimit')){_0x4fa87e['limit']=qs[_0x0eac('0x1e')](_0xf50fbb[_0x0eac('0x2e')][_0x0eac('0x1e')]);_0x4fa87e[_0x0eac('0x1b')]=qs[_0x0eac('0x1b')](_0xf50fbb[_0x0eac('0x2e')][_0x0eac('0x1b')]);}return _0x4b69ba[_0x0eac('0x4c')](_0x4fa87e);}})[_0x0eac('0x23')](function(_0x4f1a60){if(_0x4f1a60){return _0x4f1a60?{'count':_0x4f8642,'rows':_0x4f1a60}:null;}})[_0x0eac('0x23')](respondWithResult(_0xacd2ca,null))[_0x0eac('0x45')](handleError(_0xacd2ca,null));};exports[_0x0eac('0x4d')]=function(_0x25428a,_0xf40d3c,_0x1409ea){var _0x523467={};var _0x2d4a76={};var _0x101832;var _0x360909;return db[_0x0eac('0x3c')]['findOne']({'where':{'id':_0x25428a['params']['id']}})['then'](handleEntityNotFound(_0xf40d3c,null))[_0x0eac('0x23')](function(_0x16a86a){if(_0x16a86a){_0x101832=_0x16a86a;_0x2d4a76['model']=_[_0x0eac('0x41')](db['DeskField'][_0x0eac('0x2a')]);_0x2d4a76[_0x0eac('0x2e')]=_[_0x0eac('0x41')](_0x25428a['query']);_0x2d4a76['filters']=_[_0x0eac('0x30')](_0x2d4a76['model'],_0x2d4a76[_0x0eac('0x2e')]);_0x523467[_0x0eac('0x32')]=_[_0x0eac('0x30')](_0x2d4a76[_0x0eac('0x31')],qs[_0x0eac('0x33')](_0x25428a['query'][_0x0eac('0x33')]));_0x523467[_0x0eac('0x32')]=_0x523467[_0x0eac('0x32')][_0x0eac('0x34')]?_0x523467['attributes']:_0x2d4a76['model'];_0x523467['order']=qs[_0x0eac('0x37')](_0x25428a['query']['sort']);_0x523467['where']=qs[_0x0eac('0x2f')](_[_0x0eac('0x38')](_0x25428a[_0x0eac('0x2e')],_0x2d4a76[_0x0eac('0x2f')]));if(_0x25428a[_0x0eac('0x2e')][_0x0eac('0x49')]){_0x523467['where']=_[_0x0eac('0x4a')](_0x523467[_0x0eac('0x39')],{'$or':_[_0x0eac('0x29')](_0x523467[_0x0eac('0x32')],function(_0x4a75b8){var _0x3bfe75={};_0x3bfe75[_0x4a75b8]={'$like':'%'+_0x25428a[_0x0eac('0x2e')][_0x0eac('0x49')]+'%'};return _0x3bfe75;})});}_0x523467=_['merge']({},_0x523467,_0x25428a['options']);return _0x101832[_0x0eac('0x4d')](_0x523467);}})[_0x0eac('0x23')](function(_0x14b509){if(_0x14b509){_0x360909=_0x14b509[_0x0eac('0x34')];if(!_0x25428a[_0x0eac('0x2e')][_0x0eac('0x35')]('nolimit')){_0x523467[_0x0eac('0x1e')]=qs[_0x0eac('0x1e')](_0x25428a[_0x0eac('0x2e')][_0x0eac('0x1e')]);_0x523467[_0x0eac('0x1b')]=qs[_0x0eac('0x1b')](_0x25428a[_0x0eac('0x2e')][_0x0eac('0x1b')]);}return _0x101832[_0x0eac('0x4d')](_0x523467);}})[_0x0eac('0x23')](function(_0xa77e9c){if(_0xa77e9c){return _0xa77e9c?{'count':_0x360909,'rows':_0xa77e9c}:null;}})['then'](respondWithResult(_0xf40d3c,null))[_0x0eac('0x45')](handleError(_0xf40d3c,null));};exports[_0x0eac('0x4e')]=function(_0x24cd4d,_0xdff4bc,_0x2ab465){var _0x33fcb0={};var _0x4f9a86={};var _0x1a3d3d;var _0x49b2da;return db[_0x0eac('0x3c')][_0x0eac('0x46')]({'where':{'id':_0x24cd4d['params']['id']}})['then'](handleEntityNotFound(_0xdff4bc,null))[_0x0eac('0x23')](function(_0x258d57){if(_0x258d57){_0x1a3d3d=_0x258d57;_0x4f9a86['model']=_[_0x0eac('0x41')](db[_0x0eac('0x4f')][_0x0eac('0x2a')]);_0x4f9a86[_0x0eac('0x2e')]=_[_0x0eac('0x41')](_0x24cd4d[_0x0eac('0x2e')]);_0x4f9a86[_0x0eac('0x2f')]=_[_0x0eac('0x30')](_0x4f9a86[_0x0eac('0x31')],_0x4f9a86[_0x0eac('0x2e')]);_0x33fcb0['attributes']=_['intersection'](_0x4f9a86[_0x0eac('0x31')],qs[_0x0eac('0x33')](_0x24cd4d[_0x0eac('0x2e')][_0x0eac('0x33')]));_0x33fcb0[_0x0eac('0x32')]=_0x33fcb0['attributes']['length']?_0x33fcb0['attributes']:_0x4f9a86[_0x0eac('0x31')];_0x33fcb0[_0x0eac('0x48')]=qs[_0x0eac('0x37')](_0x24cd4d[_0x0eac('0x2e')][_0x0eac('0x37')]);_0x33fcb0[_0x0eac('0x39')]=qs[_0x0eac('0x2f')](_[_0x0eac('0x38')](_0x24cd4d[_0x0eac('0x2e')],_0x4f9a86[_0x0eac('0x2f')]));if(_0x24cd4d['query'][_0x0eac('0x49')]){_0x33fcb0['where']=_[_0x0eac('0x4a')](_0x33fcb0['where'],{'$or':_['map'](_0x33fcb0[_0x0eac('0x32')],function(_0x3e287e){var _0x5f02d0={};_0x5f02d0[_0x3e287e]={'$like':'%'+_0x24cd4d[_0x0eac('0x2e')][_0x0eac('0x49')]+'%'};return _0x5f02d0;})});}_0x33fcb0=_[_0x0eac('0x4a')]({},_0x33fcb0,_0x24cd4d[_0x0eac('0x3b')]);return _0x1a3d3d[_0x0eac('0x4e')](_0x33fcb0);}})[_0x0eac('0x23')](function(_0x24cf9a){if(_0x24cf9a){_0x49b2da=_0x24cf9a[_0x0eac('0x34')];if(!_0x24cd4d[_0x0eac('0x2e')]['hasOwnProperty'](_0x0eac('0x36'))){_0x33fcb0['limit']=qs['limit'](_0x24cd4d['query'][_0x0eac('0x1e')]);_0x33fcb0[_0x0eac('0x1b')]=qs[_0x0eac('0x1b')](_0x24cd4d[_0x0eac('0x2e')][_0x0eac('0x1b')]);}return _0x1a3d3d[_0x0eac('0x4e')](_0x33fcb0);}})[_0x0eac('0x23')](function(_0x5e6c48){if(_0x5e6c48){return _0x5e6c48?{'count':_0x49b2da,'rows':_0x5e6c48}:null;}})[_0x0eac('0x23')](respondWithResult(_0xdff4bc,null))[_0x0eac('0x45')](handleError(_0xdff4bc,null));};exports[_0x0eac('0x50')]=function(_0x254809,_0x59c1f1,_0xa53ede){if(_0x254809['body']['id']){delete _0x254809[_0x0eac('0x44')]['id'];}return db[_0x0eac('0x3c')]['findOne']({'where':{'id':_0x254809[_0x0eac('0x40')]['id']}})[_0x0eac('0x23')](handleEntityNotFound(_0x59c1f1,null))[_0x0eac('0x23')](function(_0x82ae49){if(_0x82ae49){return _0x82ae49[_0x0eac('0x50')](_0x254809['body'][_0x0eac('0x51')]||[]);}return null;})[_0x0eac('0x23')](respondWithResult(_0x59c1f1,null))['catch'](handleError(_0x59c1f1,null));};