Compare commits

...

2 Commits

Author SHA1 Message Date
2dfacfbe2c feat 添加providerArticle 2024-08-27 19:35:21 +08:00
7bb4399844 feat seller和provider备注改为remark 2024-08-27 17:47:45 +08:00
5 changed files with 45 additions and 6 deletions

View File

@ -17,6 +17,12 @@ type articleApi struct {
db *gorm.DB
}
func NewArticleApi(db *gorm.DB) ArticleApi {
return &articleApi{
db: db,
}
}
// Upsert 插入或者更新商品
func (a *articleApi) Upsert(article v2.Article) error {
return a.db.Clauses(clause.OnConflict{

View File

@ -0,0 +1,32 @@
package storage
import (
"testing"
v2 "gitea.timerzz.com/kedaya_haitao/common/structs/v2"
)
var providerArticle = v2.ProviderArticle{
ArticleID: 1,
Brand: v2.Brand_Coach,
Cost: v2.ProviderPrice{
CalMark: "111",
FinalPrice: 1,
OriginalPrice: 0,
ProviderArticleID: 0,
},
HistoryPrice: []v2.ProviderPrice{
{
CalMark: "222",
},
},
}
func TestProviderArticleApi_Upsert(t *testing.T) {
db, err := GetDevDB()
if err != nil {
t.Fatal(err)
}
storage := NewStorage(db)
storage.ProviderArticle().Upsert(providerArticle)
}

View File

@ -12,11 +12,10 @@ type Storage struct {
func NewStorage(db *gorm.DB) *Storage {
return &Storage{
articleApi: &articleApi{
db: db,
},
providerApi: NewProviderApi(db),
sellerApi: NewSellerApi(db),
articleApi: NewArticleApi(db),
providerApi: NewProviderApi(db),
providerArticleApi: NewProviderArticleApi(db),
sellerApi: NewSellerApi(db),
}
}

View File

@ -19,7 +19,7 @@ type Provider struct {
//计算过程
CalculateProcess []CalculateProcess `json:"calculateProcess" gorm:"polymorphicType:Kind;polymorphicId:OwnerID;polymorphicValue:provider"`
// 备注
Mark string `json:"mark,omitempty"`
Remark string `json:"remark,omitempty"`
}
type ProviderOption struct {

View File

@ -19,6 +19,8 @@ type Seller struct {
Config SellerOption `gorm:"type:json;serializer:json" json:"config"`
//计算过程
CalculateProcess []CalculateProcess `json:"calculateProcess" gorm:"polymorphicType:Kind;polymorphicId:OwnerID;polymorphicValue:seller"`
// 备注
Remark string `json:"remark,omitempty"`
}
type SellerOption struct {