feat: 在业务提供项公开详情中关联咨询表单
This commit is contained in:
1 parent
c907734076
commit
888a504423
2 files changed
+20
No files matched your search
@@ -170,6 +170,13 @@ export class PublicOfferingController {
|
|||||||
const items = await this.prisma.offering.findMany({
|
const items = await this.prisma.offering.findMany({
|
||||||
where: { brandId, isEnabled: true },
|
where: { brandId, isEnabled: true },
|
||||||
orderBy: { sortOrder: "asc" },
|
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));
|
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",
|
brandId: process.env.DEFAULT_BRAND_ID ?? "00000000-0000-0000-0000-000000000001",
|
||||||
isEnabled: true,
|
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("业务提供项不存在");
|
if (!item) throw new BadRequestException("业务提供项不存在");
|
||||||
return this.present(item);
|
return this.present(item);
|
||||||
|
|||||||
@@ -198,11 +198,14 @@ test("admin can create and version an inquiry form", async () => {
|
|||||||
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
payload: { username: "admin", password: process.env.SEED_ADMIN_PASSWORD },
|
||||||
});
|
});
|
||||||
const token = JSON.parse(login.body).token;
|
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", {
|
const created = await request("/admin/workspace/forms", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: { authorization: `Bearer ${token}` },
|
headers: { authorization: `Bearer ${token}` },
|
||||||
payload: {
|
payload: {
|
||||||
name: "品牌合作咨询",
|
name: "品牌合作咨询",
|
||||||
|
offeringId: offering.id,
|
||||||
fieldsSnapshot: [{ key: "project", type: "textarea", label: "项目背景", required: true }],
|
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);
|
assert.equal(JSON.parse(updated.body).version, 2);
|
||||||
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}`);
|
||||||
|
assert.equal(publicOffering.statusCode, 200);
|
||||||
|
assert.equal(JSON.parse(publicOffering.body).inquiryForms[0].id, id);
|
||||||
const publicWorkspace = await request("/public/workspace");
|
const publicWorkspace = await request("/public/workspace");
|
||||||
assert.equal(publicWorkspace.statusCode, 200);
|
assert.equal(publicWorkspace.statusCode, 200);
|
||||||
assert.equal(JSON.parse(publicWorkspace.body).inquiryForm.id, id);
|
assert.equal(JSON.parse(publicWorkspace.body).inquiryForm.id, id);
|
||||||
|
|||||||
Reference in new issue
Block a user