fix: 收敛模板编辑发布契约并还原餐饮页面视觉
This commit is contained in:
1 parent
20bcb43534
commit
f4061a24bd
102 files changed
+4510
-870
No files matched your search
@@ -183,6 +183,11 @@ class AdminWorkspaceController {
|
||||
? {
|
||||
displayName: manifest.displayName,
|
||||
admin: manifest.admin,
|
||||
navigation: manifest.navigation.map(({ key, label, page }) => ({ key, label, page })),
|
||||
templateFields: (manifest.templateFields ?? []).map((field) => ({
|
||||
...field,
|
||||
binding: field.binding ?? `brand.config.templateData.${field.key}`,
|
||||
})),
|
||||
assetSlots: manifest.assetSlots,
|
||||
trustContentTypes: manifest.trustContentTypes ?? [],
|
||||
}
|
||||
@@ -244,7 +249,10 @@ class AdminWorkspaceController {
|
||||
offerings: sample.offerings.length,
|
||||
trustContent: sample.trustContent.length,
|
||||
fields: sample.fields.length,
|
||||
inquiryForms: 1,
|
||||
},
|
||||
willCreateInquiryForm:
|
||||
(await this.prisma.inquiryForm.count({ where: { brandId, isEnabled: true } })) === 0,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -255,6 +263,8 @@ class AdminWorkspaceController {
|
||||
const templateKey = await this.templateWorkspace.getEffectiveTemplateKey(brandId);
|
||||
const sample = getTemplateSampleContent(templateKey);
|
||||
if (!sample) throw new BadRequestException("模板示例内容不存在");
|
||||
const fieldIssues = validateFieldSnapshot(sample.fields);
|
||||
if (fieldIssues.length) throw new BadRequestException("模板咨询表单示例字段无效");
|
||||
const existing = await this.prisma.brandFieldDefinition.count({
|
||||
where: { brandId, source: "sample" },
|
||||
});
|
||||
@@ -280,6 +290,7 @@ class AdminWorkspaceController {
|
||||
type: item.type,
|
||||
title: item.title,
|
||||
content: item.content,
|
||||
...(item.config ? { config: item.config as Prisma.InputJsonValue } : {}),
|
||||
sortOrder,
|
||||
isPublished: false,
|
||||
})),
|
||||
@@ -296,6 +307,20 @@ class AdminWorkspaceController {
|
||||
required: item.required,
|
||||
})),
|
||||
});
|
||||
const hasEnabledForm = await tx.inquiryForm.count({ where: { brandId, isEnabled: true } });
|
||||
const inquiryForm = hasEnabledForm
|
||||
? null
|
||||
: await tx.inquiryForm.create({
|
||||
data: {
|
||||
brandId,
|
||||
name: sample.inquiryFormName,
|
||||
purpose: "inquiry",
|
||||
targetType: "brand",
|
||||
submissionAction: "create-inquiry",
|
||||
fieldsSnapshot: sample.fields,
|
||||
isEnabled: true,
|
||||
},
|
||||
});
|
||||
await tx.capabilityAuditLog.create({
|
||||
data: {
|
||||
brandId,
|
||||
@@ -303,10 +328,20 @@ class AdminWorkspaceController {
|
||||
actorId: identity.subject,
|
||||
action: "sample_content_imported",
|
||||
toStatus: "enabled",
|
||||
config: { offerings: offerings.count, trustContent: trust.count, fields: fields.count },
|
||||
config: {
|
||||
offerings: offerings.count,
|
||||
trustContent: trust.count,
|
||||
fields: fields.count,
|
||||
inquiryForms: inquiryForm ? 1 : 0,
|
||||
},
|
||||
},
|
||||
});
|
||||
return { offerings: offerings.count, trustContent: trust.count, fields: fields.count };
|
||||
return {
|
||||
offerings: offerings.count,
|
||||
trustContent: trust.count,
|
||||
fields: fields.count,
|
||||
inquiryForms: inquiryForm ? 1 : 0,
|
||||
};
|
||||
});
|
||||
return { imported: true, counts: result };
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user