YiAi/YiAiQuickDeploy/dist/modules/midjourney/midjourney.service.js
2024-02-05 23:18:50 +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';const _0x3b2075=_0x2697;(function(_0x447caa,_0x765c8e){const _0x48ff96=_0x2697,_0x51e971=_0x447caa();while(!![]){try{const _0x2101b8=parseInt(_0x48ff96(0x1ab))/0x1+parseInt(_0x48ff96(0x19b))/0x2+parseInt(_0x48ff96(0x1b5))/0x3*(-parseInt(_0x48ff96(0x1d0))/0x4)+parseInt(_0x48ff96(0x1ce))/0x5*(-parseInt(_0x48ff96(0x141))/0x6)+parseInt(_0x48ff96(0x1ae))/0x7*(parseInt(_0x48ff96(0x1b9))/0x8)+-parseInt(_0x48ff96(0x14d))/0x9+-parseInt(_0x48ff96(0x167))/0xa*(-parseInt(_0x48ff96(0x1ad))/0xb);if(_0x2101b8===_0x765c8e)break;else _0x51e971['push'](_0x51e971['shift']());}catch(_0x16b40f){_0x51e971['push'](_0x51e971['shift']());}}}(_0x4a52,0x298fa));var __decorate=this&&this[_0x3b2075(0x16c)]||function(_0x435737,_0x2898f9,_0x32849b,_0x25d89d){const _0x4eb5e5=_0x3b2075;var _0x2dc33b=arguments[_0x4eb5e5(0x1c0)],_0x3ca601=_0x2dc33b<0x3?_0x2898f9:_0x25d89d===null?_0x25d89d=Object[_0x4eb5e5(0x191)](_0x2898f9,_0x32849b):_0x25d89d,_0x32d2a5;if(typeof Reflect===_0x4eb5e5(0x181)&&typeof Reflect[_0x4eb5e5(0x160)]===_0x4eb5e5(0x1ac))_0x3ca601=Reflect[_0x4eb5e5(0x160)](_0x435737,_0x2898f9,_0x32849b,_0x25d89d);else{for(var _0x4ba194=_0x435737[_0x4eb5e5(0x1c0)]-0x1;_0x4ba194>=0x0;_0x4ba194--)if(_0x32d2a5=_0x435737[_0x4ba194])_0x3ca601=(_0x2dc33b<0x3?_0x32d2a5(_0x3ca601):_0x2dc33b>0x3?_0x32d2a5(_0x2898f9,_0x32849b,_0x3ca601):_0x32d2a5(_0x2898f9,_0x32849b))||_0x3ca601;}return _0x2dc33b>0x3&&_0x3ca601&&Object[_0x4eb5e5(0x177)](_0x2898f9,_0x32849b,_0x3ca601),_0x3ca601;},__metadata=this&&this[_0x3b2075(0x173)]||function(_0x3f09df,_0x4bb217){const _0x9418be=_0x3b2075;if(typeof Reflect==='object'&&typeof Reflect[_0x9418be(0x1a2)]==='function')return Reflect[_0x9418be(0x1a2)](_0x3f09df,_0x4bb217);},__param=this&&this[_0x3b2075(0x1a1)]||function(_0x15d92c,_0x561c29){return function(_0x301cb7,_0x1620cf){_0x561c29(_0x301cb7,_0x1620cf,_0x15d92c);};};function _0x2697(_0x51fda2,_0x5bef4f){const _0x4a522c=_0x4a52();return _0x2697=function(_0x26977d,_0x386468){_0x26977d=_0x26977d-0x138;let _0x877a34=_0x4a522c[_0x26977d];return _0x877a34;},_0x2697(_0x51fda2,_0x5bef4f);}Object[_0x3b2075(0x177)](exports,_0x3b2075(0x149),{'value':!![]}),exports['MidjourneyService']=void 0x0;function _0x4a52(){const _0x627342=['查询失败!','__param','metadata','user','customId','fullPrompt','绘画完成,执行扣费,扣除费用:','update','userBalanceService','deleteDraw','midjourney:getList','251404OSdrXW','function','888767CWIxpW','1589rOsyKt','delete','default','HttpException','SUCCESS','当前管理员限制单用户同时最多能执行','label','934524pVhcgi','uploadFileFromUrl','MJ::JOB::reroll::0::','status','4264wXUrpJ','userEntity','log','queryPrompt','BAD_REQUEST','redisCacheService','lockPrompt','length','midjourneyEntity','所需绘画操作信息不存在!','affected','getAdminDrawList','updateDrawStatus','setPrompt','error:\x20','find','./../user/user.entity','extraParam','UserEntity','DRAWING','mjProxyUrl','550aVsaRn','height','4DeXBTe','IMAGINE','HttpStatus','now','轮询失败次数过多,请稍后再试!','Error\x20fetching\x20image\x20size:','Zoom\x20Out\x201.5x','action','delPrompt','cleanQueue','GlobalConfigService','getDrawActionDetail','DESC','typeorm','from','../../common/utils','Logger','buttons','data','parse','绘画ID:\x20','replace','mjLimitCount','绘画超时,请稍后再试!','/mj/task/','forEach','sleep','DRAWED','../userBalance/userBalance.service','removeEmoji','rec','../redisCache/redisCache.service','Error\x20in\x20addDrawQueue:','Zoom\x20Out\x202x','save','getConfigs','getDrawList','个任务','1176ixkZwJ','email','MidjourneyEntity','/mj/submit/imagine','error','toString','axios','RedisCacheService','__esModule','filter','formatCreateOrUpdateDate','bindJobId','1109394PIctfw','../globalConfig/globalConfig.service','../../common/constants/midjourney.constant','prompt','Repository','width','username','proxyImg','drawSuccess','updateDrawData','更新绘画数据失败','recDraw','绘制成功,\x20URL:\x20','.png','./midjourney.entity','pollComparisonResultDraw','assign','drawId','$1****$2','decorate','Injectable','当前图片不存在!','WAITING','findAndCount','REGENERATE','addDrawQueue','10vZPMqz','获取我得绘制列表失败','积分。','getList','process','__decorate','绘制中的图片任务、禁止删除!','操作成功!','debug','UploadService','drawFailed','draw','__metadata','@nestjs/common','uploadService','findOne','defineProperty','design:paramtypes','isDelete','orderId','DRAWFAIL','userInfo','get','mjPromptsEntity','getImageSizeFromUrl','userId','object','删除失败!','stringify','存储图片失败,使用原始图片链接','image-size','删除成功!','MidjourneyStatusEnum','发送绘图指令失败、请联系管理员检测绘画配置!','删除记录失败!','UPSCALE','ZOOM','未能获取结果数据','mjKey','checkLimit','arraybuffer','drawRatio','getOwnPropertyDescriptor','mjNotSaveImg','MidjourneyService','sendDrawCommand','startsWith','count','createdAt','test','drawUrl','mjPromptEntity','346752nNkhpf','imageUrl','InjectRepository','./prompt.entity','globalConfigService'];_0x4a52=function(){return _0x627342;};return _0x4a52();}const user_entity_1=require(_0x3b2075(0x1c9)),common_1=require(_0x3b2075(0x174)),typeorm_1=require('@nestjs/typeorm'),midjourney_entity_1=require(_0x3b2075(0x15b)),typeorm_2=require(_0x3b2075(0x1dd)),axios_1=require(_0x3b2075(0x147)),globalConfig_service_1=require(_0x3b2075(0x14e)),midjourney_constant_1=require(_0x3b2075(0x14f)),upload_service_1=require('../upload/upload.service'),userBalance_service_1=require(_0x3b2075(0x1ec)),utils_1=require(_0x3b2075(0x1df)),redisCache_service_1=require(_0x3b2075(0x13a)),prompt_entity_1=require(_0x3b2075(0x19e)),image_size_1=require(_0x3b2075(0x185));let MidjourneyService=class MidjourneyService{constructor(_0x1d2402,_0x525cc9,_0x5efda4,_0x333bb4,_0x54f4d2,_0x4c26ce,_0x524073){const _0xcbf1f2=_0x3b2075;this[_0xcbf1f2(0x1c1)]=_0x1d2402,this['userEntity']=_0x525cc9,this[_0xcbf1f2(0x17e)]=_0x5efda4,this[_0xcbf1f2(0x19f)]=_0x333bb4,this[_0xcbf1f2(0x175)]=_0x54f4d2,this[_0xcbf1f2(0x1a8)]=_0x4c26ce,this[_0xcbf1f2(0x1be)]=_0x524073,this[_0xcbf1f2(0x1bf)]=[];}async[_0x3b2075(0x1ea)](_0x48a43a){return new Promise(_0x56890f=>setTimeout(_0x56890f,_0x48a43a));}async['getImageSizeFromUrl'](_0x18aba2){const _0x40d131=_0x3b2075;try{const _0x53bee0=await axios_1['default'][_0x40d131(0x17d)](_0x18aba2,{'responseType':'arraybuffer'}),_0x5af17c=Buffer[_0x40d131(0x1de)](_0x53bee0[_0x40d131(0x1e2)],'binary'),_0x538da7=(0x0,image_size_1[_0x40d131(0x1b0)])(_0x5af17c);return{'width':_0x538da7[_0x40d131(0x152)],'height':_0x538da7[_0x40d131(0x1cf)]};}catch(_0x25f5f1){console[_0x40d131(0x145)](_0x40d131(0x1d5),_0x25f5f1);throw _0x25f5f1;}}async[_0x3b2075(0x172)](_0x1a96ba,_0x139219){const _0x803b19=_0x3b2075,{id:_0x5b4f1b,action:_0x4b10d9,drawId:_0x364c9a}=_0x1a96ba,_0x576d32=await this[_0x803b19(0x1c1)][_0x803b19(0x176)]({'where':{'id':_0x5b4f1b}}),{customId:_0x550b06}=_0x576d32;try{await this[_0x803b19(0x14c)](_0x5b4f1b,_0x139219),await this[_0x803b19(0x1c5)](_0x5b4f1b,midjourney_constant_1[_0x803b19(0x187)][_0x803b19(0x1cc)]);const _0x3c05f5=await this['sendDrawCommand'](_0x576d32,_0x4b10d9);_0x576d32[_0x803b19(0x15e)]=_0x3c05f5;const _0x3543af=await this[_0x803b19(0x15c)](_0x5b4f1b,_0x576d32);return await this[_0x803b19(0x156)](_0x1a96ba,_0x3543af),this[_0x803b19(0x155)](_0x1a96ba),!![];}catch(_0x369fc3){return console[_0x803b19(0x1bb)](_0x803b19(0x1c7),_0x369fc3),!![];}}async[_0x3b2075(0x166)](_0x559110){const _0x33961b=_0x3b2075;try{const {prompt:_0x5783ee,imgUrl:imgUrl='',extraParam:extraParam='',action:_0x4ef009,userId:_0x2761cb,orderId:_0x144060,customId:_0x2f2191,drawId:_0x127e62}=_0x559110,_0x949f67=imgUrl?imgUrl+'\x20'+_0x5783ee+'\x20'+extraParam:_0x5783ee+'\x20'+extraParam,_0x44da10={'userId':_0x2761cb,'drawId':_0x127e62,'extraParam':extraParam,'prompt':_0x5783ee,'imgUrl':imgUrl,'fullPrompt':_0x949f67,'status':midjourney_constant_1[_0x33961b(0x187)][_0x33961b(0x163)],'action':_0x4ef009,'orderId':_0x144060,'customId':_0x2f2191},_0x2dcc9a=await this[_0x33961b(0x1c1)]['save'](_0x44da10);return _0x2dcc9a;}catch(_0x74b502){console[_0x33961b(0x145)](_0x33961b(0x13b),_0x74b502);throw _0x74b502;}}async['updateDrawStatus'](_0x5b52db,_0x53682c){const _0x5addb7=_0x3b2075;await this[_0x5addb7(0x1c1)][_0x5addb7(0x1a7)]({'id':_0x5b52db},{'status':_0x53682c});}async[_0x3b2075(0x156)](_0x1b694a,_0x3cbbaf){const _0x1464c3=_0x3b2075;try{const {id:_0x30d82b,imageUrl:_0x189e23,action:_0xb8c856,submitTime:_0x3e41f6,finishTime:_0x4a9e50,progress:_0x58aa29}=_0x3cbbaf,_0x28a9d5=_0x4a9e50-_0x3e41f6;let _0x1b8633=Date['now']()+'-'+_0x30d82b+_0x1464c3(0x15a);const _0x534770=await this[_0x1464c3(0x19f)][_0x1464c3(0x13e)]([_0x1464c3(0x192)]);let _0x358b4b='',_0x46b084=!![];try{!Number(_0x534770)||Number(_0x534770)===0x0?(common_1[_0x1464c3(0x1e0)][_0x1464c3(0x16f)]('------>\x20开始上传图片',_0x1464c3(0x193)),_0x358b4b=await this[_0x1464c3(0x175)][_0x1464c3(0x1b6)]({'filename':_0x1b8633,'url':_0x189e23})):(_0x358b4b=_0x189e23,_0x46b084=![],common_1[_0x1464c3(0x1e0)]['debug']('本次不存图片了',_0x1464c3(0x193)));}catch(_0x147d89){common_1[_0x1464c3(0x1e0)][_0x1464c3(0x145)](_0x1464c3(0x184),_0x1464c3(0x193)),_0x358b4b=_0x189e23,_0x46b084=![];}const {width:_0x16a6bb,height:_0x464ea4}=await this[_0x1464c3(0x17f)](_0x189e23),_0x59a58c={'status':midjourney_constant_1['MidjourneyStatusEnum'][_0x1464c3(0x1eb)],'drawId':_0x30d82b,'action':_0xb8c856,'drawUrl':_0x358b4b,'drawRatio':_0x16a6bb+'x'+_0x464ea4,'progress':0x64,'extend':this[_0x1464c3(0x138)](JSON[_0x1464c3(0x183)](_0x3cbbaf)),'durationSpent':_0x28a9d5,'isSaveImg':_0x46b084};await this[_0x1464c3(0x1c1)][_0x1464c3(0x1a7)]({'id':_0x1b694a['id']},_0x59a58c);}catch(_0x2762c8){throw new common_1['HttpException'](_0x1464c3(0x157),common_1[_0x1464c3(0x1d2)][_0x1464c3(0x1bd)]);}}async[_0x3b2075(0x194)](_0x31f133,_0x5408ae){const _0x695b7c=_0x3b2075,_0x2e6974=await this['globalConfigService']['getConfigs']([_0x695b7c(0x1cd)]),_0x4fc5cf=await this[_0x695b7c(0x19f)][_0x695b7c(0x13e)](['mjKey']),{id:_0x2414f9,fullPrompt:_0x28d986,imgUrl:_0x22b15d,drawId:_0xcd8ff6,customId:_0xeaf115}=_0x31f133,_0x59fc2b=_0x22b15d?_0x22b15d+'\x20'+_0x28d986:''+_0x28d986;let _0x3d7393='',_0x30065f={};const _0x2aeea7=0x3;let _0x2d20c5=0x0;while(_0x2d20c5<_0x2aeea7){try{_0x5408ae===_0x695b7c(0x1d1)?(_0x3d7393=_0x2e6974+_0x695b7c(0x144),_0x30065f={'prompt':_0x59fc2b}):(_0x3d7393=_0x2e6974+'/mj/submit/action',_0x30065f={'taskId':_0xcd8ff6,'customId':_0xeaf115});const _0x1f11b1={'mj-api-secret':_0x4fc5cf},_0x66d7d4=await axios_1[_0x695b7c(0x1b0)]['post'](_0x3d7393,_0x30065f,{'headers':_0x1f11b1}),{result:_0x5514d8}=_0x66d7d4[_0x695b7c(0x1e2)];if(_0x5514d8)return common_1[_0x695b7c(0x1e0)]['log'](_0x695b7c(0x1e4)+_0x5514d8,_0x695b7c(0x193)),_0x5514d8;else throw new Error(_0x695b7c(0x18c));}catch(_0x224791){_0x2d20c5++;if(_0x2d20c5>=_0x2aeea7){await this[_0x695b7c(0x1c5)](_0x2414f9,midjourney_constant_1['MidjourneyStatusEnum'][_0x695b7c(0x17b)]);throw new common_1[(_0x695b7c(0x1b1))](_0x695b7c(0x188),common_1['HttpStatus']['BAD_REQUEST']);}}}}async[_0x3b2075(0x15c)](_0x556191,_0x161cb1){const _0x456eb3=_0x3b2075,_0x3934d4=await this['globalConfigService']['getConfigs']([_0x456eb3(0x1cd)]),_0x11f77c=await this['globalConfigService'][_0x456eb3(0x13e)]([_0x456eb3(0x18d)]),_0x3f8c9e=Date['now'](),_0x347185=0x1388,_0x44d8e6=0x249f0;let _0x5b4bc4=0x0,_0x16f68b=0x0;const _0x726ebc=0x5,{drawId:_0x395e3a}=_0x161cb1;try{while(Date[_0x456eb3(0x1d3)]()-_0x3f8c9e<_0x44d8e6&&_0x16f68b<_0x726ebc){await new Promise(_0x27b363=>setTimeout(_0x27b363,_0x347185));try{const _0x26e104={'Content-Type':'application/x-www-form-urlencoded','mj-api-secret':_0x11f77c},_0x43b6f3=_0x3934d4+_0x456eb3(0x1e8)+_0x395e3a+'/fetch',_0x11ca3e=await axios_1[_0x456eb3(0x1b0)][_0x456eb3(0x17d)](_0x43b6f3,{'headers':_0x26e104}),_0x46048f=_0x11ca3e[_0x456eb3(0x1e2)],_0x450ede=_0x46048f[_0x456eb3(0x16b)];await this['midjourneyEntity'][_0x456eb3(0x1a7)]({'id':_0x556191},{'progress':_0x450ede});if(_0x46048f[_0x456eb3(0x1b8)]===_0x456eb3(0x1b2))return common_1[_0x456eb3(0x1e0)][_0x456eb3(0x1bb)](_0x456eb3(0x159)+_0x46048f[_0x456eb3(0x19c)],'MidjourneyService'),_0x46048f;}catch(_0x573497){_0x16f68b++,common_1[_0x456eb3(0x1e0)][_0x456eb3(0x145)]('轮询过程中发生错误:\x20'+_0x573497,_0x456eb3(0x193));}_0x5b4bc4++;}if(_0x16f68b>=_0x726ebc){await this[_0x456eb3(0x1c5)](_0x556191,midjourney_constant_1[_0x456eb3(0x187)][_0x456eb3(0x17b)]);throw new common_1[(_0x456eb3(0x1b1))](_0x456eb3(0x1d4),common_1[_0x456eb3(0x1d2)][_0x456eb3(0x1bd)]);}common_1[_0x456eb3(0x1e0)]['error']('绘画超时,请稍后再试!',_0x456eb3(0x193)),await this[_0x456eb3(0x1c5)](_0x556191,midjourney_constant_1[_0x456eb3(0x187)][_0x456eb3(0x17b)]);throw new common_1[(_0x456eb3(0x1b1))](_0x456eb3(0x1e7),common_1[_0x456eb3(0x1d2)][_0x456eb3(0x1bd)]);}catch(_0x1f4fa9){common_1[_0x456eb3(0x1e0)]['error']('获取图片结果失败:\x20',_0x1f4fa9,'MidjourneyService'),await this[_0x456eb3(0x1c5)](_0x556191,midjourney_constant_1[_0x456eb3(0x187)][_0x456eb3(0x17b)]);throw _0x1f4fa9;}}[_0x3b2075(0x138)](_0x41237a){const _0x2e49e0=_0x3b2075,_0x365a71=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return _0x41237a[_0x2e49e0(0x1e5)](_0x365a71,'');}async[_0x3b2075(0x14c)](_0x118da0,_0x3ef64a){const _0x37e9f9=_0x3b2075;await this[_0x37e9f9(0x1c1)][_0x37e9f9(0x1a7)]({'id':_0x118da0},{'jobId':_0x3ef64a});}async[_0x3b2075(0x13f)](_0x190354,_0x2eec71){const _0x479275=_0x3b2075;try{const {page:page=0x1,size:size=0x1e}=_0x2eec71,[_0x4e3058,_0x15e472]=await this['midjourneyEntity'][_0x479275(0x164)]({'where':{'userId':_0x190354['user']['id'],'isDelete':0x0},'order':{'id':_0x479275(0x1dc)},'take':size,'skip':(page-0x1)*size,'select':['id',_0x479275(0x180),_0x479275(0x150),_0x479275(0x1ca),_0x479275(0x1a5),'rec',_0x479275(0x17a),'drawId','drawUrl','drawRatio',_0x479275(0x179),_0x479275(0x1b8),'action']}),_0x34e93d=await this[_0x479275(0x1c1)]['count']({'where':{'isDelete':0x0,'status':(0x0,typeorm_2['In'])([0x1,0x2])}}),_0x7e9ade={'rows':(0x0,utils_1[_0x479275(0x14b)])(_0x4e3058),'count':_0x15e472,'countQueue':_0x34e93d};return _0x7e9ade;}catch(_0x248905){throw new common_1[(_0x479275(0x1b1))](_0x479275(0x168),common_1[_0x479275(0x1d2)][_0x479275(0x1bd)]);}}async[_0x3b2075(0x1db)](_0x53adba,_0x1b3405,_0x5e7218){const _0x45fbb5=_0x3b2075,_0x2d445a=await this[_0x45fbb5(0x1c1)][_0x45fbb5(0x176)]({'where':{'drawId':_0x1b3405}}),{extend:_0x383b21,prompt:_0x34fd40,imgUrl:_0xa58b62,extraParam:_0x1de526}=_0x2d445a,_0x343e4a=JSON[_0x45fbb5(0x1e3)](_0x383b21),_0x3aeef3=_0x343e4a[_0x45fbb5(0x1e1)]||[];let _0x5c6aec;_0x53adba===_0x45fbb5(0x18a)&&(_0x5c6aec=_0x3aeef3[_0x45fbb5(0x1c8)](_0x5ed9f2=>{const _0xc03976=_0x45fbb5,_0x1ddfb2=_0x5ed9f2[_0xc03976(0x1b4)][_0xc03976(0x195)]('U'+_0x5e7218),_0x21991a=_0x5e7218===0x1&&/(Redo )?Upscale \(Subtle\)/[_0xc03976(0x198)](_0x5ed9f2[_0xc03976(0x1b4)])||_0x5e7218===0x2&&/(Redo )?Upscale \(Creative\)/[_0xc03976(0x198)](_0x5ed9f2[_0xc03976(0x1b4)]);return _0x1ddfb2||_0x21991a;}));_0x53adba==='VARIATION'&&(_0x5c6aec=_0x3aeef3[_0x45fbb5(0x1c8)](_0x1825bf=>{const _0x1e7faf=_0x45fbb5,_0x3308f6=_0x1825bf[_0x1e7faf(0x1b4)][_0x1e7faf(0x195)]('V'+_0x5e7218),_0x425516=_0x5e7218===0x1&&/Vary \(Strong\)/[_0x1e7faf(0x198)](_0x1825bf[_0x1e7faf(0x1b4)])||_0x5e7218===0x2&&/Vary \(Region\)/[_0x1e7faf(0x198)](_0x1825bf[_0x1e7faf(0x1b4)]);return _0x3308f6||_0x425516;}));_0x53adba===_0x45fbb5(0x165)&&(_0x5c6aec=_0x3aeef3[_0x45fbb5(0x1c8)](_0x32b26b=>_0x32b26b[_0x45fbb5(0x1a4)][_0x45fbb5(0x195)](_0x45fbb5(0x1b7))&&_0x32b26b['label']===''));_0x53adba===_0x45fbb5(0x18b)&&(_0x5c6aec=_0x3aeef3[_0x45fbb5(0x1c8)](_0xa92d7f=>_0x5e7218===0x1&&_0xa92d7f[_0x45fbb5(0x1b4)]===_0x45fbb5(0x13c)||_0x5e7218===0x2&&_0xa92d7f[_0x45fbb5(0x1b4)]===_0x45fbb5(0x1d6)));if(!_0x5c6aec)throw new common_1[(_0x45fbb5(0x1b1))](_0x45fbb5(0x1c2),common_1[_0x45fbb5(0x1d2)][_0x45fbb5(0x1bd)]);const {customId:_0x569747}=_0x5c6aec;return{'customId':_0x569747,'prompt':_0x34fd40,'extraParam':_0x1de526,'drawId':_0x1b3405};}async[_0x3b2075(0x1a9)](_0x2e7446,_0xeefa3e){const _0x58f81c=_0x3b2075,_0x13099f=await this[_0x58f81c(0x1c1)]['findOne']({'where':{'id':_0x2e7446,'userId':_0xeefa3e['user']['id'],'isDelete':0x0}});if(!_0x13099f)throw new common_1['HttpException'](_0x58f81c(0x162),common_1[_0x58f81c(0x1d2)][_0x58f81c(0x1bd)]);if(_0x13099f[_0x58f81c(0x1b8)]===0x2)throw new common_1[(_0x58f81c(0x1b1))](_0x58f81c(0x16d),common_1[_0x58f81c(0x1d2)]['BAD_REQUEST']);const _0x1b63f6=await this[_0x58f81c(0x1c1)][_0x58f81c(0x1a7)]({'id':_0x2e7446},{'isDelete':0x1});if(_0x1b63f6['affected']>0x0)return _0x58f81c(0x186);else throw new common_1[(_0x58f81c(0x1b1))](_0x58f81c(0x182),common_1['HttpStatus'][_0x58f81c(0x1bd)]);}async[_0x3b2075(0x18e)](_0x4655f3){const _0x1292a0=_0x3b2075,{role:_0xff5828,id:_0x5ad326}=_0x4655f3['user'],_0x536838=await this[_0x1292a0(0x1c1)][_0x1292a0(0x196)]({'where':{'userId':_0x5ad326,'isDelete':0x0,'status':(0x0,typeorm_2['In'])([0x1,0x2])}}),_0xca77fe=await this['globalConfigService'][_0x1292a0(0x13e)]([_0x1292a0(0x1e6)]),_0x546a1f=_0xca77fe?Number(_0xca77fe):0x2;if(_0x536838>=_0x546a1f)throw new common_1['HttpException'](_0x1292a0(0x1b3)+_0x546a1f+_0x1292a0(0x140),common_1[_0x1292a0(0x1d2)][_0x1292a0(0x1bd)]);}async[_0x3b2075(0x171)](_0x1f18bd){const _0x405465=_0x3b2075,{id:_0x2ff45a,userId:_0x5f3b62,action:_0x5ebc0c}=_0x1f18bd;await this[_0x405465(0x1c1)][_0x405465(0x1a7)]({'id':_0x2ff45a},{'status':0x4});}async[_0x3b2075(0x155)](_0x5a1f7e){const _0x358a68=_0x3b2075,{id:_0x19cddd,userId:_0x1c19b4,action:_0x4007a5}=_0x5a1f7e,_0x506fbe=_0x4007a5===_0x358a68(0x18a)?0x1:0x4;common_1[_0x358a68(0x1e0)][_0x358a68(0x16f)](_0x358a68(0x1a6)+_0x506fbe+_0x358a68(0x169)),await this[_0x358a68(0x1a8)]['refundMjBalance'](_0x1c19b4,-_0x506fbe),await this[_0x358a68(0x1c1)]['update']({'id':_0x19cddd},{'status':0x3});}async[_0x3b2075(0x16a)](_0x1594c6){const _0x116d0f=_0x3b2075,{page:page=0x1,size:size=0x14,rec:_0x3d2784,userId:_0x2bdbda,status:_0x457bf7}=_0x1594c6;if(Number(size)===0x3e7){const _0x3c5108=await this[_0x116d0f(0x1be)][_0x116d0f(0x17d)]({'key':_0x116d0f(0x1aa)});if(_0x3c5108)try{return JSON['parse'](_0x3c5108);}catch(_0x194ebd){return[];}}const _0x29b8c7={'isDelete':0x0};_0x3d2784&&Object['assign'](_0x29b8c7,{'rec':_0x3d2784}),_0x2bdbda&&Object[_0x116d0f(0x15d)](_0x29b8c7,{'userId':_0x2bdbda}),_0x457bf7&&Object['assign'](_0x29b8c7,{'status':_0x457bf7});const [_0x28db20,_0x278acd]=await this['midjourneyEntity'][_0x116d0f(0x164)]({'where':_0x29b8c7,'order':{'id':_0x116d0f(0x1dc)},'take':size,'skip':(page-0x1)*size,'select':['id',_0x116d0f(0x15e),_0x116d0f(0x199),_0x116d0f(0x190),_0x116d0f(0x150),_0x116d0f(0x1a5),_0x116d0f(0x139),_0x116d0f(0x197),_0x116d0f(0x1d7),_0x116d0f(0x1b8)]});if(Number(size)===0x3e7){const _0x2f0480={'rows':_0x28db20['map'](_0x415bac=>{const {id:_0x3f96b2,drawId:_0x513f6a,drawUrl:_0xa6251e,drawRatio:_0x24e633,prompt:_0x14f61d,fullPrompt:_0x30b177,createdAt:_0x752326,rec:_0x374324,action:_0x223f60,status:_0x235c18}=_0x415bac;return{'id':_0x3f96b2,'drawId':_0x513f6a,'drawUrl':_0xa6251e,'drawRatio':_0x24e633,'prompt':_0x14f61d,'fullPrompt':_0x30b177,'createdAt':_0x752326,'rec':_0x374324,'action':_0x223f60,'status':_0x235c18};}),'count':_0x278acd};return await this[_0x116d0f(0x1be)]['set']({'key':_0x116d0f(0x1aa),'val':JSON['stringify'](_0x2f0480)},0x3c*0x5),_0x2f0480;}const _0x3ad84={'rows':_0x28db20,'count':_0x278acd};return _0x3ad84;}async['getFullPrompt'](_0x5a1749){const _0x5217a3=_0x3b2075,_0x4850c5=await this[_0x5217a3(0x1c1)][_0x5217a3(0x176)]({'where':{'id':_0x5a1749}});if(!_0x4850c5)return'';const {fullPrompt:_0x35c297}=_0x4850c5;return _0x35c297;}async[_0x3b2075(0x1c4)](_0xf127b6,_0x392f45){const _0x976961=_0x3b2075;try{const {page:page=0x1,size:size=0xa,rec:_0x12ce4d,userId:_0x429782,status:_0x7f6765}=_0x392f45,_0x438962={'isDelete':0x0};_0x12ce4d&&Object['assign'](_0x438962,{'rec':_0x12ce4d}),_0x429782&&Object['assign'](_0x438962,{'userId':_0x429782}),_0x7f6765&&Object[_0x976961(0x15d)](_0x438962,{'status':_0x7f6765});const [_0x4aacef,_0xab7b95]=await this['midjourneyEntity'][_0x976961(0x164)]({'where':_0x438962,'order':{'id':_0x976961(0x1dc)},'take':size,'skip':(page-0x1)*size}),_0x4c73ad=_0x4aacef['map'](_0x57dc4d=>_0x57dc4d[_0x976961(0x180)])[_0x976961(0x14a)](_0x30cd9b=>_0x30cd9b<0x186a0),_0x155d3c=await this[_0x976961(0x1ba)][_0x976961(0x1c8)]({'where':{'id':(0x0,typeorm_2['In'])(_0x4c73ad)},'select':['id',_0x976961(0x153),'avatar','email']});return _0x4aacef[_0x976961(0x1e9)](_0x511d98=>{const _0x443a05=_0x976961;_0x511d98[_0x443a05(0x17c)]=_0x155d3c[_0x443a05(0x1c8)](_0x3ec2dd=>_0x3ec2dd['id']===_0x511d98['userId']);}),_0xf127b6[_0x976961(0x1a3)]['role']!=='super'&&_0x4aacef[_0x976961(0x1e9)](_0x5b71c7=>{const _0x3bec85=_0x976961;_0x5b71c7[_0x3bec85(0x17c)]&&_0x5b71c7[_0x3bec85(0x17c)][_0x3bec85(0x142)]&&(_0x5b71c7[_0x3bec85(0x17c)][_0x3bec85(0x142)]=_0x5b71c7[_0x3bec85(0x17c)][_0x3bec85(0x142)][_0x3bec85(0x1e5)](/(.{2}).+(.{2}@.+)/,_0x3bec85(0x15f)));}),{'rows':_0x4aacef,'count':_0xab7b95};}catch(_0x407f2c){throw new common_1[(_0x976961(0x1b1))](_0x976961(0x1a0),common_1[_0x976961(0x1d2)][_0x976961(0x1bd)]);}}async[_0x3b2075(0x158)](_0x53f5c0){const _0x59307b=_0x3b2075,{id:_0x440898}=_0x53f5c0,_0xeae32d=await this['midjourneyEntity'][_0x59307b(0x176)]({'where':{'id':_0x440898,'status':0x3,'isDelete':0x0}});if(!_0xeae32d)throw new common_1['HttpException'](_0x59307b(0x162),common_1['HttpStatus']['BAD_REQUEST']);const {rec:_0x2c1bd2}=_0xeae32d,_0x5621fc=await this[_0x59307b(0x1c1)]['update']({'id':_0x440898},{'rec':_0x2c1bd2===0x1?0x0:0x1});if(_0x5621fc[_0x59307b(0x1c3)]>0x0)return _0x59307b(0x16e);}async[_0x3b2075(0x1d9)](){const _0x22368e=_0x3b2075;try{await this[_0x22368e(0x1c1)][_0x22368e(0x1a7)]({'status':0x2},{'status':0x4});}catch(_0x57f34f){console['log']('TODO->error:\x20',_0x57f34f);}}async['delLog'](_0x4b48d7,_0x512197){const _0x29974e=_0x3b2075,{id:_0x402624}=_0x512197;if(!_0x402624)throw new common_1['HttpException']('非法操作!',common_1[_0x29974e(0x1d2)][_0x29974e(0x1bd)]);const _0x466268=await this[_0x29974e(0x1c1)][_0x29974e(0x1af)]({'id':_0x402624});if(_0x466268[_0x29974e(0x1c3)]>0x0)return'删除记录成功!';else throw new common_1[(_0x29974e(0x1b1))](_0x29974e(0x189),common_1[_0x29974e(0x1d2)][_0x29974e(0x1bd)]);}async[_0x3b2075(0x1c6)](_0x3da438,_0x4c6752){const _0x5e2756=_0x3b2075;try{const {prompt:_0x16e60e,status:_0x892930,isCarryParams:_0xc39289,title:_0x1d71a1,order:_0x2238a3,id:_0x5e0c61,aspect:_0x9ad863}=_0x4c6752;return _0x5e0c61?await this[_0x5e2756(0x17e)][_0x5e2756(0x1a7)]({'id':_0x5e0c61},{'prompt':_0x16e60e,'status':_0x892930,'isCarryParams':_0xc39289,'order':_0x2238a3,'aspect':_0x9ad863}):await this[_0x5e2756(0x17e)][_0x5e2756(0x13d)]({'prompt':_0x16e60e,'status':_0x892930,'isCarryParams':_0xc39289,'title':_0x1d71a1,'order':_0x2238a3,'aspect':_0x9ad863});}catch(_0x37a92e){console['log']('error:\x20',_0x37a92e);}}async[_0x3b2075(0x1d8)](_0x12adda,_0x431344){const _0x432e03=_0x3b2075,{id:_0x546431}=_0x431344;if(!_0x546431)throw new common_1['HttpException']('非法操作!',common_1[_0x432e03(0x1d2)][_0x432e03(0x1bd)]);return await this[_0x432e03(0x17e)][_0x432e03(0x1af)]({'id':_0x546431});}async[_0x3b2075(0x1bc)](){const _0x4e692f=_0x3b2075;return await this[_0x4e692f(0x17e)][_0x4e692f(0x1c8)]({'order':{'order':'DESC'}});}async[_0x3b2075(0x154)](_0x26e6e9){const _0x1c45fe=_0x3b2075,{url:_0x3a1932}=_0x26e6e9;if(!_0x3a1932)return;const _0x3cb3aa=await axios_1[_0x1c45fe(0x1b0)][_0x1c45fe(0x17d)](_0x3a1932,{'responseType':_0x1c45fe(0x18f)}),_0x32f797=Buffer[_0x1c45fe(0x1de)](_0x3cb3aa[_0x1c45fe(0x1e2)])[_0x1c45fe(0x146)]('base64');return _0x32f797;}};MidjourneyService=__decorate([(0x0,common_1[_0x3b2075(0x161)])(),__param(0x0,(0x0,typeorm_1[_0x3b2075(0x19d)])(midjourney_entity_1[_0x3b2075(0x143)])),__param(0x1,(0x0,typeorm_1[_0x3b2075(0x19d)])(user_entity_1[_0x3b2075(0x1cb)])),__param(0x2,(0x0,typeorm_1[_0x3b2075(0x19d)])(prompt_entity_1[_0x3b2075(0x19a)])),__metadata(_0x3b2075(0x178),[typeorm_2[_0x3b2075(0x151)],typeorm_2[_0x3b2075(0x151)],typeorm_2[_0x3b2075(0x151)],globalConfig_service_1[_0x3b2075(0x1da)],upload_service_1[_0x3b2075(0x170)],userBalance_service_1['UserBalanceService'],redisCache_service_1[_0x3b2075(0x148)]])],MidjourneyService),exports[_0x3b2075(0x193)]=MidjourneyService;