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("标识为空")