From fb9918e2665989b6fe958bcd2b5e043c54382505 Mon Sep 17 00:00:00 2001 From: timerzz Date: Fri, 6 Sep 2024 17:22:28 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E6=B7=BB=E5=8A=A0api=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=89=80=E6=9C=89=E6=BB=A1=E8=B6=B3=E6=9D=A1=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E5=92=8C=E9=94=80=E5=94=AE=E5=95=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- structs/storage/provider.go | 6 ++++++ structs/storage/seller.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/structs/storage/provider.go b/structs/storage/provider.go index b5574de..291f96a 100644 --- a/structs/storage/provider.go +++ b/structs/storage/provider.go @@ -14,6 +14,7 @@ type ProviderApi interface { Get(id uint) (provider v2.Provider, err error) GetByProvider(providerId v2.ProviderId) (provider v2.Provider, err error) List(query PageListQuery) (providers []v2.Provider, total int64, err error) + Find(query Scoper) (providers []v2.Provider, err error) Create(provider v2.Provider) error Update(provider v2.Provider) error UpdateStatus(provider v2.Provider) error @@ -67,6 +68,11 @@ func (p *providerApi) List(query PageListQuery) (providers []v2.Provider, total return } +func (p *providerApi) Find(query Scoper) (providers []v2.Provider, err error) { + err = p.db.Scopes(query.Scope).Order("id DESC").Find(&providers).Error + return +} + func (p *providerApi) Create(provider v2.Provider) error { if provider.ProviderId == "" { return fmt.Errorf("标识为空") diff --git a/structs/storage/seller.go b/structs/storage/seller.go index b3cfa01..0f20894 100644 --- a/structs/storage/seller.go +++ b/structs/storage/seller.go @@ -14,6 +14,7 @@ type SellerApi interface { Get(id uint) (seller v2.Seller, err error) GetBySellerId(sellerId v2.SellerId) (seller v2.Seller, err error) List(query PageListQuery) (sellers []v2.Seller, total int64, err error) + Find(query Scoper) (sellers []v2.Seller, err error) Create(seller v2.Seller) error Update(seller v2.Seller) error UpdateStatus(seller v2.Seller) error @@ -67,6 +68,11 @@ func (p *sellerApi) List(query PageListQuery) (sellers []v2.Seller, total int64, return } +func (p *sellerApi) Find(query Scoper) (sellers []v2.Seller, err error) { + err = p.db.Scopes(query.Scope).Order("id DESC").Find(&sellers).Error + return +} + func (p *sellerApi) Create(seller v2.Seller) error { if seller.SellerId == "" { return fmt.Errorf("标识为空")