fix: 保证品牌模板身份不被台账漂移

This commit is contained in:
que01 committed 2026-10-14 16:27:23 +08:00
1 parent 6073e72940
commit aaeec14733
6 files changed
+53 -13

No files matched your search

+2 -6
View File
@@ -91,12 +91,6 @@ export class TemplateWorkspaceService {
select: { config: true, templateKey: true },
}),
]);
if (existing)
throw new BadRequestException(
existing.templateKey === templateKey
? "该模板已经安装"
: "品牌已经安装主模板,更换行业模板不在本版本范围内",
);
// 一个品牌只使用一个行业模板(BrandProfile.templateKey 即身份)。安装只允许补建当前模板的版本台账,
// 不得换成别的行业模板,否则会出现「身份是 A、台账是 B」的漂移,并把发布快照接到不适配的视觉模板上。
const currentTemplate = brand?.templateKey ? getBrandTemplate(brand.templateKey) : undefined;
@@ -104,6 +98,8 @@ export class TemplateWorkspaceService {
throw new BadRequestException(
`当前品牌已在使用「${currentTemplate.name}」行业模板,更换行业模板不在本版本范围内`,
);
if (existing && existing.templateKey === templateKey)
throw new BadRequestException("该模板已经安装");
const brandConfig =
brand?.config && typeof brand.config === "object" && !Array.isArray(brand.config)
? (brand.config as Record<string, unknown>)