fix: 拦截禁用业务的过期提交

This commit is contained in:
que01 committed 2026-09-22 11:54:39 +08:00
1 parent 7821c0c98c
commit 4afb6bbbe8
2 files changed
+16 -1

No files matched your search

+7 -1
View File
@@ -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({
+9
View File
@@ -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}`);