mirror of
https://github.com/vastxie/99AI.git
synced 2025-11-13 12:13:43 +08:00
v3.7.0
This commit is contained in:
25
dist/modules/chatGroup/chatGroup.service.js
vendored
25
dist/modules/chatGroup/chatGroup.service.js
vendored
@@ -28,7 +28,7 @@ let ChatGroupService = class ChatGroupService {
|
||||
async create(body, req) {
|
||||
const { id } = req.user;
|
||||
const { appId, modelConfig: bodyModelConfig } = body;
|
||||
let modelConfig = bodyModelConfig || await this.modelsService.getBaseConfig(appId);
|
||||
let modelConfig = bodyModelConfig || (await this.modelsService.getBaseConfig());
|
||||
if (!modelConfig) {
|
||||
throw new common_1.HttpException('管理员未配置任何AI模型、请先联系管理员开通聊天模型配置!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
@@ -44,7 +44,7 @@ let ChatGroupService = class ChatGroupService {
|
||||
isGPTs,
|
||||
isFixedModel,
|
||||
modelAvatar: coverImg,
|
||||
modelName: name
|
||||
modelName: name,
|
||||
});
|
||||
if (isGPTs === 1 || isFixedModel === 1) {
|
||||
const appModelKey = await this.modelsService.getCurrentModelKeyInfo(isFixedModel === 1 ? appModel : 'gpts');
|
||||
@@ -52,7 +52,7 @@ let ChatGroupService = class ChatGroupService {
|
||||
deductType: appModelKey.deductType,
|
||||
deduct: appModelKey.deduct,
|
||||
model: appModel,
|
||||
isFileUpload: appModelKey.isFileUpload
|
||||
isFileUpload: appModelKey.isFileUpload,
|
||||
});
|
||||
}
|
||||
if (![1, 3, 4, 5].includes(status)) {
|
||||
@@ -69,13 +69,16 @@ let ChatGroupService = class ChatGroupService {
|
||||
try {
|
||||
const { id } = req.user;
|
||||
const params = { userId: id, isDelete: false };
|
||||
const res = await this.chatGroupEntity.find({ where: params, order: { isSticky: 'DESC', updatedAt: 'DESC' } });
|
||||
const res = await this.chatGroupEntity.find({
|
||||
where: params,
|
||||
order: { isSticky: 'DESC', updatedAt: 'DESC' },
|
||||
});
|
||||
return res;
|
||||
const appIds = res.filter(t => t.appId).map(t => t.appId);
|
||||
const appIds = res.filter((t) => t.appId).map((t) => t.appId);
|
||||
const appInfos = await this.appEntity.find({ where: { id: (0, typeorm_2.In)(appIds) } });
|
||||
return res.map((item) => {
|
||||
var _a;
|
||||
item.appLogo = (_a = appInfos.find(t => t.id === item.appId)) === null || _a === void 0 ? void 0 : _a.coverImg;
|
||||
item.appLogo = (_a = appInfos.find((t) => t.id === item.appId)) === null || _a === void 0 ? void 0 : _a.coverImg;
|
||||
return item;
|
||||
});
|
||||
}
|
||||
@@ -86,7 +89,9 @@ let ChatGroupService = class ChatGroupService {
|
||||
async update(body, req) {
|
||||
const { title, isSticky, groupId, config } = body;
|
||||
const { id } = req.user;
|
||||
const g = await this.chatGroupEntity.findOne({ where: { id: groupId, userId: id } });
|
||||
const g = await this.chatGroupEntity.findOne({
|
||||
where: { id: groupId, userId: id },
|
||||
});
|
||||
if (!g) {
|
||||
throw new common_1.HttpException('请先选择一个对话或者新加一个对话再操作!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
@@ -115,13 +120,15 @@ let ChatGroupService = class ChatGroupService {
|
||||
}
|
||||
async updateTime(groupId) {
|
||||
await this.chatGroupEntity.update(groupId, {
|
||||
updatedAt: new Date()
|
||||
updatedAt: new Date(),
|
||||
});
|
||||
}
|
||||
async del(body, req) {
|
||||
const { groupId } = body;
|
||||
const { id } = req.user;
|
||||
const g = await this.chatGroupEntity.findOne({ where: { id: groupId, userId: id } });
|
||||
const g = await this.chatGroupEntity.findOne({
|
||||
where: { id: groupId, userId: id },
|
||||
});
|
||||
if (!g) {
|
||||
throw new common_1.HttpException('非法操作、您在删除一个非法资源!', common_1.HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user