This commit is contained in:
archer
2023-07-04 15:39:57 +08:00
parent 9bdd5f522d
commit 6e1ef89d65
44 changed files with 213 additions and 1216 deletions

View File

@@ -1,5 +1,5 @@
import { Schema, model, models, Model as MongoModel } from 'mongoose';
import { AppSchema as ModelType } from '@/types/mongoSchema';
import { Schema, model, models, Model } from 'mongoose';
import { AppSchema as AppType } from '@/types/mongoSchema';
import { ChatModelMap, OpenAiChatEnum } from '@/constants/model';
const AppSchema = new Schema({
@@ -105,4 +105,4 @@ try {
console.log(error);
}
export const Model: MongoModel<ModelType> = models['model'] || model('model', AppSchema);
export const App: Model<AppType> = models['model'] || model('model', AppSchema);

View File

@@ -0,0 +1,18 @@
import { Schema, model, models, Model } from 'mongoose';
import { ChatSchema as ChatType } from '@/types/mongoSchema';
import { ChatRoleMap } from '@/constants/chat';
const InstallAppSchema = new Schema({
userId: {
type: Schema.Types.ObjectId,
ref: 'user',
required: true
},
modelId: {
type: Schema.Types.ObjectId,
ref: 'model',
required: true
}
});
export const InstallApp: Model<ChatType> = models['installApp'] || model('chat', InstallAppSchema);

View File

@@ -55,7 +55,7 @@ export async function connectToDatabase(): Promise<void> {
export * from './models/authCode';
export * from './models/chat';
export * from './models/model';
export * from './models/app';
export * from './models/user';
export * from './models/bill';
export * from './models/pay';

View File

@@ -1,7 +1,7 @@
import type { NextApiRequest } from 'next';
import jwt from 'jsonwebtoken';
import Cookie from 'cookie';
import { Chat, Model, OpenApi, User, ShareChat, KB } from '../mongo';
import { Chat, App, OpenApi, User, ShareChat, KB } from '../mongo';
import type { AppSchema } from '@/types/mongoSchema';
import type { ChatItemType } from '@/types/chat';
import mongoose from 'mongoose';
@@ -218,7 +218,7 @@ export const authApp = async ({
reserveDetail?: boolean; // focus reserve detail
}) => {
// 获取 model 数据
const app = await Model.findById<AppSchema>(appId);
const app = await App.findById<AppSchema>(appId);
if (!app) {
return Promise.reject('模型不存在');
}