From 888a50442397ab25719e0cf226978cb8d27503f2 Mon Sep 17 00:00:00 2001 From: que01 Date: Mon, 21 Sep 2026 20:08:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8=E4=B8=9A=E5=8A=A1=E6=8F=90?= =?UTF-8?q?=E4=BE=9B=E9=A1=B9=E5=85=AC=E5=BC=80=E8=AF=A6=E6=83=85=E4=B8=AD?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=92=A8=E8=AF=A2=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/src/main.ts | 14 ++++++++++++++ apps/api/test/http.integration.test.js | 6 ++++++ 2 files changed, 20 insertions(+) diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts index 02bd94b..ab8496d 100644 --- a/apps/api/src/main.ts +++ b/apps/api/src/main.ts @@ -170,6 +170,13 @@ export class PublicOfferingController { const items = await this.prisma.offering.findMany({ where: { brandId, isEnabled: true }, orderBy: { sortOrder: "asc" }, + include: { + inquiryForms: { + where: { isEnabled: true }, + orderBy: { updatedAt: "desc" }, + select: { id: true, name: true, purpose: true, targetType: true, version: true }, + }, + }, }); return items.map((item) => this.present(item)); } @@ -181,6 +188,13 @@ export class PublicOfferingController { brandId: process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001", isEnabled: true, }, + include: { + inquiryForms: { + where: { isEnabled: true }, + orderBy: { updatedAt: "desc" }, + select: { id: true, name: true, purpose: true, targetType: true, version: true }, + }, + }, }); if (!item) throw new BadRequestException("业务提供项不存在"); return this.present(item); diff --git a/apps/api/test/http.integration.test.js b/apps/api/test/http.integration.test.js index cba594e..c6d9cf1 100644 --- a/apps/api/test/http.integration.test.js +++ b/apps/api/test/http.integration.test.js @@ -198,11 +198,14 @@ test("admin can create and version an inquiry form", async () => { payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD }, }); const token = JSON.parse(login.body).token; + const offering = await prisma.offering.findFirst({ where: { brandId, isEnabled: true } }); + assert.ok(offering); const created = await request("/admin/workspace/forms", { method: "POST", headers: { authorization: `Bearer ${token}` }, payload: { name: "品牌合作咨询", + offeringId: offering.id, fieldsSnapshot: [{ key: "project", type: "textarea", label: "项目背景", required: true }], }, }); @@ -218,6 +221,9 @@ test("admin can create and version an inquiry form", async () => { assert.equal(JSON.parse(updated.body).version, 2); const publicForm = await request(`/public/inquiry-forms/${id}`); assert.equal(publicForm.statusCode, 200); + const publicOffering = await request(`/public/offerings/${offering.id}`); + assert.equal(publicOffering.statusCode, 200); + assert.equal(JSON.parse(publicOffering.body).inquiryForms[0].id, id); const publicWorkspace = await request("/public/workspace"); assert.equal(publicWorkspace.statusCode, 200); assert.equal(JSON.parse(publicWorkspace.body).inquiryForm.id, id);