From 88976ba8afc8df0aafee27131612177fefe38b81 Mon Sep 17 00:00:00 2001 From: timerzz Date: Wed, 4 Sep 2024 20:52:22 +0800 Subject: [PATCH] =?UTF-8?q?feat=20article=E6=B7=BB=E5=8A=A0update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- structs/storage/article.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/structs/storage/article.go b/structs/storage/article.go index 759a866..ae51ef3 100644 --- a/structs/storage/article.go +++ b/structs/storage/article.go @@ -10,6 +10,7 @@ import ( type ArticleApi interface { Upsert(article v2.Article) error + Update(article v2.Article, selects ...string) error Find(query *FindArticleQuery) (articles []v2.Article, err error) List(query PageListQuery) (articles []v2.Article, total int64, err error) Get(query *GetArticleQuery) (article v2.Article, err error) @@ -48,6 +49,13 @@ func (a *articleApi) Upsert(article v2.Article) error { } +func (a *articleApi) Update(article v2.Article, selects ...string) error { + if len(selects) > 0 { + selects = []string{"remark", "exclude"} + } + return a.db.Model(&article).Select(selects).Updates(article).Error +} + // ******************Findĺ’ŚList type FindArticleQuery struct {