Revert "sub plan page (#885)" (#886)

This reverts commit 443ad37b6a.
This commit is contained in:
Archer
2024-02-23 17:48:15 +08:00
committed by GitHub
parent 443ad37b6a
commit fd9b6291af
246 changed files with 4281 additions and 6286 deletions

View File

@@ -19,15 +19,14 @@ export async function authOpenApiKey({ apikey }: { apikey: string }) {
// auth limit
// @ts-ignore
if (global.feConfigs?.isPlus) {
await POST('/support/openapi/authLimit', {
openApi: openApi.toObject()
} as AuthOpenApiLimitProps);
await POST('/support/openapi/authLimit', { openApi } as AuthOpenApiLimitProps);
}
updateApiKeyUsedTime(openApi._id);
return {
apikey,
userId: String(openApi.userId),
teamId: String(openApi.teamId),
tmbId: String(openApi.tmbId),
appId: openApi.appId || ''

View File

@@ -1,6 +1,8 @@
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 { formatStorePrice2Read } from '@fastgpt/global/support/wallet/bill/tools';
import {
TeamCollectionName,
TeamMemberCollectionName
@@ -8,6 +10,10 @@ import {
const OpenApiSchema = new Schema(
{
userId: {
type: Schema.Types.ObjectId,
ref: 'user'
},
teamId: {
type: Schema.Types.ObjectId,
ref: TeamCollectionName,
@@ -38,17 +44,22 @@ const OpenApiSchema = new Schema(
type: String,
default: 'Api Key'
},
usagePoints: {
usage: {
// total usage. value from bill total
type: Number,
default: 0
default: 0,
get: (val: number) => formatStorePrice2Read(val)
},
limit: {
expiredTime: {
type: Date
},
maxUsagePoints: {
credit: {
// value from user settings
type: Number,
default: -1
default: -1,
set: (val: number) => val * PRICE_SCALE,
get: (val: number) => formatStorePrice2Read(val)
}
}
},

View File

@@ -8,21 +8,15 @@ export function updateApiKeyUsedTime(id: string) {
});
}
export function updateApiKeyUsage({
apikey,
totalPoints
}: {
apikey: string;
totalPoints: number;
}) {
export function updateApiKeyUsage({ apikey, usage }: { apikey: string; usage: number }) {
MongoOpenApi.findOneAndUpdate(
{ apiKey: apikey },
{
$inc: {
usagePoints: totalPoints
usage
}
}
).catch((err) => {
console.log('update apiKey totalPoints error', err);
console.log('update apiKey usage error', err);
});
}