fix: 拦截禁用业务的过期提交
This commit is contained in:
1 parent
7821c0c98c
commit
4afb6bbbe8
2 files changed
+16
-1
No files matched your search
@@ -220,6 +220,7 @@ export class PublicInquiryFormController {
|
|||||||
id,
|
id,
|
||||||
brandId: process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001",
|
brandId: process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001",
|
||||||
isEnabled: true,
|
isEnabled: true,
|
||||||
|
OR: [{ offeringId: null }, { offering: { isEnabled: true } }],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (!form) throw new BadRequestException("咨询表单不存在");
|
if (!form) throw new BadRequestException("咨询表单不存在");
|
||||||
@@ -245,7 +246,12 @@ export class CustomerInquirySubmissionController {
|
|||||||
}
|
}
|
||||||
if (identity.role !== "customer") throw new ForbiddenException("无客户权限");
|
if (identity.role !== "customer") throw new ForbiddenException("无客户权限");
|
||||||
const form = await this.prisma.inquiryForm.findFirst({
|
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("咨询表单不存在");
|
if (!form) throw new BadRequestException("咨询表单不存在");
|
||||||
return this.prisma.inquirySubmission.create({
|
return this.prisma.inquirySubmission.create({
|
||||||
|
|||||||
@@ -219,6 +219,15 @@ test("admin can create and version an inquiry form", async () => {
|
|||||||
});
|
});
|
||||||
assert.equal(updated.statusCode, 200);
|
assert.equal(updated.statusCode, 200);
|
||||||
assert.equal(JSON.parse(updated.body).version, 2);
|
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}`);
|
const publicForm = await request(`/public/inquiry-forms/${id}`);
|
||||||
assert.equal(publicForm.statusCode, 200);
|
assert.equal(publicForm.statusCode, 200);
|
||||||
const publicOffering = await request(`/public/offerings/${offering.id}`);
|
const publicOffering = await request(`/public/offerings/${offering.id}`);
|
||||||
|
|||||||
Reference in new issue
Block a user