From 6063310bb3c001aed4e138dd4a250e653839dd4f Mon Sep 17 00:00:00 2001 From: timerzz Date: Sat, 31 Aug 2024 12:46:18 +0800 Subject: [PATCH] =?UTF-8?q?feat=20get=E5=92=8Clist=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E5=BC=95=E7=94=A8query?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- structs/storage/article.go | 8 ++++---- structs/storage/provider-article.go | 4 ++-- structs/storage/seller-article.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/structs/storage/article.go b/structs/storage/article.go index eca524b..9aad211 100644 --- a/structs/storage/article.go +++ b/structs/storage/article.go @@ -8,9 +8,9 @@ import ( type ArticleApi interface { Upsert(article v2.Article) error - Find(query FindArticleQuery) (articles []v2.Article, err 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) + Get(query *GetArticleQuery) (article v2.Article, err error) } type articleApi struct { @@ -84,7 +84,7 @@ func (l *FindArticleQuery) Scope(db *gorm.DB) *gorm.DB { return db } -func (a *articleApi) Find(query FindArticleQuery) (articles []v2.Article, err error) { +func (a *articleApi) Find(query *FindArticleQuery) (articles []v2.Article, err error) { err = a.db.Scopes(query.Scope).Find(&articles).Error return } @@ -146,7 +146,7 @@ func (g *GetArticleQuery) Scope(db *gorm.DB) *gorm.DB { return db } -func (a *articleApi) Get(query GetArticleQuery) (article v2.Article, err error) { +func (a *articleApi) Get(query *GetArticleQuery) (article v2.Article, err error) { err = a.db.Scopes(query.Scope).First(&article).Error return } diff --git a/structs/storage/provider-article.go b/structs/storage/provider-article.go index b149229..976ab4e 100644 --- a/structs/storage/provider-article.go +++ b/structs/storage/provider-article.go @@ -8,7 +8,7 @@ import ( // ProviderArticleApi 管理供应商商品的接口 type ProviderArticleApi interface { - Get(query GetProviderArticleQuery) (article v2.ProviderArticle, err error) + Get(query *GetProviderArticleQuery) (article v2.ProviderArticle, err error) Upsert(article v2.ProviderArticle) error AutoMigrate() error } @@ -77,7 +77,7 @@ func (g *GetProviderArticleQuery) Scope(db *gorm.DB) *gorm.DB { return db } -func (p *providerArticleApi) Get(query GetProviderArticleQuery) (article v2.ProviderArticle, err error) { +func (p *providerArticleApi) Get(query *GetProviderArticleQuery) (article v2.ProviderArticle, err error) { err = p.db.Scopes(query.Scope).Preload("CalculateProcess").First(&article).Error return } diff --git a/structs/storage/seller-article.go b/structs/storage/seller-article.go index 456e785..b0fb86e 100644 --- a/structs/storage/seller-article.go +++ b/structs/storage/seller-article.go @@ -8,7 +8,7 @@ import ( // SellerArticleApi 管理供应商商品的接口 type SellerArticleApi interface { - Get(query GetProviderArticleQuery) (article v2.ProviderArticle, err error) + Get(query *GetProviderArticleQuery) (article v2.ProviderArticle, err error) Upsert(article v2.SellerArticle) error AutoMigrate() error } @@ -70,7 +70,7 @@ func (g *GetSellerArticleQuery) Scope(db *gorm.DB) *gorm.DB { return db } -func (p *sellerArticleApi) Get(query GetSellerArticleQuery) (article v2.SellerArticle, err error) { +func (p *sellerArticleApi) Get(query *GetSellerArticleQuery) (article v2.SellerArticle, err error) { err = p.db.Scopes(query.Scope).First(&article).Error return }