mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-27 08:25:07 +00:00

* feat: sync org from wecom, pref: member list pagination (#3549) * feat: sync org * chore: fe * chore: loading * chore: type * pref: team member list change to pagination. Edit a sort of list apis. * feat: member update avatar * chore: user avatar move to tmb * chore: init scripts move user avatar * chore: sourceMember * fix: list api sourceMember * fix: member sync * fix: pagination * chore: adjust code * chore: move changeOwner to pro * chore: init v4819 script * chore: adjust code * chore: UserBox * perf: scroll page code * perf: list data * docs:更新用户答疑 (#3576) * docs: add custom uid docs (#3572) * fix: pagination bug (#3577) * 4.8.19 test (#3584) * faet: dataset search filter * fix: scroll page * fix: collection list api old version (#3591) * fix: collection list api format * fix: type error of addSourceMemeber * fix: scroll fetch (#3592) * fix: yuque dataset file folder can enter (#3593) * perf: load members;perf: yuque load;fix: workflow llm params cannot close (#3594) * chat openapi doc * feat: dataset openapi doc * perf: load members * perf: member load code * perf: yuque load * fix: workflow llm params cannot close * fix: api dataset reference tag preview (#3600) * perf: doc * feat: chat page config * fix: http parse (#3634) * update doc * fix: http parse * fix code run node reset template (#3633) Co-authored-by: Archer <545436317@qq.com> * docs:faq (#3627) * docs:faq * docsFix * perf: sleep plugin * fix: selector --------- Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com> Co-authored-by: Jiangween <145003935+Jiangween@users.noreply.github.com> Co-authored-by: heheer <heheer@sealos.io>
75 lines
1.7 KiB
TypeScript
75 lines
1.7 KiB
TypeScript
import { TeamCollectionName } from '@fastgpt/global/support/user/team/constant';
|
|
import { OrgCollectionName } from '@fastgpt/global/support/user/team/org/constant';
|
|
import type { OrgSchemaType } from '@fastgpt/global/support/user/team/org/type';
|
|
import { connectionMongo, getMongoModel } from '../../../common/mongo';
|
|
import { OrgMemberCollectionName } from './orgMemberSchema';
|
|
import { getNanoid } from '@fastgpt/global/common/string/tools';
|
|
const { Schema } = connectionMongo;
|
|
|
|
export const OrgSchema = new Schema(
|
|
{
|
|
teamId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: TeamCollectionName,
|
|
required: true
|
|
},
|
|
pathId: {
|
|
// path id, only used for path
|
|
type: String,
|
|
required: true,
|
|
default: () => getNanoid()
|
|
},
|
|
path: {
|
|
type: String,
|
|
required: function (this: OrgSchemaType) {
|
|
return typeof this.path !== 'string';
|
|
} // allow empty string, but not null
|
|
},
|
|
name: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
avatar: String,
|
|
description: String,
|
|
updateTime: {
|
|
type: Date,
|
|
default: () => new Date()
|
|
}
|
|
},
|
|
{
|
|
// Auto update updateTime
|
|
timestamps: {
|
|
updatedAt: 'updateTime'
|
|
}
|
|
}
|
|
);
|
|
|
|
OrgSchema.virtual('members', {
|
|
ref: OrgMemberCollectionName,
|
|
localField: '_id',
|
|
foreignField: 'orgId',
|
|
match: function (this: OrgSchemaType) {
|
|
return { teamId: this.teamId };
|
|
}
|
|
});
|
|
|
|
try {
|
|
OrgSchema.index({
|
|
teamId: 1,
|
|
path: 1
|
|
});
|
|
OrgSchema.index(
|
|
{
|
|
teamId: 1,
|
|
pathId: 1
|
|
},
|
|
{
|
|
unique: true
|
|
}
|
|
);
|
|
} catch (error) {
|
|
console.log(error);
|
|
}
|
|
|
|
export const MongoOrgModel = getMongoModel<OrgSchemaType>(OrgCollectionName, OrgSchema);
|