From 67c6c3cccbacec8512eb4a9cbea104f5b3359dcd Mon Sep 17 00:00:00 2001 From: Rogee Date: Mon, 5 Jan 2026 13:00:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=89=8D=E6=A3=80=E6=9F=A5=EF=BC=8C=E7=A1=AE?= =?UTF-8?q?=E4=BF=9D=E5=86=85=E5=AE=B9=E6=9C=AA=E8=A2=AB=E8=B4=AD=E4=B9=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/services/creator.go | 6 ++++++ frontend/portal/src/views/creator/ContentsView.vue | 2 ++ 2 files changed, 8 insertions(+) diff --git a/backend/app/services/creator.go b/backend/app/services/creator.go index 00e18f2..58c1491 100644 --- a/backend/app/services/creator.go +++ b/backend/app/services/creator.go @@ -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() diff --git a/frontend/portal/src/views/creator/ContentsView.vue b/frontend/portal/src/views/creator/ContentsView.vue index 585b014..aa273b7 100644 --- a/frontend/portal/src/views/creator/ContentsView.vue +++ b/frontend/portal/src/views/creator/ContentsView.vue @@ -131,6 +131,8 @@ + +