feat: 按模板要求校验信任内容发布
This commit is contained in:
1 parent
e3a4074d8e
commit
5ed06b1abe
10 files changed
+71
-16
No files matched your search
@@ -69,7 +69,7 @@ export class BrandReleaseApiService {
|
||||
: getDefaultVisualTemplateKey(brand?.templateKey ?? "personal");
|
||||
const visual = getVisualTemplate(visualKey);
|
||||
const packageManifest = getTemplatePackageManifestForVisualKey(visualKey);
|
||||
const [offerings, forms, trust] = await Promise.all([
|
||||
const [offerings, forms, trustItems] = await Promise.all([
|
||||
database.offering.findMany({
|
||||
where: { brandId, isEnabled: true },
|
||||
select: { id: true, name: true, coverUrl: true, config: true },
|
||||
@@ -78,7 +78,10 @@ export class BrandReleaseApiService {
|
||||
where: { brandId, isEnabled: true },
|
||||
select: { offeringId: true, fieldsSnapshot: true },
|
||||
}),
|
||||
database.trustContent.count({ where: { brandId, isPublished: true } }),
|
||||
database.trustContent.findMany({
|
||||
where: { brandId, isPublished: true },
|
||||
select: { type: true },
|
||||
}),
|
||||
]);
|
||||
const offeringIds = new Set(offerings.map((item) => item.id));
|
||||
const usableForms = forms.filter(
|
||||
@@ -129,10 +132,21 @@ export class BrandReleaseApiService {
|
||||
{
|
||||
key: "trust",
|
||||
label: "至少需要一条已发布的信任内容",
|
||||
passed: trust > 0,
|
||||
passed: trustItems.length > 0,
|
||||
destination: "/admin/trust",
|
||||
},
|
||||
];
|
||||
const publishedTrustTypes = new Set(trustItems.map((item) => item.type));
|
||||
for (const type of packageManifest?.trustContentTypes ?? []) {
|
||||
if (type.required !== true) continue;
|
||||
checks.push({
|
||||
key: `trust:${type.type}`,
|
||||
label: `请补充${type.label}`,
|
||||
passed: publishedTrustTypes.has(type.type),
|
||||
...(type.help ? { help: type.help } : {}),
|
||||
destination: "/admin/trust",
|
||||
});
|
||||
}
|
||||
const brandRecord = { ...this.jsonObject(brand), config };
|
||||
for (const section of packageManifest?.admin.sections ?? []) {
|
||||
for (const field of section.fields) {
|
||||
@@ -166,7 +180,7 @@ export class BrandReleaseApiService {
|
||||
? offerings.length > 0 && offerings.every((item) => Boolean(item.coverUrl?.trim()))
|
||||
: slot.target === "brand"
|
||||
? this.resolveBinding(slot.binding, { brand: brandRecord, offerings })
|
||||
: trust > 0;
|
||||
: trustItems.length > 0;
|
||||
checks.push({
|
||||
key: `asset:${String(slot.key)}`,
|
||||
label: present ? `已添加${String(slot.label)}` : `请添加${String(slot.label)}`,
|
||||
|
||||
Reference in new issue
Block a user