feat: 添加内容删除前检查,确保内容未被购买

This commit is contained in:
2026-01-05 13:00:12 +08:00
parent c231847f81
commit 67c6c3cccb
2 changed files with 8 additions and 0 deletions

View File

@@ -425,6 +425,12 @@ func (s *creator) DeleteContent(ctx context.Context, userID int64, id string) er
return err
}
// Check if purchased (ContentAccess exists)
count, _ := models.ContentAccessQuery.WithContext(ctx).Where(models.ContentAccessQuery.ContentID.Eq(cid)).Count()
if count > 0 {
return errorx.ErrPreconditionFailed.WithMsg("该内容已被购买,无法删除")
}
_, err = models.ContentQuery.WithContext(ctx).
Where(models.ContentQuery.ID.Eq(cid), models.ContentQuery.TenantID.Eq(tid)).
Delete()

View File

@@ -131,6 +131,8 @@
</div>
</div>
</div>
<ConfirmDialog />
</div>
</template>