YiAi/YiAiQuickDeploy/dist/modules/chatGroup/chatGroup.service.js
2024-07-02 16:38:26 +08:00

1 line
8.7 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 _0xbd27b1=_0x2d36;function _0x2d36(_0xdeddea,_0x18bb9f){const _0x4fc4ad=_0x4fc4();return _0x2d36=function(_0x2d3641,_0x17f649){_0x2d3641=_0x2d3641-0x106;let _0x3c5cf3=_0x4fc4ad[_0x2d3641];return _0x3c5cf3;},_0x2d36(_0xdeddea,_0x18bb9f);}function _0x4fc4(){const _0x731995=['Repository','DESC','decorate','1725350Hcpylf','Injectable','276kaZJNc','106599ZMoQPP','ModelsService','query','config','isSticky','@nestjs/common','find','design:paramtypes','更新对话失败!','请先选择一个对话或者新加一个对话再操作!','../app/app.entity','./chatGroup.entity','user','ChatGroupService','function','map','affected','管理员未配置任何AI模型、请先联系管理员开通聊天模型配置','update','InjectRepository','appLogo','error:\x20','非法操作、您在删除一个非法资源!','__esModule','typeorm','length','__decorate','create','BAD_REQUEST','500290kZtVZG','appEntity','ChatGroupEntity','del','metadata','assign','应用对话名称不能修改哟!','../models/models.service','当前应用已经开启了一个对话无需新建了!','1919268nOHFVH','63608uxqooe','__param','getOwnPropertyDescriptor','coverImg','@nestjs/typeorm','891mYYZDa','findOne','非法操作、您在使用一个未启用的应用!','includes','parse','keyType','删除成功','新对话','HttpStatus','modelsService','2883YbSyJH','24cZBpdg','chatGroupEntity','filter','HttpException','object','appId','undefined','defineProperty','title','1511902iMkLcx','getGroupInfoFromId','AppEntity'];_0x4fc4=function(){return _0x731995;};return _0x4fc4();}(function(_0x41dcbe,_0x565fae){const _0x3440d8=_0x2d36,_0x17b0df=_0x41dcbe();while(!![]){try{const _0x3a0ba7=-parseInt(_0x3440d8(0x10e))/0x1*(parseInt(_0x3440d8(0x120))/0x2)+parseInt(_0x3440d8(0x121))/0x3+parseInt(_0x3440d8(0x147))/0x4+parseInt(_0x3440d8(0x11e))/0x5+parseInt(_0x3440d8(0x10f))/0x6*(parseInt(_0x3440d8(0x118))/0x7)+-parseInt(_0x3440d8(0x148))/0x8*(parseInt(_0x3440d8(0x14d))/0x9)+-parseInt(_0x3440d8(0x13e))/0xa;if(_0x3a0ba7===_0x565fae)break;else _0x17b0df['push'](_0x17b0df['shift']());}catch(_0x2061da){_0x17b0df['push'](_0x17b0df['shift']());}}}(_0x4fc4,0x77774));var __decorate=this&&this[_0xbd27b1(0x13b)]||function(_0x3cfff4,_0x20bb0a,_0x2e9af8,_0x363f5a){const _0x42e9f2=_0xbd27b1;var _0x1b5d9d=arguments[_0x42e9f2(0x13a)],_0x5446f5=_0x1b5d9d<0x3?_0x20bb0a:_0x363f5a===null?_0x363f5a=Object[_0x42e9f2(0x14a)](_0x20bb0a,_0x2e9af8):_0x363f5a,_0x584a14;if(typeof Reflect===_0x42e9f2(0x113)&&typeof Reflect[_0x42e9f2(0x11d)]===_0x42e9f2(0x12f))_0x5446f5=Reflect[_0x42e9f2(0x11d)](_0x3cfff4,_0x20bb0a,_0x2e9af8,_0x363f5a);else{for(var _0x445e86=_0x3cfff4[_0x42e9f2(0x13a)]-0x1;_0x445e86>=0x0;_0x445e86--)if(_0x584a14=_0x3cfff4[_0x445e86])_0x5446f5=(_0x1b5d9d<0x3?_0x584a14(_0x5446f5):_0x1b5d9d>0x3?_0x584a14(_0x20bb0a,_0x2e9af8,_0x5446f5):_0x584a14(_0x20bb0a,_0x2e9af8))||_0x5446f5;}return _0x1b5d9d>0x3&&_0x5446f5&&Object[_0x42e9f2(0x116)](_0x20bb0a,_0x2e9af8,_0x5446f5),_0x5446f5;},__metadata=this&&this['__metadata']||function(_0x20ffd6,_0x576c9c){const _0x4c87c6=_0xbd27b1;if(typeof Reflect==='object'&&typeof Reflect[_0x4c87c6(0x142)]===_0x4c87c6(0x12f))return Reflect['metadata'](_0x20ffd6,_0x576c9c);},__param=this&&this[_0xbd27b1(0x149)]||function(_0x4a2595,_0x52dec6){return function(_0x238a45,_0x2041b7){_0x52dec6(_0x238a45,_0x2041b7,_0x4a2595);};};Object[_0xbd27b1(0x116)](exports,_0xbd27b1(0x138),{'value':!![]}),exports[_0xbd27b1(0x12e)]=void 0x0;const common_1=require(_0xbd27b1(0x126)),chatGroup_entity_1=require(_0xbd27b1(0x12c)),typeorm_1=require(_0xbd27b1(0x14c)),typeorm_2=require(_0xbd27b1(0x139)),app_entity_1=require(_0xbd27b1(0x12b)),models_service_1=require(_0xbd27b1(0x145));let ChatGroupService=class ChatGroupService{constructor(_0x2a4e49,_0x276daa,_0x2fbf42){const _0x5c171f=_0xbd27b1;this['chatGroupEntity']=_0x2a4e49,this['appEntity']=_0x276daa,this[_0x5c171f(0x10d)]=_0x2fbf42;}async[_0xbd27b1(0x13c)](_0x3d5613,_0x2d1549){const _0x493abe=_0xbd27b1,{id:_0x367136}=_0x2d1549[_0x493abe(0x12d)],{appId:_0x22a9b7}=_0x3d5613,_0x45ed00={'title':_0x493abe(0x10b),'userId':_0x367136};if(_0x22a9b7){const _0x59b9f7=await this[_0x493abe(0x13f)][_0x493abe(0x14e)]({'where':{'id':_0x22a9b7}});if(!_0x59b9f7)throw new common_1[(_0x493abe(0x112))]('非法操作、您在使用一个不存在的应用!',common_1['HttpStatus'][_0x493abe(0x13d)]);else{const {status:_0x1f8099,name:_0x5b5234}=_0x59b9f7,_0x4f9201=await this['chatGroupEntity']['count']({'where':{'userId':_0x367136,'appId':_0x22a9b7,'isDelete':![]}});if(_0x4f9201>0x0)throw new common_1['HttpException'](_0x493abe(0x146),common_1[_0x493abe(0x10c)][_0x493abe(0x13d)]);if(![0x1,0x3,0x4,0x5][_0x493abe(0x107)](_0x1f8099))throw new common_1[(_0x493abe(0x112))](_0x493abe(0x106),common_1[_0x493abe(0x10c)][_0x493abe(0x13d)]);_0x5b5234&&(_0x45ed00['title']=_0x5b5234),_0x22a9b7&&(_0x45ed00[_0x493abe(0x114)]=_0x22a9b7);}}const _0x32622c=await this[_0x493abe(0x10d)]['getBaseConfig'](_0x22a9b7);_0x22a9b7&&(_0x32622c['appId']=_0x22a9b7);if(!_0x32622c)throw new common_1[(_0x493abe(0x112))](_0x493abe(0x132),common_1['HttpStatus'][_0x493abe(0x13d)]);return await this[_0x493abe(0x110)]['save'](Object[_0x493abe(0x143)](Object[_0x493abe(0x143)]({},_0x45ed00),{'config':JSON['stringify'](_0x32622c)}));}async[_0xbd27b1(0x123)](_0x2c3607){const _0x310b04=_0xbd27b1;try{const {id:_0x3ce414}=_0x2c3607[_0x310b04(0x12d)],_0x5bb63e={'userId':_0x3ce414,'isDelete':![]},_0x1187c0=await this['chatGroupEntity'][_0x310b04(0x127)]({'where':_0x5bb63e,'order':{'isSticky':_0x310b04(0x11c),'id':_0x310b04(0x11c)}}),_0x1cacab=_0x1187c0[_0x310b04(0x111)](_0x3b1bcc=>_0x3b1bcc[_0x310b04(0x114)])[_0x310b04(0x130)](_0x998dca=>_0x998dca[_0x310b04(0x114)]),_0x8a11b6=await this[_0x310b04(0x13f)][_0x310b04(0x127)]({'where':{'id':(0x0,typeorm_2['In'])(_0x1cacab)}});return _0x1187c0[_0x310b04(0x130)](_0x5d51ba=>{const _0x980c18=_0x310b04;var _0x23cbac;return _0x5d51ba[_0x980c18(0x135)]=(_0x23cbac=_0x8a11b6['find'](_0x5e424e=>_0x5e424e['id']===_0x5d51ba[_0x980c18(0x114)]))===null||_0x23cbac===void 0x0?void 0x0:_0x23cbac[_0x980c18(0x14b)],_0x5d51ba;});}catch(_0x4ebc95){console['log'](_0x310b04(0x136),_0x4ebc95);}}async[_0xbd27b1(0x133)](_0x116602,_0x74daf1){const _0x2974b5=_0xbd27b1,{title:_0x2a7152,isSticky:_0x2fa901,groupId:_0x3dde82,config:_0x2d72be}=_0x116602,{id:_0x33a7a5}=_0x74daf1[_0x2974b5(0x12d)],_0x5e614b=await this[_0x2974b5(0x110)][_0x2974b5(0x14e)]({'where':{'id':_0x3dde82,'userId':_0x33a7a5}});if(!_0x5e614b)throw new common_1[(_0x2974b5(0x112))](_0x2974b5(0x12a),common_1[_0x2974b5(0x10c)][_0x2974b5(0x13d)]);const {appId:_0x18fbe2}=_0x5e614b;if(_0x18fbe2&&!_0x2a7152)try{const _0x2f5eee=JSON[_0x2974b5(0x108)](_0x2d72be);if(Number(_0x2f5eee[_0x2974b5(0x109)])!==0x1)throw new common_1[(_0x2974b5(0x112))](_0x2974b5(0x144),common_1[_0x2974b5(0x10c)][_0x2974b5(0x13d)]);}catch(_0x4d8066){}const _0x2c34ea={};_0x2a7152&&(_0x2c34ea[_0x2974b5(0x117)]=_0x2a7152),typeof _0x2fa901!==_0x2974b5(0x115)&&(_0x2c34ea[_0x2974b5(0x125)]=_0x2fa901),_0x2d72be&&(_0x2c34ea[_0x2974b5(0x124)]=_0x2d72be);const _0xf6ef12=await this[_0x2974b5(0x110)][_0x2974b5(0x133)]({'id':_0x3dde82},_0x2c34ea);if(_0xf6ef12[_0x2974b5(0x131)])return!![];else throw new common_1['HttpException'](_0x2974b5(0x129),common_1['HttpStatus'][_0x2974b5(0x13d)]);}async[_0xbd27b1(0x141)](_0x24ed36,_0x2e1abc){const _0x1cb209=_0xbd27b1,{groupId:_0x4ff2a3}=_0x24ed36,{id:_0xa8301e}=_0x2e1abc[_0x1cb209(0x12d)],_0x76de02=await this['chatGroupEntity'][_0x1cb209(0x14e)]({'where':{'id':_0x4ff2a3,'userId':_0xa8301e}});if(!_0x76de02)throw new common_1[(_0x1cb209(0x112))](_0x1cb209(0x137),common_1[_0x1cb209(0x10c)][_0x1cb209(0x13d)]);const _0x3ec41a=await this[_0x1cb209(0x110)][_0x1cb209(0x133)]({'id':_0x4ff2a3},{'isDelete':!![]});if(_0x3ec41a[_0x1cb209(0x131)])return _0x1cb209(0x10a);else throw new common_1[(_0x1cb209(0x112))]('删除失败!',common_1[_0x1cb209(0x10c)]['BAD_REQUEST']);}async['delAll'](_0x31b85f){const _0xc94fd6=_0xbd27b1,{id:_0x3de6a1}=_0x31b85f[_0xc94fd6(0x12d)],_0x43f9ca=await this[_0xc94fd6(0x110)]['update']({'userId':_0x3de6a1,'isSticky':![],'isDelete':![]},{'isDelete':!![]});if(_0x43f9ca[_0xc94fd6(0x131)])return _0xc94fd6(0x10a);else throw new common_1[(_0xc94fd6(0x112))]('删除失败!',common_1[_0xc94fd6(0x10c)][_0xc94fd6(0x13d)]);}async[_0xbd27b1(0x119)](_0x6292c8){const _0x5061ab=_0xbd27b1;if(!_0x6292c8)return;return await this[_0x5061ab(0x110)][_0x5061ab(0x14e)]({'where':{'id':_0x6292c8}});}};ChatGroupService=__decorate([(0x0,common_1[_0xbd27b1(0x11f)])(),__param(0x0,(0x0,typeorm_1[_0xbd27b1(0x134)])(chatGroup_entity_1[_0xbd27b1(0x140)])),__param(0x1,(0x0,typeorm_1[_0xbd27b1(0x134)])(app_entity_1[_0xbd27b1(0x11a)])),__metadata(_0xbd27b1(0x128),[typeorm_2[_0xbd27b1(0x11b)],typeorm_2[_0xbd27b1(0x11b)],models_service_1[_0xbd27b1(0x122)]])],ChatGroupService),exports[_0xbd27b1(0x12e)]=ChatGroupService;