YiAi/YiAiQuickDeploy/dist/modules/chatGroup/chatGroup.service.js
2024-02-06 13:43:30 +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 _0x251c81=_0x3b16;(function(_0x18e5c2,_0x5a8eab){const _0x165a40=_0x3b16,_0xc27628=_0x18e5c2();while(!![]){try{const _0xfdba4=-parseInt(_0x165a40(0x172))/0x1*(-parseInt(_0x165a40(0x14f))/0x2)+-parseInt(_0x165a40(0x162))/0x3+-parseInt(_0x165a40(0x156))/0x4+parseInt(_0x165a40(0x160))/0x5*(-parseInt(_0x165a40(0x165))/0x6)+-parseInt(_0x165a40(0x16b))/0x7+-parseInt(_0x165a40(0x16e))/0x8*(-parseInt(_0x165a40(0x15a))/0x9)+-parseInt(_0x165a40(0x161))/0xa*(-parseInt(_0x165a40(0x183))/0xb);if(_0xfdba4===_0x5a8eab)break;else _0xc27628['push'](_0xc27628['shift']());}catch(_0x12eab1){_0xc27628['push'](_0xc27628['shift']());}}}(_0x3772,0x3f1c5));var __decorate=this&&this[_0x251c81(0x151)]||function(_0xbd80ec,_0x5a8ac8,_0x356910,_0x2ce497){const _0x1f5839=_0x251c81;var _0x599423=arguments[_0x1f5839(0x189)],_0x65028=_0x599423<0x3?_0x5a8ac8:_0x2ce497===null?_0x2ce497=Object['getOwnPropertyDescriptor'](_0x5a8ac8,_0x356910):_0x2ce497,_0x22f9e9;if(typeof Reflect===_0x1f5839(0x14e)&&typeof Reflect[_0x1f5839(0x173)]==='function')_0x65028=Reflect[_0x1f5839(0x173)](_0xbd80ec,_0x5a8ac8,_0x356910,_0x2ce497);else{for(var _0x483d0e=_0xbd80ec['length']-0x1;_0x483d0e>=0x0;_0x483d0e--)if(_0x22f9e9=_0xbd80ec[_0x483d0e])_0x65028=(_0x599423<0x3?_0x22f9e9(_0x65028):_0x599423>0x3?_0x22f9e9(_0x5a8ac8,_0x356910,_0x65028):_0x22f9e9(_0x5a8ac8,_0x356910))||_0x65028;}return _0x599423>0x3&&_0x65028&&Object[_0x1f5839(0x177)](_0x5a8ac8,_0x356910,_0x65028),_0x65028;},__metadata=this&&this[_0x251c81(0x179)]||function(_0x17530a,_0xbe6bbb){const _0x35b5d7=_0x251c81;if(typeof Reflect==='object'&&typeof Reflect['metadata']===_0x35b5d7(0x14a))return Reflect[_0x35b5d7(0x146)](_0x17530a,_0xbe6bbb);},__param=this&&this['__param']||function(_0x5f51c9,_0x3e1524){return function(_0x4d5472,_0x5da6a2){_0x3e1524(_0x4d5472,_0x5da6a2,_0x5f51c9);};};Object[_0x251c81(0x177)](exports,_0x251c81(0x153),{'value':!![]}),exports[_0x251c81(0x187)]=void 0x0;function _0x3b16(_0x3cdd82,_0x2fa4af){const _0x3772be=_0x3772();return _0x3b16=function(_0x3b16f4,_0x47d353){_0x3b16f4=_0x3b16f4-0x145;let _0x5b3489=_0x3772be[_0x3b16f4];return _0x5b3489;},_0x3b16(_0x3cdd82,_0x2fa4af);}const common_1=require(_0x251c81(0x185)),chatGroup_entity_1=require('./chatGroup.entity'),typeorm_1=require('@nestjs/typeorm'),typeorm_2=require(_0x251c81(0x188)),app_entity_1=require(_0x251c81(0x174)),models_service_1=require('../models/models.service');function _0x3772(){const _0x1a8ed0=['9cYszwN','create','非法操作、您在删除一个非法资源!','管理员未配置任何AI模型、请先联系管理员开通聊天模型配置','design:paramtypes','appLogo','163215IeEdNG','186740kkJeRK','925950WkPnuN','HttpException','coverImg','66kcczEi','appEntity','请先选择一个对话或者新加一个对话再操作!','error:\x20','应用对话名称不能修改哟!','del','2865408wlQZzL','Repository','parse','4118584eXdrJY','count','新对话','当前应用已经开启了一个对话无需新建了!','61511sYuLAF','decorate','../app/app.entity','title','删除失败!','defineProperty','非法操作、您在使用一个不存在的应用!','__metadata','Injectable','config','modelsService','affected','filter','user','AppEntity','findOne','DESC','539pXHcsP','getGroupInfoFromId','@nestjs/common','InjectRepository','ChatGroupService','typeorm','length','删除成功','chatGroupEntity','ModelsService','非法操作、您在使用一个未启用的应用!','BAD_REQUEST','metadata','map','ChatGroupEntity','appId','function','update','stringify','getBaseConfig','object','6hpFDgu','includes','__decorate','更新对话失败!','__esModule','save','query','1115256HpLFoH','HttpStatus','assign','find'];_0x3772=function(){return _0x1a8ed0;};return _0x3772();}let ChatGroupService=class ChatGroupService{constructor(_0x5ea7d1,_0x114a65,_0x844107){const _0x22fdc8=_0x251c81;this[_0x22fdc8(0x18b)]=_0x5ea7d1,this[_0x22fdc8(0x166)]=_0x114a65,this[_0x22fdc8(0x17c)]=_0x844107;}async[_0x251c81(0x15b)](_0x51d836,_0xc35c3d){const _0x27cb50=_0x251c81,{id:_0x54bede}=_0xc35c3d[_0x27cb50(0x17f)],{appId:_0x264d7d}=_0x51d836,_0x2f3447={'title':_0x27cb50(0x170),'userId':_0x54bede};if(_0x264d7d){const _0xdc35f2=await this['appEntity']['findOne']({'where':{'id':_0x264d7d}});if(!_0xdc35f2)throw new common_1[(_0x27cb50(0x163))](_0x27cb50(0x178),common_1['HttpStatus']['BAD_REQUEST']);else{const {status:_0x385d5c,name:_0x28688a}=_0xdc35f2,_0x1e2355=await this[_0x27cb50(0x18b)][_0x27cb50(0x16f)]({'where':{'userId':_0x54bede,'appId':_0x264d7d,'isDelete':![]}});if(_0x1e2355>0x0)throw new common_1[(_0x27cb50(0x163))](_0x27cb50(0x171),common_1[_0x27cb50(0x157)][_0x27cb50(0x145)]);if(![0x1,0x3,0x4,0x5][_0x27cb50(0x150)](_0x385d5c))throw new common_1[(_0x27cb50(0x163))](_0x27cb50(0x18d),common_1[_0x27cb50(0x157)][_0x27cb50(0x145)]);_0x28688a&&(_0x2f3447[_0x27cb50(0x175)]=_0x28688a),_0x264d7d&&(_0x2f3447[_0x27cb50(0x149)]=_0x264d7d);}}const _0x3c116a=await this['modelsService'][_0x27cb50(0x14d)](_0x264d7d);_0x264d7d&&(_0x3c116a['appId']=_0x264d7d);if(!_0x3c116a)throw new common_1[(_0x27cb50(0x163))](_0x27cb50(0x15d),common_1['HttpStatus'][_0x27cb50(0x145)]);return await this[_0x27cb50(0x18b)][_0x27cb50(0x154)](Object[_0x27cb50(0x158)](Object[_0x27cb50(0x158)]({},_0x2f3447),{'config':JSON[_0x27cb50(0x14c)](_0x3c116a)}));}async[_0x251c81(0x155)](_0x42b373){const _0x39af29=_0x251c81;try{const {id:_0x23ddd4}=_0x42b373[_0x39af29(0x17f)],_0x3c8c22={'userId':_0x23ddd4,'isDelete':![]},_0x35a521=await this[_0x39af29(0x18b)][_0x39af29(0x159)]({'where':_0x3c8c22,'order':{'isSticky':_0x39af29(0x182),'id':_0x39af29(0x182)}}),_0x1397f6=_0x35a521[_0x39af29(0x17e)](_0x47a288=>_0x47a288[_0x39af29(0x149)])[_0x39af29(0x147)](_0x20eb16=>_0x20eb16[_0x39af29(0x149)]),_0x39707f=await this[_0x39af29(0x166)][_0x39af29(0x159)]({'where':{'id':(0x0,typeorm_2['In'])(_0x1397f6)}});return _0x35a521[_0x39af29(0x147)](_0x3c3eaa=>{const _0x10fd0d=_0x39af29;var _0x2c321a;return _0x3c3eaa[_0x10fd0d(0x15f)]=(_0x2c321a=_0x39707f[_0x10fd0d(0x159)](_0x2c9184=>_0x2c9184['id']===_0x3c3eaa[_0x10fd0d(0x149)]))===null||_0x2c321a===void 0x0?void 0x0:_0x2c321a[_0x10fd0d(0x164)],_0x3c3eaa;});}catch(_0x58d558){console['log'](_0x39af29(0x168),_0x58d558);}}async[_0x251c81(0x14b)](_0x39d384,_0x17de17){const _0x20f85a=_0x251c81,{title:_0x433933,isSticky:_0x54b79e,groupId:_0x167024,config:_0xf523bc}=_0x39d384,{id:_0x20634f}=_0x17de17['user'],_0x27a60a=await this[_0x20f85a(0x18b)][_0x20f85a(0x181)]({'where':{'id':_0x167024,'userId':_0x20634f}});if(!_0x27a60a)throw new common_1[(_0x20f85a(0x163))](_0x20f85a(0x167),common_1[_0x20f85a(0x157)][_0x20f85a(0x145)]);const {appId:_0x3aa7ef}=_0x27a60a;if(_0x3aa7ef&&!_0x433933)try{const _0x50cb0b=JSON[_0x20f85a(0x16d)](_0xf523bc);if(Number(_0x50cb0b['keyType'])!==0x1)throw new common_1[(_0x20f85a(0x163))](_0x20f85a(0x169),common_1[_0x20f85a(0x157)]['BAD_REQUEST']);}catch(_0x2e031c){}const _0xbb39b={};_0x433933&&(_0xbb39b[_0x20f85a(0x175)]=_0x433933),typeof _0x54b79e!=='undefined'&&(_0xbb39b['isSticky']=_0x54b79e),_0xf523bc&&(_0xbb39b[_0x20f85a(0x17b)]=_0xf523bc);const _0x3e6bc9=await this['chatGroupEntity'][_0x20f85a(0x14b)]({'id':_0x167024},_0xbb39b);if(_0x3e6bc9[_0x20f85a(0x17d)])return!![];else throw new common_1['HttpException'](_0x20f85a(0x152),common_1[_0x20f85a(0x157)]['BAD_REQUEST']);}async[_0x251c81(0x16a)](_0xacf84e,_0x15c1a5){const _0x1f2c3b=_0x251c81,{groupId:_0x42363f}=_0xacf84e,{id:_0x1eb984}=_0x15c1a5['user'],_0x5509d8=await this['chatGroupEntity'][_0x1f2c3b(0x181)]({'where':{'id':_0x42363f,'userId':_0x1eb984}});if(!_0x5509d8)throw new common_1[(_0x1f2c3b(0x163))](_0x1f2c3b(0x15c),common_1[_0x1f2c3b(0x157)][_0x1f2c3b(0x145)]);const _0x48f4aa=await this[_0x1f2c3b(0x18b)][_0x1f2c3b(0x14b)]({'id':_0x42363f},{'isDelete':!![]});if(_0x48f4aa['affected'])return _0x1f2c3b(0x18a);else throw new common_1[(_0x1f2c3b(0x163))]('删除失败!',common_1[_0x1f2c3b(0x157)][_0x1f2c3b(0x145)]);}async['delAll'](_0x3f3203){const _0x91d42f=_0x251c81,{id:_0x5b6580}=_0x3f3203[_0x91d42f(0x17f)],_0x5cde07=await this['chatGroupEntity'][_0x91d42f(0x14b)]({'userId':_0x5b6580,'isSticky':![],'isDelete':![]},{'isDelete':!![]});if(_0x5cde07[_0x91d42f(0x17d)])return'删除成功';else throw new common_1[(_0x91d42f(0x163))](_0x91d42f(0x176),common_1[_0x91d42f(0x157)][_0x91d42f(0x145)]);}async[_0x251c81(0x184)](_0x7d3d0d){const _0xbd3380=_0x251c81;if(!_0x7d3d0d)return;return await this[_0xbd3380(0x18b)][_0xbd3380(0x181)]({'where':{'id':_0x7d3d0d}});}};ChatGroupService=__decorate([(0x0,common_1[_0x251c81(0x17a)])(),__param(0x0,(0x0,typeorm_1[_0x251c81(0x186)])(chatGroup_entity_1[_0x251c81(0x148)])),__param(0x1,(0x0,typeorm_1['InjectRepository'])(app_entity_1[_0x251c81(0x180)])),__metadata(_0x251c81(0x15e),[typeorm_2[_0x251c81(0x16c)],typeorm_2[_0x251c81(0x16c)],models_service_1[_0x251c81(0x18c)]])],ChatGroupService),exports['ChatGroupService']=ChatGroupService;