Skip to content

Commit

Permalink
perf: user schema
Browse files Browse the repository at this point in the history
  • Loading branch information
c121914yu committed Mar 24, 2024
1 parent 5561ae7 commit eab3fae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 3 additions & 2 deletions packages/global/support/user/type.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import { TeamItemType } from './team/type';
export type UserModelSchema = {
_id: string;
username: string;
email?: string;
phonePrefix?: number;
phone?: string;
password: string;
avatar: string;
balance: number;
promotionRate: number;
inviterId?: string;
openaiKey: string;
Expand All @@ -24,7 +26,6 @@ export type UserType = {
_id: string;
username: string;
avatar: string;
balance: number;
timezone: string;
promotionRate: UserModelSchema['promotionRate'];
openaiAccount: UserModelSchema['openaiAccount'];
Expand Down
14 changes: 9 additions & 5 deletions packages/service/support/user/schema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { connectionMongo, type Model } from '../../common/mongo';
const { Schema, model, models } = connectionMongo;
import { hashStr } from '@fastgpt/global/common/string/tools';
import { PRICE_SCALE } from '@fastgpt/global/support/wallet/constants';
import type { UserModelSchema } from '@fastgpt/global/support/user/type';
import { UserStatusEnum, userStatusMap } from '@fastgpt/global/support/user/constant';

Expand All @@ -19,6 +18,15 @@ const UserSchema = new Schema({
required: true,
unique: true // 唯一
},
email: {
type: String
},
phonePrefix: {
type: Number
},
phone: {
type: String
},
password: {
type: String,
required: true,
Expand All @@ -34,10 +42,6 @@ const UserSchema = new Schema({
type: String,
default: '/icon/human.svg'
},
balance: {
type: Number,
default: 2 * PRICE_SCALE
},
inviterId: {
// 谁邀请注册的
type: Schema.Types.ObjectId,
Expand Down

0 comments on commit eab3fae

Please sign in to comment.