mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-22 20:37:48 +00:00
perf: member group (#4324)
* sync collection * remove lock * perf: member group
This commit is contained in:
4
packages/global/support/permission/memberGroup/api.d.ts
vendored
Normal file
4
packages/global/support/permission/memberGroup/api.d.ts
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
export type GetGroupListBody = {
|
||||
searchKey?: string;
|
||||
withMembers?: boolean;
|
||||
};
|
@@ -1,6 +1,7 @@
|
||||
import { TeamMemberItemType } from 'support/user/team/type';
|
||||
import { TeamPermission } from '../user/controller';
|
||||
import { GroupMemberRole } from './constant';
|
||||
import { Permission } from '../controller';
|
||||
|
||||
type MemberGroupSchemaType = {
|
||||
_id: string;
|
||||
@@ -16,23 +17,25 @@ type GroupMemberSchemaType = {
|
||||
role: `${GroupMemberRole}`;
|
||||
};
|
||||
|
||||
type MemberGroupType = MemberGroupSchemaType & {
|
||||
members: {
|
||||
tmbId: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
}[];
|
||||
count: number;
|
||||
owner: {
|
||||
tmbId: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
};
|
||||
canEdit: boolean;
|
||||
type MemberGroupListItemType<T extends boolean | undefined> = MemberGroupSchemaType & {
|
||||
members: T extends true
|
||||
? {
|
||||
tmbId: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
}[]
|
||||
: undefined;
|
||||
count: T extends true ? number : undefined;
|
||||
owner?: T extends true
|
||||
? {
|
||||
tmbId: string;
|
||||
name: string;
|
||||
avatar: string;
|
||||
}
|
||||
: undefined;
|
||||
permission: T extends true ? Permission : undefined;
|
||||
};
|
||||
|
||||
type MemberGroupListType = MemberGroupType[];
|
||||
|
||||
type GroupMemberItemType = {
|
||||
tmbId: string;
|
||||
name: string;
|
||||
|
5
packages/global/support/user/api.d.ts
vendored
5
packages/global/support/user/api.d.ts
vendored
@@ -1,4 +1,7 @@
|
||||
import { MemberGroupSchemaType, MemberGroupType } from 'support/permission/memberGroup/type';
|
||||
import {
|
||||
MemberGroupSchemaType,
|
||||
MemberGroupListItemType
|
||||
} from 'support/permission/memberGroup/type';
|
||||
import { OAuthEnum } from './constant';
|
||||
import { TrackRegisterParams } from './login/api';
|
||||
import { TeamMemberStatusEnum } from './team/constant';
|
||||
|
@@ -55,6 +55,14 @@ async function getTeamMember(match: Record<string, any>): Promise<TeamTmbItemTyp
|
||||
};
|
||||
}
|
||||
|
||||
export const getTeamOwner = async (teamId: string) => {
|
||||
const tmb = await MongoTeamMember.findOne({
|
||||
teamId,
|
||||
role: TeamMemberRoleEnum.owner
|
||||
}).lean();
|
||||
return tmb;
|
||||
};
|
||||
|
||||
export async function getTmbInfoByTmbId({ tmbId }: { tmbId: string }) {
|
||||
if (!tmbId) {
|
||||
return Promise.reject('tmbId or userId is required');
|
||||
|
Reference in New Issue
Block a user