fix: 保证示例内容导入幂等
This commit is contained in:
1 parent
3f42388fb3
commit
fef0a890ad
2 files changed
+5
-2
No files matched your search
@@ -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: [
|
||||
|
||||
Reference in new issue
Block a user