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 }