diff --git a/structs/storage/provider.go b/structs/storage/provider.go index 793011b..34c1567 100644 --- a/structs/storage/provider.go +++ b/structs/storage/provider.go @@ -12,6 +12,7 @@ import ( 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) Create(provider v2.Provider) error Update(provider v2.Provider) error @@ -51,6 +52,11 @@ func (p *providerApi) Get(id uint) (provider v2.Provider, err error) { return } +func (p *providerApi) GetByProvider(providerId v2.ProviderId) (provider v2.Provider, err error) { + err = p.db.Where("provider_id = ?", providerId).Preload("CalculateProcess").First(&provider).Error + return +} + func (p *providerApi) List(query PageListQuery) (providers []v2.Provider, total int64, err error) { err = p.db.Scopes(query.Scoper.Scope).Model(&v2.Provider{}).Count(&total).Error if err != nil { diff --git a/structs/storage/seller.go b/structs/storage/seller.go index 1ba173c..0b95730 100644 --- a/structs/storage/seller.go +++ b/structs/storage/seller.go @@ -12,6 +12,7 @@ import ( 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) Create(seller v2.Seller) error Update(seller v2.Seller) error @@ -51,6 +52,11 @@ func (p *sellerApi) Get(id uint) (seller v2.Seller, err error) { return } +func (p *sellerApi) GetBySellerId(sellerId v2.SellerId) (seller v2.Seller, err error) { + err = p.db.Where("seller_id = ?", sellerId).Preload("CalculateProcess").First(&seller).Error + return +} + func (p *sellerApi) List(query PageListQuery) (sellers []v2.Seller, total int64, err error) { err = p.db.Scopes(query.Scoper.Scope).Model(&v2.Seller{}).Count(&total).Error if err != nil {