common/structs/storage/article.go

26 lines
589 B
Go

package storage
import (
v2 "gitea.timerzz.com/kedaya_haitao/common/structs/v2"
"gorm.io/gorm"
"gorm.io/gorm/clause"
)
type Storage struct {
}
type ArticleApi interface {
}
type articleApi struct {
db *gorm.DB
}
// Upsert 插入或者更新商品
func (a *articleApi) Upsert(article v2.Article) error {
return a.db.Clauses(clause.OnConflict{
Columns: []clause.Column{{Name: "pid"}, {Name: "brand"}},
DoUpdates: clause.AssignmentColumns([]string{"name", "english_name", "available", "updated_at", "cost_price", "sell_price", "rate", "remark"}),
}).Create(&article).Error
}