From 4afb6bbbe8790480bc4e4b86304879e022cf5bbf Mon Sep 17 00:00:00 2001 From: que01 Date: Tue, 22 Sep 2026 11:54:39 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8B=A6=E6=88=AA=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E4=B8=9A=E5=8A=A1=E7=9A=84=E8=BF=87=E6=9C=9F=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/src/main.ts | 8 +++++++- apps/api/test/http.integration.test.js | 9 +++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index c22c998..e72dac4 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -220,6 +220,7 @@ export class PublicInquiryFormController { id, brandId: process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001", isEnabled: true, + OR: [{ offeringId: null }, { offering: { isEnabled: true } }], }, }); if (!form) throw new BadRequestException("咨询表单不存在"); @@ -245,7 +246,12 @@ export class CustomerInquirySubmissionController { } if (identity.role !== "customer") throw new ForbiddenException("无客户权限"); const form = await this.prisma.inquiryForm.findFirst({ - where: { id: body.formId, brandId: identity.brandId, isEnabled: true }, + where: { + id: body.formId, + brandId: identity.brandId, + isEnabled: true, + OR: [{ offeringId: null }, { offering: { isEnabled: true } }], + }, }); if (!form) throw new BadRequestException("咨询表单不存在"); return this.prisma.inquirySubmission.create({ diff --git a/apps/api/test/http.integration.test.js b/apps/api/test/http.integration.test.js index 8d57f65..54726f9 100644 --- a/apps/api/test/http.integration.test.js +++ b/apps/api/test/http.integration.test.js @@ -219,6 +219,15 @@ test("admin can create and version an inquiry form", async () => { }); assert.equal(updated.statusCode, 200); assert.equal(JSON.parse(updated.body).version, 2); + await prisma.offering.update({ where: { id: offering.id }, data: { isEnabled: false } }); + assert.equal((await request(`/public/inquiry-forms/${id}`)).statusCode, 400); + const blockedSubmission = await request("/customer/inquiry-submissions", { + method: "POST", + headers: { authorization: `Bearer ${customerToken}` }, + payload: { formId: id, values: { budget: 1000 } }, + }); + assert.equal(blockedSubmission.statusCode, 400); + await prisma.offering.update({ where: { id: offering.id }, data: { isEnabled: true } }); const publicForm = await request(`/public/inquiry-forms/${id}`); assert.equal(publicForm.statusCode, 200); const publicOffering = await request(`/public/offerings/${offering.id}`);