Built motion from commit (unavailable).|2.5.24
[motion2.git] / server / api / template / template.controller.js
index 2bd3ec9..fb65620 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9019=['error','stack','name','send','index','map','Template','rawAttributes','fieldName','key','model','query','keys','filters','attributes','intersection','fields','length','hasOwnProperty','nolimit','limit','order','sort','where','pick','filter','merge','type','options','includeAll','findAll','catch','include','find','create','body','Unable\x20to\x20retrieve\x20the\x20current\x20user','user','UserProfileSection','userProfileId','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','eml-format','rimraf','zip-dir','fast-json-patch','request-promise','bluebird','mustache','util','sox','to-csv','ejs','squel','crypto','jsforce','querystring','papaparse','ioredis','../../components/auth/service','../../components/parsers/qs','../../components/parsers/advancedSearch','../../config/license/hardware','../../config/logger','../../config/environment','../../mysqldb','sendStatus','end','status','json','count','offset','set','Content-Range','apply','update','then','destroy','get','Templates','UserProfileResource'];(function(_0x2255cc,_0x92c897){var _0x13d99a=function(_0x39885f){while(--_0x39885f){_0x2255cc['push'](_0x2255cc['shift']());}};_0x13d99a(++_0x92c897);}(_0x9019,0x16e));var _0x9901=function(_0x2ab365,_0xa3812e){_0x2ab365=_0x2ab365-0x0;var _0x49fef3=_0x9019[_0x2ab365];return _0x49fef3;};'use strict';var pdf=require('html-pdf');var emlformat=require(_0x9901('0x0'));var rimraf=require(_0x9901('0x1'));var zipdir=require(_0x9901('0x2'));var jsonpatch=require(_0x9901('0x3'));var rp=require(_0x9901('0x4'));var moment=require('moment');var BPromise=require(_0x9901('0x5'));var Mustache=require(_0x9901('0x6'));var util=require(_0x9901('0x7'));var path=require('path');var sox=require(_0x9901('0x8'));var csv=require(_0x9901('0x9'));var ejs=require(_0x9901('0xa'));var fs=require('fs');var _=require('lodash');var squel=require(_0x9901('0xb'));var crypto=require(_0x9901('0xc'));var jsforce=require(_0x9901('0xd'));var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0x9901('0xe'));var Papa=require(_0x9901('0xf'));var Redis=require(_0x9901('0x10'));var authService=require(_0x9901('0x11'));var qs=require(_0x9901('0x12'));var as=require(_0x9901('0x13'));var hardwareService=require(_0x9901('0x14'));var logger=require(_0x9901('0x15'))('api');var utils=require('../../config/utils');var config=require(_0x9901('0x16'));var db=require(_0x9901('0x17'))['db'];function respondWithStatusCode(_0x1a13cd,_0x2a44aa){_0x2a44aa=_0x2a44aa||0xcc;return function(_0x5e9cad){if(_0x5e9cad){return _0x1a13cd[_0x9901('0x18')](_0x2a44aa);}return _0x1a13cd['status'](_0x2a44aa)[_0x9901('0x19')]();};}function respondWithResult(_0x445d3d,_0x2ee927){_0x2ee927=_0x2ee927||0xc8;return function(_0x543020){if(_0x543020){return _0x445d3d[_0x9901('0x1a')](_0x2ee927)[_0x9901('0x1b')](_0x543020);}};}function respondWithFilteredResult(_0x38f84,_0x1ced01){return function(_0x31cca7){if(_0x31cca7){var _0xaeb3c7=_0x31cca7[_0x9901('0x1c')],_0x53c51d=_0x1ced01[_0x9901('0x1d')],_0x155e2b=_0x1ced01['offset']+_0x1ced01['limit'],_0x123ab9;if(_0x155e2b>=_0xaeb3c7){_0x155e2b=_0xaeb3c7;_0x123ab9=0xc8;}else{_0x123ab9=0xce;}_0x38f84[_0x9901('0x1a')](_0x123ab9);return _0x38f84[_0x9901('0x1e')](_0x9901('0x1f'),_0x53c51d+'-'+_0x155e2b+'/'+_0xaeb3c7)[_0x9901('0x1b')](_0x31cca7);}return null;};}function patchUpdates(_0x444b01){return function(_0x2093a2){try{jsonpatch[_0x9901('0x20')](_0x2093a2,_0x444b01,!![]);}catch(_0x46e485){return BPromise['reject'](_0x46e485);}return _0x2093a2['save']();};}function saveUpdates(_0x2b9ce1,_0x2b7a9f){return function(_0x282947){if(_0x282947){return _0x282947[_0x9901('0x21')](_0x2b9ce1)[_0x9901('0x22')](function(_0x68aea6){return _0x68aea6;});}return null;};}function removeEntity(_0x5135e1,_0x5a7919){return function(_0x279852){if(_0x279852){return _0x279852[_0x9901('0x23')]()[_0x9901('0x22')](function(){var _0x38f0bb=_0x279852[_0x9901('0x24')]({'plain':!![]});var _0x14b295=_0x9901('0x25');return db[_0x9901('0x26')]['destroy']({'where':{'type':_0x14b295,'resourceId':_0x38f0bb['id']}})[_0x9901('0x22')](function(){return _0x279852;});})[_0x9901('0x22')](function(){_0x5135e1[_0x9901('0x1a')](0xcc)[_0x9901('0x19')]();});}};}function handleEntityNotFound(_0x4e5650,_0x4699fc){return function(_0x126c97){if(!_0x126c97){_0x4e5650[_0x9901('0x18')](0x194);}return _0x126c97;};}function handleError(_0x12c2d1,_0x1880b9){_0x1880b9=_0x1880b9||0x1f4;return function(_0x5838e2){logger[_0x9901('0x27')](_0x5838e2[_0x9901('0x28')]);if(_0x5838e2['name']){delete _0x5838e2[_0x9901('0x29')];}_0x12c2d1[_0x9901('0x1a')](_0x1880b9)[_0x9901('0x2a')](_0x5838e2);};}exports[_0x9901('0x2b')]=function(_0x2d7ef0,_0x5b3d94){var _0x24d1c0={},_0x4959da={},_0x5cfe5e={'count':0x0,'rows':[]};var _0x47b1a2=_[_0x9901('0x2c')](db[_0x9901('0x2d')][_0x9901('0x2e')],function(_0x47d883){return{'name':_0x47d883[_0x9901('0x2f')],'type':_0x47d883['type'][_0x9901('0x30')]};});_0x4959da[_0x9901('0x31')]=_[_0x9901('0x2c')](_0x47b1a2,'name');_0x4959da[_0x9901('0x32')]=_[_0x9901('0x33')](_0x2d7ef0[_0x9901('0x32')]);_0x4959da[_0x9901('0x34')]=_['intersection'](_0x4959da[_0x9901('0x31')],_0x4959da[_0x9901('0x32')]);_0x24d1c0[_0x9901('0x35')]=_[_0x9901('0x36')](_0x4959da[_0x9901('0x31')],qs[_0x9901('0x37')](_0x2d7ef0[_0x9901('0x32')]['fields']));_0x24d1c0['attributes']=_0x24d1c0[_0x9901('0x35')][_0x9901('0x38')]?_0x24d1c0[_0x9901('0x35')]:_0x4959da['model'];if(!_0x2d7ef0[_0x9901('0x32')][_0x9901('0x39')](_0x9901('0x3a'))){_0x24d1c0[_0x9901('0x3b')]=qs['limit'](_0x2d7ef0[_0x9901('0x32')][_0x9901('0x3b')]);_0x24d1c0['offset']=qs[_0x9901('0x1d')](_0x2d7ef0[_0x9901('0x32')][_0x9901('0x1d')]);}_0x24d1c0[_0x9901('0x3c')]=qs[_0x9901('0x3d')](_0x2d7ef0[_0x9901('0x32')][_0x9901('0x3d')]);_0x24d1c0[_0x9901('0x3e')]=qs[_0x9901('0x34')](_[_0x9901('0x3f')](_0x2d7ef0[_0x9901('0x32')],_0x4959da[_0x9901('0x34')]));if(_0x2d7ef0[_0x9901('0x32')][_0x9901('0x40')]){_0x24d1c0[_0x9901('0x3e')]=_[_0x9901('0x41')](_0x24d1c0[_0x9901('0x3e')],{'$or':_[_0x9901('0x2c')](_0x47b1a2,function(_0x2aea62){if(_0x2aea62[_0x9901('0x42')]!=='VIRTUAL'){var _0x349ecc={};_0x349ecc[_0x2aea62[_0x9901('0x29')]]={'$like':'%'+_0x2d7ef0['query']['filter']+'%'};return _0x349ecc;}})});}_0x24d1c0=_[_0x9901('0x41')]({},_0x24d1c0,_0x2d7ef0[_0x9901('0x43')]);var _0x33cd2b={'where':_0x24d1c0[_0x9901('0x3e')]};return db[_0x9901('0x2d')][_0x9901('0x1c')](_0x33cd2b)[_0x9901('0x22')](function(_0x561638){_0x5cfe5e[_0x9901('0x1c')]=_0x561638;if(_0x2d7ef0['query'][_0x9901('0x44')]){_0x24d1c0['include']=[{'all':!![]}];}return db[_0x9901('0x2d')][_0x9901('0x45')](_0x24d1c0);})['then'](function(_0x2a799d){_0x5cfe5e['rows']=_0x2a799d;return _0x5cfe5e;})[_0x9901('0x22')](respondWithFilteredResult(_0x5b3d94,_0x24d1c0))[_0x9901('0x46')](handleError(_0x5b3d94,null));};exports['show']=function(_0x1a1f73,_0x44bd39){var _0x1606e4={'raw':!![],'where':{'id':_0x1a1f73['params']['id']}},_0x49a1e4={};_0x49a1e4[_0x9901('0x31')]=_['keys'](db[_0x9901('0x2d')][_0x9901('0x2e')]);_0x49a1e4[_0x9901('0x32')]=_[_0x9901('0x33')](_0x1a1f73['query']);_0x49a1e4['filters']=_[_0x9901('0x36')](_0x49a1e4[_0x9901('0x31')],_0x49a1e4['query']);_0x1606e4[_0x9901('0x35')]=_[_0x9901('0x36')](_0x49a1e4[_0x9901('0x31')],qs[_0x9901('0x37')](_0x1a1f73[_0x9901('0x32')][_0x9901('0x37')]));_0x1606e4['attributes']=_0x1606e4['attributes'][_0x9901('0x38')]?_0x1606e4['attributes']:_0x49a1e4[_0x9901('0x31')];if(_0x1a1f73[_0x9901('0x32')][_0x9901('0x44')]){_0x1606e4[_0x9901('0x47')]=[{'all':!![]}];}_0x1606e4=_[_0x9901('0x41')]({},_0x1606e4,_0x1a1f73[_0x9901('0x43')]);return db[_0x9901('0x2d')][_0x9901('0x48')](_0x1606e4)['then'](handleEntityNotFound(_0x44bd39,null))['then'](respondWithResult(_0x44bd39,null))[_0x9901('0x46')](handleError(_0x44bd39,null));};exports['create']=function(_0x12e6ed,_0x3b61e0){return db[_0x9901('0x2d')][_0x9901('0x49')](_0x12e6ed[_0x9901('0x4a')],{})['then'](function(_0x54ad50){var _0x107c32=_0x12e6ed['user'][_0x9901('0x24')]({'plain':!![]});if(!_0x107c32)throw new Error(_0x9901('0x4b'));if(_0x107c32['role']===_0x9901('0x4c')){var _0x4309ac=_0x54ad50[_0x9901('0x24')]({'plain':!![]});var _0x1036ad='Templates';return db[_0x9901('0x4d')][_0x9901('0x48')]({'where':{'name':_0x1036ad,'userProfileId':_0x107c32[_0x9901('0x4e')]},'raw':!![]})[_0x9901('0x22')](function(_0x326dc1){if(_0x326dc1&&_0x326dc1['autoAssociation']===0x0){return db[_0x9901('0x26')][_0x9901('0x49')]({'name':_0x4309ac[_0x9901('0x29')],'resourceId':_0x4309ac['id'],'type':_0x326dc1[_0x9901('0x29')],'sectionId':_0x326dc1['id']},{})['then'](function(){return _0x54ad50;});}else{return _0x54ad50;}})[_0x9901('0x46')](function(_0x1eac58){logger[_0x9901('0x27')](_0x9901('0x4f'),_0x1eac58);throw _0x1eac58;});}return _0x54ad50;})[_0x9901('0x22')](respondWithResult(_0x3b61e0,0xc9))[_0x9901('0x46')](handleError(_0x3b61e0,null));};exports['update']=function(_0x4dfd28,_0x4c934a){if(_0x4dfd28[_0x9901('0x4a')]['id']){delete _0x4dfd28['body']['id'];}return db[_0x9901('0x2d')]['find']({'where':{'id':_0x4dfd28[_0x9901('0x50')]['id']}})['then'](handleEntityNotFound(_0x4c934a,null))[_0x9901('0x22')](saveUpdates(_0x4dfd28['body'],null))[_0x9901('0x22')](respondWithResult(_0x4c934a,null))[_0x9901('0x46')](handleError(_0x4c934a,null));};exports[_0x9901('0x23')]=function(_0x16aacc,_0x23822e){return db[_0x9901('0x2d')][_0x9901('0x48')]({'where':{'id':_0x16aacc[_0x9901('0x50')]['id']}})['then'](handleEntityNotFound(_0x23822e,null))[_0x9901('0x22')](removeEntity(_0x23822e,null))[_0x9901('0x46')](handleError(_0x23822e,null));};
\ No newline at end of file
+var _0xe14b=['../../config/logger','../../config/utils','../../config/environment','../../config/license/util','../../mysqldb','sendStatus','status','end','count','offset','limit','Content-Range','json','apply','save','update','destroy','get','Templates','then','error','name','send','index','map','Template','rawAttributes','fieldName','type','key','model','query','keys','filters','intersection','attributes','hasOwnProperty','nolimit','order','sort','where','pick','merge','VIRTUAL','filter','options','include','findAll','catch','show','fields','length','includeAll','find','create','body','user','Unable\x20to\x20retrieve\x20the\x20current\x20user','role','UserProfileSection','userProfileId','autoAssociation','UserProfileResource','Unable\x20to\x20associate\x20the\x20resource\x20to\x20the\x20User\x20Profile:\x20%s','params','html-pdf','eml-format','fast-json-patch','request-promise','bluebird','path','sox','to-csv','ejs','lodash','squel','crypto','querystring','papaparse','ioredis','../../components/auth/service','../../config/license/hardware'];(function(_0x52ea87,_0x1e5a76){var _0x5f3ed0=function(_0x292868){while(--_0x292868){_0x52ea87['push'](_0x52ea87['shift']());}};_0x5f3ed0(++_0x1e5a76);}(_0xe14b,0x93));var _0xbe14=function(_0x14fea8,_0x5e1ed7){_0x14fea8=_0x14fea8-0x0;var _0x1bc204=_0xe14b[_0x14fea8];return _0x1bc204;};'use strict';var pdf=require(_0xbe14('0x0'));var emlformat=require(_0xbe14('0x1'));var rimraf=require('rimraf');var zipdir=require('zip-dir');var jsonpatch=require(_0xbe14('0x2'));var rp=require(_0xbe14('0x3'));var moment=require('moment');var BPromise=require(_0xbe14('0x4'));var Mustache=require('mustache');var util=require('util');var path=require(_0xbe14('0x5'));var sox=require(_0xbe14('0x6'));var csv=require(_0xbe14('0x7'));var ejs=require(_0xbe14('0x8'));var fs=require('fs');var _=require(_0xbe14('0x9'));var squel=require(_0xbe14('0xa'));var crypto=require(_0xbe14('0xb'));var jsforce=require('jsforce');var deskjs=require('desk.js');var toCsv=require('to-csv');var querystring=require(_0xbe14('0xc'));var Papa=require(_0xbe14('0xd'));var Redis=require(_0xbe14('0xe'));var authService=require(_0xbe14('0xf'));var qs=require('../../components/parsers/qs');var as=require('../../components/parsers/advancedSearch');var hardwareService=require(_0xbe14('0x10'));var logger=require(_0xbe14('0x11'))('api');var utils=require(_0xbe14('0x12'));var config=require(_0xbe14('0x13'));var licenseUtil=require(_0xbe14('0x14'));var db=require(_0xbe14('0x15'))['db'];function respondWithStatusCode(_0x27792f,_0x3b898d){_0x3b898d=_0x3b898d||0xcc;return function(_0x23a730){if(_0x23a730){return _0x27792f[_0xbe14('0x16')](_0x3b898d);}return _0x27792f[_0xbe14('0x17')](_0x3b898d)[_0xbe14('0x18')]();};}function respondWithResult(_0x1e4826,_0x33fd54){_0x33fd54=_0x33fd54||0xc8;return function(_0x813399){if(_0x813399){return _0x1e4826['status'](_0x33fd54)['json'](_0x813399);}};}function respondWithFilteredResult(_0x3f58f5,_0x3dc4a9){return function(_0xf4ac9){if(_0xf4ac9){var _0x37ce4e=_0xf4ac9[_0xbe14('0x19')],_0x4e8f34=_0x3dc4a9[_0xbe14('0x1a')],_0x21c789=_0x3dc4a9[_0xbe14('0x1a')]+_0x3dc4a9[_0xbe14('0x1b')],_0xe9c3ec;if(_0x21c789>=_0x37ce4e){_0x21c789=_0x37ce4e;_0xe9c3ec=0xc8;}else{_0xe9c3ec=0xce;}_0x3f58f5[_0xbe14('0x17')](_0xe9c3ec);return _0x3f58f5['set'](_0xbe14('0x1c'),_0x4e8f34+'-'+_0x21c789+'/'+_0x37ce4e)[_0xbe14('0x1d')](_0xf4ac9);}return null;};}function patchUpdates(_0x329588){return function(_0x433459){try{jsonpatch[_0xbe14('0x1e')](_0x433459,_0x329588,!![]);}catch(_0x37e4c1){return BPromise['reject'](_0x37e4c1);}return _0x433459[_0xbe14('0x1f')]();};}function saveUpdates(_0x4a1bbd,_0x417c8d){return function(_0xc12977){if(_0xc12977){return _0xc12977[_0xbe14('0x20')](_0x4a1bbd)['then'](function(_0xe60f42){return _0xe60f42;});}return null;};}function removeEntity(_0x56d845,_0x3c1c85){return function(_0x56e80c){if(_0x56e80c){return _0x56e80c[_0xbe14('0x21')]()['then'](function(){var _0x274018=_0x56e80c[_0xbe14('0x22')]({'plain':!![]});var _0x505dbd=_0xbe14('0x23');return db['UserProfileResource'][_0xbe14('0x21')]({'where':{'type':_0x505dbd,'resourceId':_0x274018['id']}})['then'](function(){return _0x56e80c;});})[_0xbe14('0x24')](function(){_0x56d845[_0xbe14('0x17')](0xcc)[_0xbe14('0x18')]();});}};}function handleEntityNotFound(_0x39cc81,_0x15ef02){return function(_0x2703f5){if(!_0x2703f5){_0x39cc81['sendStatus'](0x194);}return _0x2703f5;};}function handleError(_0x1822e0,_0x1ba46a){_0x1ba46a=_0x1ba46a||0x1f4;return function(_0x391556){logger[_0xbe14('0x25')](_0x391556['stack']);if(_0x391556[_0xbe14('0x26')]){delete _0x391556[_0xbe14('0x26')];}_0x1822e0['status'](_0x1ba46a)[_0xbe14('0x27')](_0x391556);};}exports[_0xbe14('0x28')]=function(_0x1c7cc7,_0x19252f){var _0x34d648={},_0x36d4b2={},_0x31a664={'count':0x0,'rows':[]};var _0x2b05cb=_[_0xbe14('0x29')](db[_0xbe14('0x2a')][_0xbe14('0x2b')],function(_0x3bf43c){return{'name':_0x3bf43c[_0xbe14('0x2c')],'type':_0x3bf43c[_0xbe14('0x2d')][_0xbe14('0x2e')]};});_0x36d4b2[_0xbe14('0x2f')]=_[_0xbe14('0x29')](_0x2b05cb,_0xbe14('0x26'));_0x36d4b2[_0xbe14('0x30')]=_[_0xbe14('0x31')](_0x1c7cc7['query']);_0x36d4b2[_0xbe14('0x32')]=_['intersection'](_0x36d4b2['model'],_0x36d4b2[_0xbe14('0x30')]);_0x34d648['attributes']=_[_0xbe14('0x33')](_0x36d4b2[_0xbe14('0x2f')],qs['fields'](_0x1c7cc7['query']['fields']));_0x34d648[_0xbe14('0x34')]=_0x34d648[_0xbe14('0x34')]['length']?_0x34d648[_0xbe14('0x34')]:_0x36d4b2[_0xbe14('0x2f')];if(!_0x1c7cc7[_0xbe14('0x30')][_0xbe14('0x35')](_0xbe14('0x36'))){_0x34d648['limit']=qs['limit'](_0x1c7cc7[_0xbe14('0x30')]['limit']);_0x34d648['offset']=qs['offset'](_0x1c7cc7[_0xbe14('0x30')][_0xbe14('0x1a')]);}_0x34d648[_0xbe14('0x37')]=qs[_0xbe14('0x38')](_0x1c7cc7[_0xbe14('0x30')][_0xbe14('0x38')]);_0x34d648[_0xbe14('0x39')]=qs[_0xbe14('0x32')](_[_0xbe14('0x3a')](_0x1c7cc7[_0xbe14('0x30')],_0x36d4b2[_0xbe14('0x32')]),_0x2b05cb);if(_0x1c7cc7[_0xbe14('0x30')]['filter']){_0x34d648['where']=_[_0xbe14('0x3b')](_0x34d648[_0xbe14('0x39')],{'$or':_[_0xbe14('0x29')](_0x2b05cb,function(_0x520e09){if(_0x520e09[_0xbe14('0x2d')]!==_0xbe14('0x3c')){var _0xeda70e={};_0xeda70e[_0x520e09[_0xbe14('0x26')]]={'$like':'%'+_0x1c7cc7[_0xbe14('0x30')][_0xbe14('0x3d')]+'%'};return _0xeda70e;}})});}_0x34d648=_[_0xbe14('0x3b')]({},_0x34d648,_0x1c7cc7[_0xbe14('0x3e')]);var _0x1b2608={'where':_0x34d648['where']};return db[_0xbe14('0x2a')][_0xbe14('0x19')](_0x1b2608)[_0xbe14('0x24')](function(_0x1b3118){_0x31a664[_0xbe14('0x19')]=_0x1b3118;if(_0x1c7cc7[_0xbe14('0x30')]['includeAll']){_0x34d648[_0xbe14('0x3f')]=[{'all':!![]}];}return db[_0xbe14('0x2a')][_0xbe14('0x40')](_0x34d648);})[_0xbe14('0x24')](function(_0x5cf713){_0x31a664['rows']=_0x5cf713;return _0x31a664;})[_0xbe14('0x24')](respondWithFilteredResult(_0x19252f,_0x34d648))[_0xbe14('0x41')](handleError(_0x19252f,null));};exports[_0xbe14('0x42')]=function(_0x51c859,_0x5d5318){var _0x6b6aa8={'raw':!![],'where':{'id':_0x51c859['params']['id']}},_0x59ae4d={};_0x59ae4d[_0xbe14('0x2f')]=_[_0xbe14('0x31')](db[_0xbe14('0x2a')]['rawAttributes']);_0x59ae4d['query']=_['keys'](_0x51c859[_0xbe14('0x30')]);_0x59ae4d[_0xbe14('0x32')]=_[_0xbe14('0x33')](_0x59ae4d['model'],_0x59ae4d[_0xbe14('0x30')]);_0x6b6aa8[_0xbe14('0x34')]=_[_0xbe14('0x33')](_0x59ae4d[_0xbe14('0x2f')],qs['fields'](_0x51c859['query'][_0xbe14('0x43')]));_0x6b6aa8[_0xbe14('0x34')]=_0x6b6aa8[_0xbe14('0x34')][_0xbe14('0x44')]?_0x6b6aa8[_0xbe14('0x34')]:_0x59ae4d['model'];if(_0x51c859['query'][_0xbe14('0x45')]){_0x6b6aa8[_0xbe14('0x3f')]=[{'all':!![]}];}_0x6b6aa8=_[_0xbe14('0x3b')]({},_0x6b6aa8,_0x51c859[_0xbe14('0x3e')]);return db['Template'][_0xbe14('0x46')](_0x6b6aa8)[_0xbe14('0x24')](handleEntityNotFound(_0x5d5318,null))['then'](respondWithResult(_0x5d5318,null))[_0xbe14('0x41')](handleError(_0x5d5318,null));};exports[_0xbe14('0x47')]=function(_0x2d6ee8,_0x36c20c){return db['Template']['create'](_0x2d6ee8[_0xbe14('0x48')],{})[_0xbe14('0x24')](function(_0x4a1a37){var _0x5acf90=_0x2d6ee8[_0xbe14('0x49')][_0xbe14('0x22')]({'plain':!![]});if(!_0x5acf90)throw new Error(_0xbe14('0x4a'));if(_0x5acf90[_0xbe14('0x4b')]===_0xbe14('0x49')){var _0xd04fd5=_0x4a1a37[_0xbe14('0x22')]({'plain':!![]});var _0x5a4068=_0xbe14('0x23');return db[_0xbe14('0x4c')][_0xbe14('0x46')]({'where':{'name':_0x5a4068,'userProfileId':_0x5acf90[_0xbe14('0x4d')]},'raw':!![]})[_0xbe14('0x24')](function(_0x494c32){if(_0x494c32&&_0x494c32[_0xbe14('0x4e')]===0x0){return db[_0xbe14('0x4f')][_0xbe14('0x47')]({'name':_0xd04fd5[_0xbe14('0x26')],'resourceId':_0xd04fd5['id'],'type':_0x494c32[_0xbe14('0x26')],'sectionId':_0x494c32['id']},{})[_0xbe14('0x24')](function(){return _0x4a1a37;});}else{return _0x4a1a37;}})['catch'](function(_0x5aeea9){logger[_0xbe14('0x25')](_0xbe14('0x50'),_0x5aeea9);throw _0x5aeea9;});}return _0x4a1a37;})[_0xbe14('0x24')](respondWithResult(_0x36c20c,0xc9))['catch'](handleError(_0x36c20c,null));};exports['update']=function(_0x44fe0d,_0x134878){if(_0x44fe0d['body']['id']){delete _0x44fe0d[_0xbe14('0x48')]['id'];}return db[_0xbe14('0x2a')]['find']({'where':{'id':_0x44fe0d[_0xbe14('0x51')]['id']}})['then'](handleEntityNotFound(_0x134878,null))[_0xbe14('0x24')](saveUpdates(_0x44fe0d[_0xbe14('0x48')],null))[_0xbe14('0x24')](respondWithResult(_0x134878,null))['catch'](handleError(_0x134878,null));};exports[_0xbe14('0x21')]=function(_0x404212,_0x5dc78a){return db[_0xbe14('0x2a')][_0xbe14('0x46')]({'where':{'id':_0x404212[_0xbe14('0x51')]['id']}})[_0xbe14('0x24')](handleEntityNotFound(_0x5dc78a,null))[_0xbe14('0x24')](removeEntity(_0x5dc78a,null))['catch'](handleError(_0x5dc78a,null));};
\ No newline at end of file