From 56c30cfe59713bad2a86eacb118d929b43938650 Mon Sep 17 00:00:00 2001 From: timerzz Date: Fri, 30 Aug 2024 13:39:16 +0800 Subject: [PATCH] =?UTF-8?q?feat=20=E9=80=9A=E8=BF=87sellerId=E5=92=8Cprovi?= =?UTF-8?q?derId=E8=8E=B7=E5=8F=96=E5=AF=B9=E8=B1=A1?= 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 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 {