feat: 添加内容删除前检查,确保内容未被购买
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -131,6 +131,8 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ConfirmDialog />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user