From a9a90ab1b4ec97d860683703d5a1634777a8fdc8 Mon Sep 17 00:00:00 2001 From: timerzz Date: Tue, 3 Sep 2024 17:32:40 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E4=BF=AE=E6=94=B9sellers=E9=95=BF?= =?UTF-8?q?=E5=BA=A6=E4=B8=BA0=E4=B8=8D=E4=BF=9D=E5=AD=98=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- structs/storage/article.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/structs/storage/article.go b/structs/storage/article.go index d441a2c..7f1d3d4 100644 --- a/structs/storage/article.go +++ b/structs/storage/article.go @@ -35,10 +35,15 @@ func (a *articleApi) Upsert(article v2.Article) error { }).Create(&article).Error; err != nil { return err } - if err := tx.Save(&article.Providers).Error; err != nil { - return fmt.Errorf("failed to save providers: %v", err) + if len(article.Providers) > 0 { + if err := tx.Save(&article.Providers).Error; err != nil { + return fmt.Errorf("failed to save providers: %v", err) + } } - return tx.Save(&article.Sellers).Error + if len(article.Sellers) > 0 { + return tx.Save(&article.Sellers).Error + } + return nil }) }