Compare commits
2 Commits
8bd70ec18d
...
566d95bc0f
Author | SHA1 | Date | |
---|---|---|---|
566d95bc0f | |||
217039202d |
@ -15,6 +15,7 @@ type ProviderArticleApi interface {
|
||||
AutoMigrate() error
|
||||
FindInBatches(query *GetProviderArticleQuery, results *[]v2.ProviderArticle, f func(tx *gorm.DB, batch int) error) error
|
||||
ProviderPrice(providerArticleID uint) (history []v2.ProviderPrice, err error)
|
||||
UpdateStatus(article v2.ProviderArticle) error
|
||||
}
|
||||
|
||||
type providerArticleApi struct {
|
||||
@ -89,7 +90,7 @@ func (p *providerArticleApi) Get(query *GetProviderArticleQuery) (article v2.Pro
|
||||
func (p *providerArticleApi) Upsert(article v2.ProviderArticle) error {
|
||||
if err := p.db.Clauses(clause.OnConflict{
|
||||
Columns: []clause.Column{{Name: "provider_id"}, {Name: "sku_id"}},
|
||||
DoUpdates: clause.AssignmentColumns([]string{"cost", "available", "updated_at"}),
|
||||
DoUpdates: clause.AssignmentColumns([]string{"cost", "available", "updated_at", "ast"}),
|
||||
}).Create(&article).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
@ -98,6 +99,9 @@ func (p *providerArticleApi) Upsert(article v2.ProviderArticle) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (p *providerArticleApi) UpdateStatus(article v2.ProviderArticle) error {
|
||||
return p.db.Where("id=?", article.ID).Select("status").Updates(&article).Error
|
||||
}
|
||||
|
||||
func (p *providerArticleApi) FindInBatches(query *GetProviderArticleQuery, results *[]v2.ProviderArticle, f func(tx *gorm.DB, batch int) error) error {
|
||||
err := p.db.Scopes(query.Scope).Preload("CalculateProcess").FindInBatches(results, 20, f).Error
|
||||
|
Loading…
Reference in New Issue
Block a user