mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 05:12:39 +00:00

* chore: purge old permission - remove useless role of teamMember - Cleanup auth apis' Props and Return type Definitions * chore: a better way of RequireAtLeastOne Signed-off-by: Finley Ge <m13203533462@163.com> --------- Signed-off-by: Finley Ge <m13203533462@163.com>
56 lines
1.2 KiB
TypeScript
56 lines
1.2 KiB
TypeScript
import { connectionMongo, getMongoModel } from '../../../common/mongo';
|
|
const { Schema } = connectionMongo;
|
|
import { TeamMemberSchema as TeamMemberType } from '@fastgpt/global/support/user/team/type.d';
|
|
import { userCollectionName } from '../../user/schema';
|
|
import {
|
|
TeamMemberRoleMap,
|
|
TeamMemberStatusMap,
|
|
TeamMemberCollectionName,
|
|
TeamCollectionName
|
|
} from '@fastgpt/global/support/user/team/constant';
|
|
|
|
const TeamMemberSchema = new Schema({
|
|
teamId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: TeamCollectionName,
|
|
required: true
|
|
},
|
|
userId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: userCollectionName,
|
|
required: true
|
|
},
|
|
name: {
|
|
type: String,
|
|
default: 'Member'
|
|
},
|
|
role: {
|
|
type: String,
|
|
enum: Object.keys(TeamMemberRoleMap)
|
|
},
|
|
status: {
|
|
type: String,
|
|
enum: Object.keys(TeamMemberStatusMap)
|
|
},
|
|
createTime: {
|
|
type: Date,
|
|
default: () => new Date()
|
|
},
|
|
defaultTeam: {
|
|
type: Boolean,
|
|
default: false
|
|
}
|
|
});
|
|
|
|
try {
|
|
TeamMemberSchema.index({ teamId: 1 }, { background: true });
|
|
TeamMemberSchema.index({ userId: 1 }, { background: true });
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
|
|
export const MongoTeamMember = getMongoModel<TeamMemberType>(
|
|
TeamMemberCollectionName,
|
|
TeamMemberSchema
|
|
);
|