mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-30 02:12:38 +00:00
feat: admin add user
This commit is contained in:
@@ -21,22 +21,39 @@ mongoose
|
||||
.then(() => console.log('Connected to MongoDB successfully!'))
|
||||
.catch((err) => console.log(`Error connecting to MongoDB: ${err}`));
|
||||
|
||||
const userSchema = new mongoose.Schema({
|
||||
_id: mongoose.Schema.Types.ObjectId,
|
||||
username: String,
|
||||
password: String,
|
||||
balance: Number,
|
||||
promotion: {
|
||||
rate: Number
|
||||
const UserSchema = new mongoose.Schema({
|
||||
username: {
|
||||
type: String,
|
||||
required: true,
|
||||
unique: true
|
||||
},
|
||||
openaiKey: String,
|
||||
avatar: String,
|
||||
createTime: Date
|
||||
password: {
|
||||
type: String,
|
||||
required: true,
|
||||
select: false
|
||||
},
|
||||
createTime: {
|
||||
type: Date,
|
||||
default: () => new Date()
|
||||
},
|
||||
avatar: {
|
||||
type: String,
|
||||
default: '/icon/human.png'
|
||||
},
|
||||
balance: {
|
||||
type: Number,
|
||||
default: 0
|
||||
},
|
||||
limit: {
|
||||
exportKbTime: {
|
||||
// Every half hour
|
||||
type: Date
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 新增: 定义 pays 模型
|
||||
const paySchema = new mongoose.Schema({
|
||||
_id: mongoose.Schema.Types.ObjectId,
|
||||
userId: mongoose.Schema.Types.ObjectId,
|
||||
price: Number,
|
||||
orderId: String,
|
||||
@@ -47,7 +64,6 @@ const paySchema = new mongoose.Schema({
|
||||
|
||||
// 新增: 定义 kb 模型
|
||||
const kbSchema = new mongoose.Schema({
|
||||
_id: mongoose.Schema.Types.ObjectId,
|
||||
userId: mongoose.Schema.Types.ObjectId,
|
||||
avatar: String,
|
||||
name: String,
|
||||
@@ -98,8 +114,8 @@ const SystemSchema = new mongoose.Schema({
|
||||
}
|
||||
});
|
||||
|
||||
export const App = mongoose.models['app'] || mongoose.model('app', appSchema);
|
||||
export const App = mongoose.models['model'] || mongoose.model('model', appSchema);
|
||||
export const Kb = mongoose.models['kb'] || mongoose.model('kb', kbSchema);
|
||||
export const User = mongoose.models['user'] || mongoose.model('user', userSchema);
|
||||
export const User = mongoose.models['user'] || mongoose.model('user', UserSchema);
|
||||
export const Pay = mongoose.models['pay'] || mongoose.model('pay', paySchema);
|
||||
export const System = mongoose.models['system'] || mongoose.model('system', SystemSchema);
|
||||
|
Reference in New Issue
Block a user