From e2409c08482e02fba62dda357a0ea094b0808736 Mon Sep 17 00:00:00 2001 From: que01 Date: Wed, 23 Sep 2026 12:47:09 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=A4=9A=E5=93=81?= =?UTF-8?q?=E7=89=8C=E6=9E=B6=E6=9E=84=E5=9B=9E=E5=BD=92=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E4=B8=8E=E6=A0=A1=E9=AA=8C=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/src/admin-workspace.controller.ts | 2 +- apps/api/src/modules/admin/admin-config.controller.ts | 2 +- .../customer-inquiry-submission.controller.ts | 11 ++++++----- .../src/modules/public/public-workspace.controller.ts | 6 +++--- apps/api/src/modules/tenant/tenant.controller.ts | 1 - packages/types/src/index.ts | 9 +++++---- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/apps/api/src/admin-workspace.controller.ts b/apps/api/src/admin-workspace.controller.ts index 2731e32..ce2f600 100644 --- a/apps/api/src/admin-workspace.controller.ts +++ b/apps/api/src/admin-workspace.controller.ts @@ -237,7 +237,7 @@ class AdminWorkspaceController { kind: sortOrder === 3 ? "service" : "product", name: item[0]!, summary: item[1]!, - config: { categoryKey: item[2]! } as Prisma.InputJsonValue, + config: { categoryKey: item[2]! }, sortOrder, isEnabled: true, })), diff --git a/apps/api/src/modules/admin/admin-config.controller.ts b/apps/api/src/modules/admin/admin-config.controller.ts index e8cc429..064bb5b 100644 --- a/apps/api/src/modules/admin/admin-config.controller.ts +++ b/apps/api/src/modules/admin/admin-config.controller.ts @@ -141,7 +141,7 @@ export class AdminConfigController { config: { ...config, visualTemplateKey: previous.visualTemplateKey, - } as Prisma.InputJsonValue, + }, }, }), ...(installation diff --git a/apps/api/src/modules/customer/customer-inquiry-submission.controller.ts b/apps/api/src/modules/customer/customer-inquiry-submission.controller.ts index ad2144e..c09f3c8 100644 --- a/apps/api/src/modules/customer/customer-inquiry-submission.controller.ts +++ b/apps/api/src/modules/customer/customer-inquiry-submission.controller.ts @@ -106,15 +106,16 @@ export class CustomerInquirySubmissionController { : []; for (const field of fields) { const key = typeof field.key === "string" ? field.key : ""; + const label = typeof field.label === "string" ? field.label : key; const value = body.values[key]; + const textValue = typeof value === "string" || typeof value === "number" ? String(value) : ""; const empty = value === undefined || value === null || value === ""; - if (field.required === true && empty) - throw new BadRequestException(`${String(field.label ?? key)}不能为空`); + if (field.required === true && empty) throw new BadRequestException(`${label}不能为空`); if (empty) continue; - if ((field.type === "phone" || field.type === "tel") && !/^1\d{10}$/.test(String(value))) - throw new BadRequestException(`${String(field.label ?? key)}格式不正确`); + if ((field.type === "phone" || field.type === "tel") && !/^1\d{10}$/.test(textValue)) + throw new BadRequestException(`${label}格式不正确`); if (field.type === "number" && !Number.isFinite(Number(value))) - throw new BadRequestException(`${String(field.label ?? key)}必须是数字`); + throw new BadRequestException(`${label}必须是数字`); } const allowedKeys = new Set(fields.map((field) => String(field.key))); const values = Object.fromEntries( diff --git a/apps/api/src/modules/public/public-workspace.controller.ts b/apps/api/src/modules/public/public-workspace.controller.ts index de3d89f..ab90ee3 100644 --- a/apps/api/src/modules/public/public-workspace.controller.ts +++ b/apps/api/src/modules/public/public-workspace.controller.ts @@ -1,4 +1,4 @@ -import { BadRequestException, Controller, Get, NotFoundException, Query } from "@nestjs/common"; +import { Controller, Get, NotFoundException, Query } from "@nestjs/common"; import { Prisma } from "@prisma/client"; import { PrismaService } from "../../prisma.service.js"; import { @@ -173,7 +173,7 @@ export class PublicWorkspaceController { const inquiryForm = inquiryForms[0] ?? null; const runtimeWorkspace: RuntimeWorkspace = { schemaVersion: "1.0.0", - brand: (brand ?? {}) as Record, + brand: brand ?? {}, navigation: { tabs: [ { key: "home", label: "首页", page: "pages/index/index" }, @@ -242,7 +242,7 @@ export class PublicWorkspaceController { : {}; } private jsonArray(value: unknown): Prisma.JsonValue[] { - return Array.isArray(value) ? value : []; + return Array.isArray(value) ? (value as Prisma.JsonValue[]) : []; } private moduleType(value: string): RuntimeModule["type"] { const known: RuntimeModule["type"][] = [ diff --git a/apps/api/src/modules/tenant/tenant.controller.ts b/apps/api/src/modules/tenant/tenant.controller.ts index d49a4a0..96179f8 100644 --- a/apps/api/src/modules/tenant/tenant.controller.ts +++ b/apps/api/src/modules/tenant/tenant.controller.ts @@ -1,5 +1,4 @@ import { - Body, Controller, ForbiddenException, Get, diff --git a/packages/types/src/index.ts b/packages/types/src/index.ts index 82d1204..d3b6495 100644 --- a/packages/types/src/index.ts +++ b/packages/types/src/index.ts @@ -4,10 +4,11 @@ export type ContactPreference = "wechat" | "phone" | "none"; export type FulfillmentType = "pickup" | "delivery"; export type OrderStatus = BookingStatus; export type BrandTemplateKey = "food" | "personal" | "doors"; -export const BRAND_TEMPLATE = { FOOD: "food", PERSONAL: "personal" } as const satisfies Record< - Uppercase, - BrandTemplateKey ->; +export const BRAND_TEMPLATE = { + FOOD: "food", + PERSONAL: "personal", + DOORS: "doors", +} as const satisfies Record, BrandTemplateKey>; export const HTTP_STATUS = { OK: 200,