YiAi/YiAiQuickDeploy/dist/modules/midjourney/midjourney.service.js
2024-02-06 13:43:30 +08:00

1 line
24 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';function _0x3a63(_0x3691f4,_0x19ff0c){const _0x70f366=_0x70f3();return _0x3a63=function(_0x3a6304,_0x20362f){_0x3a6304=_0x3a6304-0x143;let _0x201f86=_0x70f366[_0x3a6304];return _0x201f86;},_0x3a63(_0x3691f4,_0x19ff0c);}const _0x3ecbfc=_0x3a63;(function(_0x489787,_0x11b27f){const _0x38c02a=_0x3a63,_0x6a5460=_0x489787();while(!![]){try{const _0x6074cf=-parseInt(_0x38c02a(0x1e6))/0x1*(parseInt(_0x38c02a(0x144))/0x2)+-parseInt(_0x38c02a(0x155))/0x3*(parseInt(_0x38c02a(0x1eb))/0x4)+-parseInt(_0x38c02a(0x151))/0x5*(parseInt(_0x38c02a(0x146))/0x6)+-parseInt(_0x38c02a(0x181))/0x7+parseInt(_0x38c02a(0x1e3))/0x8*(parseInt(_0x38c02a(0x189))/0x9)+-parseInt(_0x38c02a(0x1cd))/0xa*(parseInt(_0x38c02a(0x17d))/0xb)+parseInt(_0x38c02a(0x15c))/0xc;if(_0x6074cf===_0x11b27f)break;else _0x6a5460['push'](_0x6a5460['shift']());}catch(_0x470a5b){_0x6a5460['push'](_0x6a5460['shift']());}}}(_0x70f3,0xa5199));function _0x70f3(){const _0x2904e5=['default','test','formatCreateOrUpdateDate','removeEmoji','MidjourneyEntity','width','更新绘画数据失败','DRAWING','image-size','@nestjs/common','arraybuffer','DRAWFAIL','../../common/constants/midjourney.constant','assign','save','replace','未能获取结果数据','stringify','./../user/user.entity','status','60874DwaUzo','delPrompt','decorate','删除成功!','879725JpiKTv','checkLimit','RedisCacheService','post','delete','updateDrawStatus','midjourneyEntity','uploadFileFromUrl','19476rqxlVY','Logger','length','addDrawQueue','pollComparisonResultDraw','map','删除记录失败!','axios','积分。','update','mjNotSaveImg','__esModule','------>\x20开始上传图片','bindJobId','Zoom\x20Out\x202x','REGENERATE','IMAGINE','UPSCALE','startsWith','find','getDrawList','SUCCESS','fullPrompt','findAndCount','Repository','存储图片失败,使用原始图片链接','error','imageUrl','HttpStatus','updateDrawData','orderId','非法操作!','user','drawId','function','set','drawUrl','@nestjs/typeorm','mjPromptsEntity','draw','recDraw','now','getList','role','from','Error\x20fetching\x20image\x20size:','所需绘画操作信息不存在!','getImageSizeFromUrl','操作成功!','queryPrompt','design:paramtypes','绘画完成,执行扣费,扣除费用:','error:\x20','filter','getDrawActionDetail','UserEntity','avatar','drawRatio','height','.png','获取图片结果失败:\x20','轮询失败次数过多,请稍后再试!','../upload/upload.service','debug','prompt','BAD_REQUEST','绘制成功,\x20URL:\x20','当前图片不存在!','1070HMrFmV','getConfigs','userBalanceService','删除记录成功!','username','globalConfigService','sendDrawCommand','application/x-www-form-urlencoded','UserBalanceService','base64','Zoom\x20Out\x201.5x','drawFailed','findOne','label','DESC','HttpException','metadata','userId','发送绘图指令失败、请联系管理员检测绘画配置!','mjPromptEntity','typeorm','toString','2920yivVVo','./midjourney.entity','绘制中的图片任务、禁止删除!','2RBHotH','MJ::JOB::reroll::0::','获取我得绘制列表失败','redisCacheService','rec','1323468szgdbQ','userInfo','refundMjBalance','/mj/submit/action','MidjourneyService','userEntity','isDelete','mjKey','InjectRepository','mjProxyUrl','绘画ID:\x20','/fetch','541622Sylouf','log','49902VmpahU','midjourney:getList','TODO->error:\x20','data','drawSuccess','email','../redisCache/redisCache.service','object','个任务','action','binary','790DqaYwB','Injectable','buttons','/mj/task/','9KmhgMZ','GlobalConfigService','__metadata','ZOOM','lockPrompt','getFullPrompt','process','41430132QSfTSw','affected','../../common/utils','parse','get','count','轮询过程中发生错误:\x20','../globalConfig/globalConfig.service','createdAt','MidjourneyStatusEnum','cleanQueue','WAITING','defineProperty'];_0x70f3=function(){return _0x2904e5;};return _0x70f3();}var __decorate=this&&this['__decorate']||function(_0x3e3a14,_0x2be88e,_0x3bc6db,_0x4ffbaa){const _0x15a4cc=_0x3a63;var _0x10c352=arguments[_0x15a4cc(0x18b)],_0x13e818=_0x10c352<0x3?_0x2be88e:_0x4ffbaa===null?_0x4ffbaa=Object['getOwnPropertyDescriptor'](_0x2be88e,_0x3bc6db):_0x4ffbaa,_0x9971c5;if(typeof Reflect===_0x15a4cc(0x14d)&&typeof Reflect[_0x15a4cc(0x17f)]===_0x15a4cc(0x1ab))_0x13e818=Reflect[_0x15a4cc(0x17f)](_0x3e3a14,_0x2be88e,_0x3bc6db,_0x4ffbaa);else{for(var _0x87e20f=_0x3e3a14[_0x15a4cc(0x18b)]-0x1;_0x87e20f>=0x0;_0x87e20f--)if(_0x9971c5=_0x3e3a14[_0x87e20f])_0x13e818=(_0x10c352<0x3?_0x9971c5(_0x13e818):_0x10c352>0x3?_0x9971c5(_0x2be88e,_0x3bc6db,_0x13e818):_0x9971c5(_0x2be88e,_0x3bc6db))||_0x13e818;}return _0x10c352>0x3&&_0x13e818&&Object['defineProperty'](_0x2be88e,_0x3bc6db,_0x13e818),_0x13e818;},__metadata=this&&this[_0x3ecbfc(0x157)]||function(_0x143fd2,_0x12b8d8){const _0x2a9ae2=_0x3ecbfc;if(typeof Reflect===_0x2a9ae2(0x14d)&&typeof Reflect[_0x2a9ae2(0x1dd)]===_0x2a9ae2(0x1ab))return Reflect[_0x2a9ae2(0x1dd)](_0x143fd2,_0x12b8d8);},__param=this&&this['__param']||function(_0xbdf8b9,_0x2a6f18){return function(_0x5f23bc,_0x4dd879){_0x2a6f18(_0x5f23bc,_0x4dd879,_0xbdf8b9);};};Object[_0x3ecbfc(0x168)](exports,_0x3ecbfc(0x194),{'value':!![]}),exports['MidjourneyService']=void 0x0;const user_entity_1=require(_0x3ecbfc(0x17b)),common_1=require(_0x3ecbfc(0x172)),typeorm_1=require(_0x3ecbfc(0x1ae)),midjourney_entity_1=require(_0x3ecbfc(0x1e4)),typeorm_2=require(_0x3ecbfc(0x1e1)),axios_1=require(_0x3ecbfc(0x190)),globalConfig_service_1=require(_0x3ecbfc(0x163)),midjourney_constant_1=require(_0x3ecbfc(0x175)),upload_service_1=require(_0x3ecbfc(0x1c7)),userBalance_service_1=require('../userBalance/userBalance.service'),utils_1=require(_0x3ecbfc(0x15e)),redisCache_service_1=require(_0x3ecbfc(0x14c)),prompt_entity_1=require('./prompt.entity'),image_size_1=require(_0x3ecbfc(0x171));let MidjourneyService=class MidjourneyService{constructor(_0x24beac,_0x1d1098,_0x3d9087,_0x1498ca,_0x3a8c29,_0xc52f74,_0x303ce4){const _0x16a06d=_0x3ecbfc;this[_0x16a06d(0x187)]=_0x24beac,this[_0x16a06d(0x1f0)]=_0x1d1098,this[_0x16a06d(0x1af)]=_0x3d9087,this['globalConfigService']=_0x1498ca,this['uploadService']=_0x3a8c29,this[_0x16a06d(0x1cf)]=_0xc52f74,this['redisCacheService']=_0x303ce4,this[_0x16a06d(0x159)]=[];}async['sleep'](_0x3793f7){return new Promise(_0x13fc29=>setTimeout(_0x13fc29,_0x3793f7));}async[_0x3ecbfc(0x1b8)](_0x537b99){const _0x1b362f=_0x3ecbfc;try{const _0x13d3d9=await axios_1[_0x1b362f(0x169)][_0x1b362f(0x160)](_0x537b99,{'responseType':_0x1b362f(0x173)}),_0x48d788=Buffer[_0x1b362f(0x1b5)](_0x13d3d9[_0x1b362f(0x149)],_0x1b362f(0x150)),_0x4e8e7c=(0x0,image_size_1['default'])(_0x48d788);return{'width':_0x4e8e7c[_0x1b362f(0x16e)],'height':_0x4e8e7c[_0x1b362f(0x1c3)]};}catch(_0x258a37){console[_0x1b362f(0x1a3)](_0x1b362f(0x1b6),_0x258a37);throw _0x258a37;}}async[_0x3ecbfc(0x1b0)](_0xf2abe7,_0x4b962e){const _0x12e290=_0x3ecbfc,{id:_0x1dbb6b,action:_0x45a39c,drawId:_0xa7bc9c}=_0xf2abe7,_0xd261de=await this['midjourneyEntity']['findOne']({'where':{'id':_0x1dbb6b}}),{customId:_0x8013c1}=_0xd261de;try{await this[_0x12e290(0x196)](_0x1dbb6b,_0x4b962e),await this[_0x12e290(0x186)](_0x1dbb6b,midjourney_constant_1[_0x12e290(0x165)][_0x12e290(0x170)]);const _0x4eedd6=await this[_0x12e290(0x1d3)](_0xd261de,_0x45a39c);_0xd261de[_0x12e290(0x1aa)]=_0x4eedd6;const _0x2b3157=await this[_0x12e290(0x18d)](_0x1dbb6b,_0xd261de);return await this[_0x12e290(0x1a6)](_0xf2abe7,_0x2b3157),this['drawSuccess'](_0xf2abe7),!![];}catch(_0x196e51){return console[_0x12e290(0x145)](_0x12e290(0x1bd),_0x196e51),!![];}}async[_0x3ecbfc(0x18c)](_0x229512){const _0x497936=_0x3ecbfc;try{const {prompt:_0xfc153d,imgUrl:imgUrl='',extraParam:extraParam='',action:_0x31bf81,userId:_0x258341,orderId:_0x248e9f,customId:_0x192621,drawId:_0x1947c3}=_0x229512,_0x1ba72c=imgUrl?imgUrl+'\x20'+_0xfc153d+'\x20'+extraParam:_0xfc153d+'\x20'+extraParam,_0xe04e57={'userId':_0x258341,'drawId':_0x1947c3,'extraParam':extraParam,'prompt':_0xfc153d,'imgUrl':imgUrl,'fullPrompt':_0x1ba72c,'status':midjourney_constant_1[_0x497936(0x165)][_0x497936(0x167)],'action':_0x31bf81,'orderId':_0x248e9f,'customId':_0x192621},_0x1c4a55=await this[_0x497936(0x187)][_0x497936(0x177)](_0xe04e57);return _0x1c4a55;}catch(_0x4f4ca4){console[_0x497936(0x1a3)]('Error\x20in\x20addDrawQueue:',_0x4f4ca4);throw _0x4f4ca4;}}async[_0x3ecbfc(0x186)](_0x1ee9a9,_0x5223e2){const _0x1db825=_0x3ecbfc;await this[_0x1db825(0x187)][_0x1db825(0x192)]({'id':_0x1ee9a9},{'status':_0x5223e2});}async['updateDrawData'](_0x4840c3,_0x38085d){const _0x4c66cc=_0x3ecbfc;try{const {id:_0x58e0d0,imageUrl:_0x113336,action:_0x2b5791,submitTime:_0xcfad94,finishTime:_0x447edc,progress:_0x3c1155}=_0x38085d,_0x188ffc=_0x447edc-_0xcfad94;let _0x4c0fa7=Date[_0x4c66cc(0x1b2)]()+'-'+_0x58e0d0+_0x4c66cc(0x1c4);const _0x3a402b=await this[_0x4c66cc(0x1d2)][_0x4c66cc(0x1ce)]([_0x4c66cc(0x193)]);let _0x1d23cf='',_0x213b5d=!![];try{!Number(_0x3a402b)||Number(_0x3a402b)===0x0?(common_1[_0x4c66cc(0x18a)]['debug'](_0x4c66cc(0x195),'MidjourneyService'),_0x1d23cf=await this['uploadService'][_0x4c66cc(0x188)]({'filename':_0x4c0fa7,'url':_0x113336})):(_0x1d23cf=_0x113336,_0x213b5d=![],common_1[_0x4c66cc(0x18a)][_0x4c66cc(0x1c8)]('本次不存图片了',_0x4c66cc(0x1ef)));}catch(_0x482ff5){common_1['Logger'][_0x4c66cc(0x1a3)](_0x4c66cc(0x1a2),_0x4c66cc(0x1ef)),_0x1d23cf=_0x113336,_0x213b5d=![];}const {width:_0x1e3811,height:_0x1fbeec}=await this[_0x4c66cc(0x1b8)](_0x113336),_0x341f9a={'status':midjourney_constant_1['MidjourneyStatusEnum']['DRAWED'],'drawId':_0x58e0d0,'action':_0x2b5791,'drawUrl':_0x1d23cf,'drawRatio':_0x1e3811+'x'+_0x1fbeec,'progress':0x64,'extend':this[_0x4c66cc(0x16c)](JSON['stringify'](_0x38085d)),'durationSpent':_0x188ffc,'isSaveImg':_0x213b5d};await this[_0x4c66cc(0x187)][_0x4c66cc(0x192)]({'id':_0x4840c3['id']},_0x341f9a);}catch(_0x2404a9){throw new common_1[(_0x4c66cc(0x1dc))](_0x4c66cc(0x16f),common_1[_0x4c66cc(0x1a5)][_0x4c66cc(0x1ca)]);}}async[_0x3ecbfc(0x1d3)](_0x220e6c,_0x1185b0){const _0x436f9a=_0x3ecbfc,_0x1c76f9=await this['globalConfigService']['getConfigs']([_0x436f9a(0x1f4)]),_0x3142dd=await this['globalConfigService'][_0x436f9a(0x1ce)]([_0x436f9a(0x1f2)]),{id:_0x381ab4,fullPrompt:_0x5ae9ce,imgUrl:_0x23f736,drawId:_0x1c8cf9,customId:_0x583946}=_0x220e6c,_0x5a3c51=_0x23f736?_0x23f736+'\x20'+_0x5ae9ce:''+_0x5ae9ce;let _0x4cf2ed='',_0x1b43e5={};const _0x21a0dc=0x3;let _0x13105a=0x0;while(_0x13105a<_0x21a0dc){try{_0x1185b0===_0x436f9a(0x199)?(_0x4cf2ed=_0x1c76f9+'/mj/submit/imagine',_0x1b43e5={'prompt':_0x5a3c51}):(_0x4cf2ed=_0x1c76f9+_0x436f9a(0x1ee),_0x1b43e5={'taskId':_0x1c8cf9,'customId':_0x583946});const _0x10dc86={'mj-api-secret':_0x3142dd},_0x637c9e=await axios_1['default'][_0x436f9a(0x184)](_0x4cf2ed,_0x1b43e5,{'headers':_0x10dc86}),{result:_0x114a07}=_0x637c9e[_0x436f9a(0x149)];if(_0x114a07)return common_1[_0x436f9a(0x18a)][_0x436f9a(0x145)](_0x436f9a(0x1f5)+_0x114a07,_0x436f9a(0x1ef)),_0x114a07;else throw new Error(_0x436f9a(0x179));}catch(_0x42f38b){_0x13105a++;if(_0x13105a>=_0x21a0dc){await this[_0x436f9a(0x186)](_0x381ab4,midjourney_constant_1[_0x436f9a(0x165)][_0x436f9a(0x174)]);throw new common_1[(_0x436f9a(0x1dc))](_0x436f9a(0x1df),common_1[_0x436f9a(0x1a5)][_0x436f9a(0x1ca)]);}}}}async[_0x3ecbfc(0x18d)](_0x14efd8,_0x518116){const _0x17f709=_0x3ecbfc,_0xbd0716=await this[_0x17f709(0x1d2)]['getConfigs']([_0x17f709(0x1f4)]),_0x3d5274=await this[_0x17f709(0x1d2)][_0x17f709(0x1ce)](['mjKey']),_0x242281=Date['now'](),_0x53ea39=0x1388,_0x2c3b0a=0x249f0;let _0x363bb4=0x0,_0x35346a=0x0;const _0x110f98=0x5,{drawId:_0x26c08b}=_0x518116;try{while(Date[_0x17f709(0x1b2)]()-_0x242281<_0x2c3b0a&&_0x35346a<_0x110f98){await new Promise(_0x8f104a=>setTimeout(_0x8f104a,_0x53ea39));try{const _0x14e4b6={'Content-Type':_0x17f709(0x1d4),'mj-api-secret':_0x3d5274},_0x5f46ef=_0xbd0716+_0x17f709(0x154)+_0x26c08b+_0x17f709(0x143),_0x1c20b1=await axios_1['default'][_0x17f709(0x160)](_0x5f46ef,{'headers':_0x14e4b6}),_0x5946c6=_0x1c20b1[_0x17f709(0x149)],_0x5dbda8=_0x5946c6[_0x17f709(0x15b)];await this['midjourneyEntity'][_0x17f709(0x192)]({'id':_0x14efd8},{'progress':_0x5dbda8});if(_0x5946c6[_0x17f709(0x17c)]===_0x17f709(0x19e))return common_1[_0x17f709(0x18a)][_0x17f709(0x145)](_0x17f709(0x1cb)+_0x5946c6[_0x17f709(0x1a4)],_0x17f709(0x1ef)),_0x5946c6;}catch(_0x1462a9){_0x35346a++,common_1[_0x17f709(0x18a)][_0x17f709(0x1a3)](_0x17f709(0x162)+_0x1462a9,_0x17f709(0x1ef));}_0x363bb4++;}if(_0x35346a>=_0x110f98){await this[_0x17f709(0x186)](_0x14efd8,midjourney_constant_1[_0x17f709(0x165)][_0x17f709(0x174)]);throw new common_1[(_0x17f709(0x1dc))](_0x17f709(0x1c6),common_1[_0x17f709(0x1a5)][_0x17f709(0x1ca)]);}common_1[_0x17f709(0x18a)][_0x17f709(0x1a3)]('绘画超时,请稍后再试!',_0x17f709(0x1ef)),await this[_0x17f709(0x186)](_0x14efd8,midjourney_constant_1[_0x17f709(0x165)]['DRAWFAIL']);throw new common_1['HttpException']('绘画超时,请稍后再试!',common_1[_0x17f709(0x1a5)]['BAD_REQUEST']);}catch(_0x1cf020){common_1[_0x17f709(0x18a)]['error'](_0x17f709(0x1c5),_0x1cf020,_0x17f709(0x1ef)),await this['updateDrawStatus'](_0x14efd8,midjourney_constant_1['MidjourneyStatusEnum'][_0x17f709(0x174)]);throw _0x1cf020;}}['removeEmoji'](_0x3ac69b){const _0x1a8034=_0x3ecbfc,_0x4d528a=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return _0x3ac69b[_0x1a8034(0x178)](_0x4d528a,'');}async[_0x3ecbfc(0x196)](_0x27ca4a,_0xd1fb78){const _0x5acc00=_0x3ecbfc;await this[_0x5acc00(0x187)][_0x5acc00(0x192)]({'id':_0x27ca4a},{'jobId':_0xd1fb78});}async[_0x3ecbfc(0x19d)](_0x5b326f,_0x3a32cf){const _0x23a35b=_0x3ecbfc;try{const {page:page=0x1,size:size=0x1e}=_0x3a32cf,[_0x1dd873,_0x443ffb]=await this[_0x23a35b(0x187)][_0x23a35b(0x1a0)]({'where':{'userId':_0x5b326f[_0x23a35b(0x1a9)]['id'],'isDelete':0x0},'order':{'id':'DESC'},'take':size,'skip':(page-0x1)*size,'select':['id',_0x23a35b(0x1de),_0x23a35b(0x1c9),'extraParam','fullPrompt',_0x23a35b(0x1ea),_0x23a35b(0x1a7),_0x23a35b(0x1aa),_0x23a35b(0x1ad),'drawRatio',_0x23a35b(0x1f1),'status','action']}),_0x623739=await this['midjourneyEntity'][_0x23a35b(0x161)]({'where':{'isDelete':0x0,'status':(0x0,typeorm_2['In'])([0x1,0x2])}}),_0x5e6e8b={'rows':(0x0,utils_1[_0x23a35b(0x16b)])(_0x1dd873),'count':_0x443ffb,'countQueue':_0x623739};return _0x5e6e8b;}catch(_0x4b71df){throw new common_1['HttpException'](_0x23a35b(0x1e8),common_1['HttpStatus']['BAD_REQUEST']);}}async[_0x3ecbfc(0x1bf)](_0x8a1b08,_0x4f2d33,_0x173e43){const _0xf9db4d=_0x3ecbfc,_0xca8097=await this['midjourneyEntity']['findOne']({'where':{'drawId':_0x4f2d33}}),{extend:_0x2d182d,prompt:_0xb49a87,imgUrl:_0x4e675c,extraParam:_0x4960a2}=_0xca8097,_0x5db61f=JSON[_0xf9db4d(0x15f)](_0x2d182d),_0x202f36=_0x5db61f[_0xf9db4d(0x153)]||[];let _0x14a710;_0x8a1b08===_0xf9db4d(0x19a)&&(_0x14a710=_0x202f36[_0xf9db4d(0x19c)](_0x9aa2c=>{const _0xd1bc29=_0xf9db4d,_0x31c655=_0x9aa2c[_0xd1bc29(0x1da)][_0xd1bc29(0x19b)]('U'+_0x173e43),_0x3c2c53=_0x173e43===0x1&&/(Redo )?Upscale \(Subtle\)/[_0xd1bc29(0x16a)](_0x9aa2c['label'])||_0x173e43===0x2&&/(Redo )?Upscale \(Creative\)/[_0xd1bc29(0x16a)](_0x9aa2c[_0xd1bc29(0x1da)]);return _0x31c655||_0x3c2c53;}));_0x8a1b08==='VARIATION'&&(_0x14a710=_0x202f36[_0xf9db4d(0x19c)](_0x53ebbb=>{const _0x46bf42=_0xf9db4d,_0x143efb=_0x53ebbb[_0x46bf42(0x1da)][_0x46bf42(0x19b)]('V'+_0x173e43),_0x4b2168=_0x173e43===0x1&&/Vary \(Strong\)/[_0x46bf42(0x16a)](_0x53ebbb['label'])||_0x173e43===0x2&&/Vary \(Region\)/[_0x46bf42(0x16a)](_0x53ebbb['label']);return _0x143efb||_0x4b2168;}));_0x8a1b08===_0xf9db4d(0x198)&&(_0x14a710=_0x202f36[_0xf9db4d(0x19c)](_0x227c4b=>_0x227c4b['customId'][_0xf9db4d(0x19b)](_0xf9db4d(0x1e7))&&_0x227c4b[_0xf9db4d(0x1da)]===''));_0x8a1b08===_0xf9db4d(0x158)&&(_0x14a710=_0x202f36[_0xf9db4d(0x19c)](_0x23dcc6=>_0x173e43===0x1&&_0x23dcc6[_0xf9db4d(0x1da)]===_0xf9db4d(0x197)||_0x173e43===0x2&&_0x23dcc6['label']===_0xf9db4d(0x1d7)));if(!_0x14a710)throw new common_1[(_0xf9db4d(0x1dc))](_0xf9db4d(0x1b7),common_1[_0xf9db4d(0x1a5)][_0xf9db4d(0x1ca)]);const {customId:_0x3a04e2}=_0x14a710;return{'customId':_0x3a04e2,'prompt':_0xb49a87,'extraParam':_0x4960a2,'drawId':_0x4f2d33};}async['deleteDraw'](_0xcaccb5,_0x1f2e0c){const _0x47f808=_0x3ecbfc,_0x5aac55=await this['midjourneyEntity'][_0x47f808(0x1d9)]({'where':{'id':_0xcaccb5,'userId':_0x1f2e0c[_0x47f808(0x1a9)]['id'],'isDelete':0x0}});if(!_0x5aac55)throw new common_1[(_0x47f808(0x1dc))]('当前图片不存在!',common_1[_0x47f808(0x1a5)][_0x47f808(0x1ca)]);if(_0x5aac55[_0x47f808(0x17c)]===0x2)throw new common_1[(_0x47f808(0x1dc))](_0x47f808(0x1e5),common_1['HttpStatus'][_0x47f808(0x1ca)]);const _0x27f371=await this[_0x47f808(0x187)]['update']({'id':_0xcaccb5},{'isDelete':0x1});if(_0x27f371[_0x47f808(0x15d)]>0x0)return _0x47f808(0x180);else throw new common_1[(_0x47f808(0x1dc))]('删除失败!',common_1[_0x47f808(0x1a5)]['BAD_REQUEST']);}async[_0x3ecbfc(0x182)](_0x38dc63){const _0x99c3a8=_0x3ecbfc,{role:_0x1d6f02,id:_0x4b818f}=_0x38dc63[_0x99c3a8(0x1a9)],_0x3b974b=await this[_0x99c3a8(0x187)][_0x99c3a8(0x161)]({'where':{'userId':_0x4b818f,'isDelete':0x0,'status':(0x0,typeorm_2['In'])([0x1,0x2])}}),_0x2f8746=await this[_0x99c3a8(0x1d2)][_0x99c3a8(0x1ce)](['mjLimitCount']),_0x5ed9f4=_0x2f8746?Number(_0x2f8746):0x2;if(_0x3b974b>=_0x5ed9f4)throw new common_1['HttpException']('当前管理员限制单用户同时最多能执行'+_0x5ed9f4+_0x99c3a8(0x14e),common_1[_0x99c3a8(0x1a5)][_0x99c3a8(0x1ca)]);}async[_0x3ecbfc(0x1d8)](_0x16bdf3){const _0x153900=_0x3ecbfc,{id:_0x2ac87d,userId:_0x2ec113,action:_0x26aca9}=_0x16bdf3;await this[_0x153900(0x187)]['update']({'id':_0x2ac87d},{'status':0x4});}async[_0x3ecbfc(0x14a)](_0x2c4105){const _0x3dc779=_0x3ecbfc,{id:_0x4f3dd5,userId:_0x39b6c0,action:_0x2b1c7d}=_0x2c4105,_0x440a22=_0x2b1c7d===_0x3dc779(0x19a)?0x1:0x4;common_1[_0x3dc779(0x18a)][_0x3dc779(0x1c8)](_0x3dc779(0x1bc)+_0x440a22+_0x3dc779(0x191)),await this[_0x3dc779(0x1cf)][_0x3dc779(0x1ed)](_0x39b6c0,-_0x440a22),await this[_0x3dc779(0x187)][_0x3dc779(0x192)]({'id':_0x4f3dd5},{'status':0x3});}async[_0x3ecbfc(0x1b3)](_0x7cfd95){const _0x3fcb73=_0x3ecbfc,{page:page=0x1,size:size=0x14,rec:_0x161985,userId:_0x41cc76,status:_0x3a811b}=_0x7cfd95;if(Number(size)===0x3e7){const _0x237a6d=await this[_0x3fcb73(0x1e9)]['get']({'key':_0x3fcb73(0x147)});if(_0x237a6d)try{return JSON['parse'](_0x237a6d);}catch(_0x8e4c77){return[];}}const _0x37a8ca={'isDelete':0x0};_0x161985&&Object['assign'](_0x37a8ca,{'rec':_0x161985}),_0x41cc76&&Object[_0x3fcb73(0x176)](_0x37a8ca,{'userId':_0x41cc76}),_0x3a811b&&Object[_0x3fcb73(0x176)](_0x37a8ca,{'status':_0x3a811b});const [_0x868674,_0x45fd9f]=await this[_0x3fcb73(0x187)][_0x3fcb73(0x1a0)]({'where':_0x37a8ca,'order':{'id':'DESC'},'take':size,'skip':(page-0x1)*size,'select':['id',_0x3fcb73(0x1aa),'drawUrl',_0x3fcb73(0x1c2),_0x3fcb73(0x1c9),_0x3fcb73(0x19f),'rec',_0x3fcb73(0x164),_0x3fcb73(0x14f),_0x3fcb73(0x17c)]});if(Number(size)===0x3e7){const _0x29d9f2={'rows':_0x868674[_0x3fcb73(0x18e)](_0x176df8=>{const {id:_0x39ba96,drawId:_0x351cbd,drawUrl:_0x39492e,drawRatio:_0x428df7,prompt:_0x35cfb5,fullPrompt:_0x11bce2,createdAt:_0x2f1387,rec:_0x336fb3,action:_0xda7a38,status:_0x1f9e4a}=_0x176df8;return{'id':_0x39ba96,'drawId':_0x351cbd,'drawUrl':_0x39492e,'drawRatio':_0x428df7,'prompt':_0x35cfb5,'fullPrompt':_0x11bce2,'createdAt':_0x2f1387,'rec':_0x336fb3,'action':_0xda7a38,'status':_0x1f9e4a};}),'count':_0x45fd9f};return await this[_0x3fcb73(0x1e9)][_0x3fcb73(0x1ac)]({'key':_0x3fcb73(0x147),'val':JSON[_0x3fcb73(0x17a)](_0x29d9f2)},0x3c*0x5),_0x29d9f2;}const _0x5611bb={'rows':_0x868674,'count':_0x45fd9f};return _0x5611bb;}async[_0x3ecbfc(0x15a)](_0x20acb9){const _0x3f7b53=_0x3ecbfc,_0x2f0f5d=await this[_0x3f7b53(0x187)][_0x3f7b53(0x1d9)]({'where':{'id':_0x20acb9}});if(!_0x2f0f5d)return'';const {fullPrompt:_0x474edc}=_0x2f0f5d;return _0x474edc;}async['getAdminDrawList'](_0x371003,_0x1451f2){const _0x4c7741=_0x3ecbfc;try{const {page:page=0x1,size:size=0xa,rec:_0x1a3188,userId:_0x273a70,status:_0x2f4ad9}=_0x1451f2,_0x1adf99={'isDelete':0x0};_0x1a3188&&Object[_0x4c7741(0x176)](_0x1adf99,{'rec':_0x1a3188}),_0x273a70&&Object[_0x4c7741(0x176)](_0x1adf99,{'userId':_0x273a70}),_0x2f4ad9&&Object[_0x4c7741(0x176)](_0x1adf99,{'status':_0x2f4ad9});const [_0x6af711,_0x5b37e2]=await this[_0x4c7741(0x187)][_0x4c7741(0x1a0)]({'where':_0x1adf99,'order':{'id':'DESC'},'take':size,'skip':(page-0x1)*size}),_0x3b2242=_0x6af711[_0x4c7741(0x18e)](_0x1eb324=>_0x1eb324[_0x4c7741(0x1de)])[_0x4c7741(0x1be)](_0x181f8a=>_0x181f8a<0x186a0),_0x1bc95b=await this[_0x4c7741(0x1f0)][_0x4c7741(0x19c)]({'where':{'id':(0x0,typeorm_2['In'])(_0x3b2242)},'select':['id',_0x4c7741(0x1d1),_0x4c7741(0x1c1),_0x4c7741(0x14b)]});return _0x6af711['forEach'](_0x337fd4=>{const _0x38f78e=_0x4c7741;_0x337fd4[_0x38f78e(0x1ec)]=_0x1bc95b[_0x38f78e(0x19c)](_0x2d0534=>_0x2d0534['id']===_0x337fd4[_0x38f78e(0x1de)]);}),_0x371003[_0x4c7741(0x1a9)][_0x4c7741(0x1b4)]!=='super'&&_0x6af711['forEach'](_0x5d29b0=>{const _0x47e20e=_0x4c7741;_0x5d29b0[_0x47e20e(0x1ec)]&&_0x5d29b0[_0x47e20e(0x1ec)]['email']&&(_0x5d29b0[_0x47e20e(0x1ec)]['email']=_0x5d29b0[_0x47e20e(0x1ec)][_0x47e20e(0x14b)][_0x47e20e(0x178)](/(.{2}).+(.{2}@.+)/,'$1****$2'));}),{'rows':_0x6af711,'count':_0x5b37e2};}catch(_0x43841f){throw new common_1[(_0x4c7741(0x1dc))]('查询失败!',common_1['HttpStatus'][_0x4c7741(0x1ca)]);}}async[_0x3ecbfc(0x1b1)](_0x1afb95){const _0xde642e=_0x3ecbfc,{id:_0x40c9d0}=_0x1afb95,_0x56fd0a=await this[_0xde642e(0x187)]['findOne']({'where':{'id':_0x40c9d0,'status':0x3,'isDelete':0x0}});if(!_0x56fd0a)throw new common_1[(_0xde642e(0x1dc))](_0xde642e(0x1cc),common_1['HttpStatus'][_0xde642e(0x1ca)]);const {rec:_0x5a1838}=_0x56fd0a,_0x2d12d4=await this[_0xde642e(0x187)]['update']({'id':_0x40c9d0},{'rec':_0x5a1838===0x1?0x0:0x1});if(_0x2d12d4[_0xde642e(0x15d)]>0x0)return _0xde642e(0x1b9);}async[_0x3ecbfc(0x166)](){const _0x13b82b=_0x3ecbfc;try{await this[_0x13b82b(0x187)][_0x13b82b(0x192)]({'status':0x2},{'status':0x4});}catch(_0x367801){console[_0x13b82b(0x145)](_0x13b82b(0x148),_0x367801);}}async['delLog'](_0x6a1e78,_0x3d80fc){const _0x10e9b8=_0x3ecbfc,{id:_0x1e9b6a}=_0x3d80fc;if(!_0x1e9b6a)throw new common_1[(_0x10e9b8(0x1dc))](_0x10e9b8(0x1a8),common_1[_0x10e9b8(0x1a5)]['BAD_REQUEST']);const _0x123420=await this[_0x10e9b8(0x187)][_0x10e9b8(0x185)]({'id':_0x1e9b6a});if(_0x123420['affected']>0x0)return _0x10e9b8(0x1d0);else throw new common_1[(_0x10e9b8(0x1dc))](_0x10e9b8(0x18f),common_1[_0x10e9b8(0x1a5)][_0x10e9b8(0x1ca)]);}async['setPrompt'](_0x8dcfde,_0x550ad8){const _0x38c943=_0x3ecbfc;try{const {prompt:_0x440878,status:_0x49ec65,isCarryParams:_0x1f2813,title:_0x406e1c,order:_0x1112ba,id:_0x26ccc5,aspect:_0x2f84f5}=_0x550ad8;return _0x26ccc5?await this['mjPromptsEntity'][_0x38c943(0x192)]({'id':_0x26ccc5},{'prompt':_0x440878,'status':_0x49ec65,'isCarryParams':_0x1f2813,'order':_0x1112ba,'aspect':_0x2f84f5}):await this[_0x38c943(0x1af)][_0x38c943(0x177)]({'prompt':_0x440878,'status':_0x49ec65,'isCarryParams':_0x1f2813,'title':_0x406e1c,'order':_0x1112ba,'aspect':_0x2f84f5});}catch(_0x1dd7f5){console[_0x38c943(0x145)](_0x38c943(0x1bd),_0x1dd7f5);}}async[_0x3ecbfc(0x17e)](_0x11f23a,_0x3c91ed){const _0x43f665=_0x3ecbfc,{id:_0x41c7da}=_0x3c91ed;if(!_0x41c7da)throw new common_1[(_0x43f665(0x1dc))]('非法操作!',common_1['HttpStatus'][_0x43f665(0x1ca)]);return await this[_0x43f665(0x1af)][_0x43f665(0x185)]({'id':_0x41c7da});}async[_0x3ecbfc(0x1ba)](){const _0x427f4f=_0x3ecbfc;return await this[_0x427f4f(0x1af)]['find']({'order':{'order':_0x427f4f(0x1db)}});}async['proxyImg'](_0x5cd738){const _0x4d7068=_0x3ecbfc,{url:_0xb61d78}=_0x5cd738;if(!_0xb61d78)return;const _0x1bf4ea=await axios_1['default'][_0x4d7068(0x160)](_0xb61d78,{'responseType':_0x4d7068(0x173)}),_0x3436d8=Buffer[_0x4d7068(0x1b5)](_0x1bf4ea['data'])[_0x4d7068(0x1e2)](_0x4d7068(0x1d6));return _0x3436d8;}};MidjourneyService=__decorate([(0x0,common_1[_0x3ecbfc(0x152)])(),__param(0x0,(0x0,typeorm_1['InjectRepository'])(midjourney_entity_1[_0x3ecbfc(0x16d)])),__param(0x1,(0x0,typeorm_1[_0x3ecbfc(0x1f3)])(user_entity_1[_0x3ecbfc(0x1c0)])),__param(0x2,(0x0,typeorm_1['InjectRepository'])(prompt_entity_1[_0x3ecbfc(0x1e0)])),__metadata(_0x3ecbfc(0x1bb),[typeorm_2[_0x3ecbfc(0x1a1)],typeorm_2[_0x3ecbfc(0x1a1)],typeorm_2[_0x3ecbfc(0x1a1)],globalConfig_service_1[_0x3ecbfc(0x156)],upload_service_1['UploadService'],userBalance_service_1[_0x3ecbfc(0x1d5)],redisCache_service_1[_0x3ecbfc(0x183)]])],MidjourneyService),exports[_0x3ecbfc(0x1ef)]=MidjourneyService;