fix: 保证示例内容导入幂等

This commit is contained in:
que01 committed 2026-09-23 02:04:32 +08:00
1 parent 3f42388fb3
commit fef0a890ad
2 files changed
+5 -2

No files matched your search

+4 -1
View File
@@ -224,7 +224,10 @@ class AdminWorkspaceController {
const existing = await this.prisma.brandFieldDefinition.count({
where: { brandId, source: "sample" },
});
if (existing) throw new BadRequestException("示例内容已经导入");
const existingOffering = await this.prisma.offering.count({
where: { brandId, name: "序章·入户门" },
});
if (existing || existingOffering) throw new BadRequestException("示例内容已经导入");
const result = await this.prisma.$transaction(async (tx) => {
const offerings = await tx.offering.createMany({
data: [