From 46cc1fec80a5c41f0840493108c14413e1e9bb0e Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Fri, 27 Dec 2024 19:01:20 +0800 Subject: [PATCH] fix: app version require tmbId --- projects/app/src/pages/api/admin/initv485.ts | 2 ++ projects/app/src/pages/api/core/app/create.ts | 10 ++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/projects/app/src/pages/api/admin/initv485.ts b/projects/app/src/pages/api/admin/initv485.ts index e7a371a42630..5aac3723e610 100644 --- a/projects/app/src/pages/api/admin/initv485.ts +++ b/projects/app/src/pages/api/admin/initv485.ts @@ -94,6 +94,7 @@ async function initHttp(teamId?: string): Promise { await MongoAppVersion.create( [ { + tmbId: plugin.tmbId, appId: newPluginId, nodes: item.modules, edges: item.edges @@ -166,6 +167,7 @@ async function initPlugin(teamId?: string): Promise { await MongoAppVersion.create( [ { + tmbId: plugin.tmbId, appId: newPluginId, nodes: plugin.modules, edges: plugin.edges diff --git a/projects/app/src/pages/api/core/app/create.ts b/projects/app/src/pages/api/core/app/create.ts index bacc1d7b8197..005b05965e5b 100644 --- a/projects/app/src/pages/api/core/app/create.ts +++ b/projects/app/src/pages/api/core/app/create.ts @@ -45,8 +45,9 @@ async function handler(req: ApiRequestProps) { // 上限校验 await checkTeamAppLimit(teamId); - const tmb = await MongoTeamMember.findById({ _id: tmbId }); - const user = await MongoUser.findById({ _id: tmb?.userId }); + const tmb = await MongoTeamMember.findById({ _id: tmbId }, 'userId').populate<{ + user: { avatar: string; username: string }; + }>('user', 'avatar username'); // 创建app const appId = await onCreateApp({ @@ -59,8 +60,8 @@ async function handler(req: ApiRequestProps) { chatConfig, teamId, tmbId, - userAvatar: user?.avatar, - username: user?.username + userAvatar: tmb?.user?.avatar, + username: tmb?.user?.username }); pushTrack.createApp({ @@ -132,6 +133,7 @@ export const onCreateApp = async ({ await MongoAppVersion.create( [ { + tmbId, appId, nodes: modules, edges,