mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 13:03:50 +00:00

* mongo init * perf: mongo connect * perf: tts perf: whisper and tts peref: tts whisper permission log reabase (#488) * perf: modal * i18n * perf: schema lean * feat: vision model format * perf: tts loading * perf: static data * perf: tts * feat: image * perf: image * perf: upload image and title * perf: image size * doc * perf: color * doc * speaking can not select file * doc
74 lines
1.7 KiB
TypeScript
74 lines
1.7 KiB
TypeScript
import { connectionMongo, type Model } from '../../common/mongo';
|
|
const { Schema, model, models } = connectionMongo;
|
|
import type { OpenApiSchema } from '@fastgpt/global/support/openapi/type';
|
|
import { PRICE_SCALE } from '@fastgpt/global/support/wallet/bill/constants';
|
|
import { formatPrice } from '@fastgpt/global/support/wallet/bill/tools';
|
|
import {
|
|
TeamCollectionName,
|
|
TeamMemberCollectionName
|
|
} from '@fastgpt/global/support/user/team/constant';
|
|
|
|
const OpenApiSchema = new Schema(
|
|
{
|
|
userId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: 'user'
|
|
},
|
|
teamId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: TeamCollectionName,
|
|
required: true
|
|
},
|
|
tmbId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: TeamMemberCollectionName,
|
|
required: true
|
|
},
|
|
apiKey: {
|
|
type: String,
|
|
required: true,
|
|
get: (val: string) => `******${val.substring(val.length - 4)}`
|
|
},
|
|
createTime: {
|
|
type: Date,
|
|
default: () => new Date()
|
|
},
|
|
lastUsedTime: {
|
|
type: Date
|
|
},
|
|
appId: {
|
|
type: String,
|
|
required: false
|
|
},
|
|
name: {
|
|
type: String,
|
|
default: 'Api Key'
|
|
},
|
|
usage: {
|
|
// total usage. value from bill total
|
|
type: Number,
|
|
default: 0,
|
|
get: (val: number) => formatPrice(val)
|
|
},
|
|
limit: {
|
|
expiredTime: {
|
|
type: Date
|
|
},
|
|
credit: {
|
|
// value from user settings
|
|
type: Number,
|
|
default: -1,
|
|
set: (val: number) => val * PRICE_SCALE,
|
|
get: (val: number) => formatPrice(val)
|
|
}
|
|
}
|
|
},
|
|
{
|
|
toObject: { getters: true }
|
|
}
|
|
);
|
|
|
|
export const MongoOpenApi: Model<OpenApiSchema> =
|
|
models['openapi'] || model('openapi', OpenApiSchema);
|
|
MongoOpenApi.syncIndexes();
|