From f790e7d7071e345e477afa78a10cce47c126ec9c Mon Sep 17 00:00:00 2001 From: que01 Date: Wed, 23 Sep 2026 02:17:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=9A=94=E7=A6=BB=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E4=B8=8E=E4=B8=9A=E5=8A=A1=E6=8F=90=E4=BE=9B=E9=A1=B9=E5=93=81?= =?UTF-8?q?=E7=89=8C=E4=B8=8A=E4=B8=8B=E6=96=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/src/admin-workspace.controller.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/apps/api/src/admin-workspace.controller.ts b/apps/api/src/admin-workspace.controller.ts index 64409ba..9f036e3 100644 --- a/apps/api/src/admin-workspace.controller.ts +++ b/apps/api/src/admin-workspace.controller.ts @@ -43,9 +43,9 @@ class AdminWorkspaceController { @Get("offerings") async listOfferings(@Req() request: FastifyRequest): Promise { - this.requireAdmin(request); + const brandId = this.requireAdmin(request).brandId; const items = await this.prisma.offering.findMany({ - where: { brandId: this.brandId() }, + where: { brandId }, orderBy: { sortOrder: "asc" }, }); return items.map((item) => { @@ -64,7 +64,7 @@ class AdminWorkspaceController { @Req() request: FastifyRequest, @Body() body: CreateOfferingDto, ): Promise { - this.requireAdmin(request); + const brandId = this.requireAdmin(request).brandId; const { config, sections, media, cta, ...fields } = body; const configValue = { ...(config ?? {}), @@ -77,7 +77,7 @@ class AdminWorkspaceController { return this.prisma.offering.create({ data: { ...fields, - brandId: this.brandId(), + brandId, config: configValue as Prisma.InputJsonValue, }, }); @@ -89,8 +89,8 @@ class AdminWorkspaceController { @Param("id") id: string, @Body() body: UpdateOfferingDto, ): Promise { - this.requireAdmin(request); - const item = await this.prisma.offering.findFirst({ where: { id, brandId: this.brandId() } }); + const brandId = this.requireAdmin(request).brandId; + const item = await this.prisma.offering.findFirst({ where: { id, brandId } }); if (!item) throw new BadRequestException("业务提供项不存在"); const { config, sections, media, cta, ...fields } = body; const configValue = { @@ -119,8 +119,8 @@ class AdminWorkspaceController { @Delete("offerings/:id") async deleteOffering(@Req() request: FastifyRequest, @Param("id") id: string): Promise { - this.requireAdmin(request); - const item = await this.prisma.offering.findFirst({ where: { id, brandId: this.brandId() } }); + const brandId = this.requireAdmin(request).brandId; + const item = await this.prisma.offering.findFirst({ where: { id, brandId } }); if (!item) throw new BadRequestException("业务提供项不存在"); const [forms, bookings, items] = await Promise.all([ this.prisma.inquiryForm.count({ where: { offeringId: id } }), @@ -336,19 +336,19 @@ class AdminWorkspaceController { @Get("template/preview") async previewTemplate(@Req() request: FastifyRequest): Promise { this.requireAdmin(request); - return this.templateWorkspace.preview(this.brandId()); + return this.templateWorkspace.preview(this.requireAdmin(request).brandId); } @Post("template/upgrade") async upgradeTemplate(@Req() request: FastifyRequest): Promise { this.requireAdmin(request); - return this.templateWorkspace.upgrade(this.brandId()); + return this.templateWorkspace.upgrade(this.requireAdmin(request).brandId); } @Post("template/rollback") async rollbackTemplate(@Req() request: FastifyRequest): Promise { this.requireAdmin(request); - return this.templateWorkspace.rollback(this.brandId()); + return this.templateWorkspace.rollback(this.requireAdmin(request).brandId); } @Patch("modules/:id")