perf: 账号api结构
This commit is contained in:
@@ -19,6 +19,10 @@ const UserSchema = new Schema({
|
||||
type: Number,
|
||||
default: 0.5 * PRICE_SCALE
|
||||
},
|
||||
openaiKey: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
accounts: [
|
||||
{
|
||||
type: {
|
||||
|
||||
@@ -12,7 +12,7 @@ import { pushGenerateVectorBill } from '../events/pushBill';
|
||||
export const getUserApiOpenai = async (userId: string) => {
|
||||
const user = await User.findById(userId);
|
||||
|
||||
const userApiKey = user?.accounts?.find((item: any) => item.type === 'openai')?.value;
|
||||
const userApiKey = user?.openaiKey;
|
||||
|
||||
if (!userApiKey) {
|
||||
return Promise.reject('缺少ApiKey, 无法请求');
|
||||
@@ -35,7 +35,7 @@ export const getOpenApiKey = async (userId: string) => {
|
||||
});
|
||||
}
|
||||
|
||||
const userApiKey = user?.accounts?.find((item: any) => item.type === 'openai')?.value;
|
||||
const userApiKey = user?.openaiKey;
|
||||
|
||||
// 有自己的key
|
||||
if (userApiKey) {
|
||||
|
||||
Reference in New Issue
Block a user