refactor: org pathId (#3516)

This commit is contained in:
a.e.
2025-01-03 09:53:53 +08:00
committed by archer
parent d24d29ac48
commit a401d4d612
6 changed files with 33 additions and 14 deletions

View File

@@ -3,6 +3,7 @@ import type { OrgSchemaType } from '@fastgpt/global/support/user/team/org/type';
import type { ClientSession } from 'mongoose';
import { MongoOrgModel } from './orgSchema';
import { MongoOrgMemberModel } from './orgMemberSchema';
import { getChildrenPath } from '@fastgpt/global/support/user/team/org/constant';
export const getOrgsByTmbId = async ({ teamId, tmbId }: { teamId: string; tmbId: string }) =>
MongoOrgMemberModel.find({ teamId, tmbId }, 'orgId').lean();
@@ -42,7 +43,7 @@ export const getChildrenByOrg = async ({
teamId: string;
session?: ClientSession;
}) => {
return MongoOrgModel.find({ teamId, path: { $regex: `^${org.path}/${org._id}` } }, undefined, {
return MongoOrgModel.find({ teamId, path: { $regex: `^${getChildrenPath(org)}` } }, undefined, {
session
}).lean();
};