feat 添加exclude属性
This commit is contained in:
parent
cba02db8e8
commit
27bd1558d4
@ -27,16 +27,42 @@ func NewArticleApi(db *gorm.DB) ArticleApi {
|
||||
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"}),
|
||||
DoUpdates: clause.AssignmentColumns([]string{"name", "english_name", "available", "updated_at", "cost_price", "sell_price", "rate", "remark", "exclude"}),
|
||||
}).Create(&article).Error
|
||||
}
|
||||
|
||||
// ******************Find和List
|
||||
|
||||
type FindArticleQuery struct {
|
||||
ID uint `query:"id"`
|
||||
Keyword string `query:"keyword"`
|
||||
Brand string `query:"brand"`
|
||||
Pid string `query:"pid"`
|
||||
Available *bool `query:"available"`
|
||||
ID uint `query:"id"`
|
||||
Keyword string `query:"keyword"`
|
||||
Brand v2.Brand `query:"brand"`
|
||||
Pid string `query:"pid"`
|
||||
Available *bool `query:"available"`
|
||||
}
|
||||
|
||||
func NewFindArticleQuery() *FindArticleQuery {
|
||||
return &FindArticleQuery{}
|
||||
}
|
||||
func (f *FindArticleQuery) SetID(id uint) *FindArticleQuery {
|
||||
f.ID = id
|
||||
return f
|
||||
}
|
||||
func (f *FindArticleQuery) SetKeyword(keyword string) *FindArticleQuery {
|
||||
f.Keyword = keyword
|
||||
return f
|
||||
}
|
||||
func (f *FindArticleQuery) SetBrand(brand v2.Brand) *FindArticleQuery {
|
||||
f.Brand = brand
|
||||
return f
|
||||
}
|
||||
func (f *FindArticleQuery) SetPid(pid string) *FindArticleQuery {
|
||||
f.Pid = pid
|
||||
return f
|
||||
}
|
||||
func (f *FindArticleQuery) SetAvailable(available bool) *FindArticleQuery {
|
||||
f.Available = &available
|
||||
return f
|
||||
}
|
||||
|
||||
func (l *FindArticleQuery) Scope(db *gorm.DB) *gorm.DB {
|
||||
@ -72,11 +98,35 @@ func (a *articleApi) List(query PageListQuery) (articles []v2.Article, total int
|
||||
return
|
||||
}
|
||||
|
||||
//**************GET
|
||||
|
||||
type GetArticleQuery struct {
|
||||
ID uint `query:"id"`
|
||||
Brand string `query:"brand"`
|
||||
Pid string `query:"pid"`
|
||||
History bool `query:"history"`
|
||||
ID uint `query:"id"`
|
||||
Brand v2.Brand `query:"brand"`
|
||||
Pid string `query:"pid"`
|
||||
History bool `query:"history"`
|
||||
}
|
||||
|
||||
func (g *GetArticleQuery) SetID(id uint) *GetArticleQuery {
|
||||
g.ID = id
|
||||
return g
|
||||
}
|
||||
|
||||
func (g *GetArticleQuery) SetBrand(brand v2.Brand) *GetArticleQuery {
|
||||
g.Brand = brand
|
||||
return g
|
||||
}
|
||||
func (g *GetArticleQuery) SetPid(pid string) *GetArticleQuery {
|
||||
g.Pid = pid
|
||||
return g
|
||||
}
|
||||
func (g *GetArticleQuery) SetHistory(history bool) *GetArticleQuery {
|
||||
g.History = history
|
||||
return g
|
||||
}
|
||||
|
||||
func NewGetArticleQuery() *GetArticleQuery {
|
||||
return &GetArticleQuery{}
|
||||
}
|
||||
|
||||
func (g *GetArticleQuery) Scope(db *gorm.DB) *gorm.DB {
|
||||
|
@ -21,12 +21,41 @@ func NewProviderArticleApi(db *gorm.DB) ProviderArticleApi {
|
||||
return &providerArticleApi{db: db}
|
||||
}
|
||||
|
||||
// ******************GET
|
||||
|
||||
type GetProviderArticleQuery struct {
|
||||
ID uint `query:"id"`
|
||||
Brand string `query:"brand"`
|
||||
Pid string `query:"pid"`
|
||||
ProviderId string `query:"providerId"`
|
||||
SkuId string `query:"skuId"`
|
||||
ID uint `query:"id"`
|
||||
Brand v2.Brand `query:"brand"`
|
||||
Pid string `query:"pid"`
|
||||
ProviderId string `query:"providerId"`
|
||||
SkuId string `query:"skuId"`
|
||||
}
|
||||
|
||||
func NewGetProviderArticleQuery() *GetProviderArticleQuery {
|
||||
return &GetProviderArticleQuery{}
|
||||
}
|
||||
|
||||
func (g *GetProviderArticleQuery) SetID(id uint) *GetProviderArticleQuery {
|
||||
g.ID = id
|
||||
return g
|
||||
}
|
||||
func (g *GetProviderArticleQuery) SetBrand(brand v2.Brand) *GetProviderArticleQuery {
|
||||
g.Brand = brand
|
||||
return g
|
||||
}
|
||||
func (g *GetProviderArticleQuery) SetPid(pid string) *GetProviderArticleQuery {
|
||||
g.Pid = pid
|
||||
return g
|
||||
}
|
||||
|
||||
func (g *GetProviderArticleQuery) SetProviderId(providerId string) *GetProviderArticleQuery {
|
||||
g.ProviderId = providerId
|
||||
return g
|
||||
}
|
||||
|
||||
func (g *GetProviderArticleQuery) SetSkuId(skuId string) *GetProviderArticleQuery {
|
||||
g.SkuId = skuId
|
||||
return g
|
||||
}
|
||||
|
||||
func (g *GetProviderArticleQuery) Scope(db *gorm.DB) *gorm.DB {
|
||||
|
@ -18,11 +18,37 @@ type sellerArticleApi struct {
|
||||
}
|
||||
|
||||
type GetSellerArticleQuery struct {
|
||||
ID uint `query:"id"`
|
||||
Brand string `query:"brand"`
|
||||
Pid string `query:"pid"`
|
||||
SellerId string `query:"sellerId"`
|
||||
SkuId string `query:"skuId"`
|
||||
ID uint `query:"id"`
|
||||
Brand v2.Brand `query:"brand"`
|
||||
Pid string `query:"pid"`
|
||||
SellerId string `query:"sellerId"`
|
||||
SkuId string `query:"skuId"`
|
||||
}
|
||||
|
||||
func NewGetSellerArticleQuery() *GetSellerArticleQuery {
|
||||
return &GetSellerArticleQuery{}
|
||||
}
|
||||
|
||||
func (g *GetSellerArticleQuery) SetID(id uint) *GetSellerArticleQuery {
|
||||
g.ID = id
|
||||
return g
|
||||
}
|
||||
|
||||
func (g *GetSellerArticleQuery) SetBrand(brand v2.Brand) *GetSellerArticleQuery {
|
||||
g.Brand = brand
|
||||
return g
|
||||
}
|
||||
func (g *GetSellerArticleQuery) SetPid(pid string) *GetSellerArticleQuery {
|
||||
g.Pid = pid
|
||||
return g
|
||||
}
|
||||
func (g *GetSellerArticleQuery) SetSellerId(sellerId string) *GetSellerArticleQuery {
|
||||
g.SellerId = sellerId
|
||||
return g
|
||||
}
|
||||
func (g *GetSellerArticleQuery) SetSkuId(skuId string) *GetSellerArticleQuery {
|
||||
g.SkuId = skuId
|
||||
return g
|
||||
}
|
||||
|
||||
func (g *GetSellerArticleQuery) Scope(db *gorm.DB) *gorm.DB {
|
||||
@ -52,7 +78,7 @@ func (p *sellerArticleApi) Get(query GetSellerArticleQuery) (article v2.SellerAr
|
||||
func (p *sellerArticleApi) Upsert(article v2.SellerArticle) error {
|
||||
return p.db.Clauses(clause.OnConflict{
|
||||
Columns: []clause.Column{{Name: "seller_id"}, {Name: "sku_id"}},
|
||||
DoUpdates: clause.AssignmentColumns([]string{"sell"}),
|
||||
DoUpdates: clause.AssignmentColumns([]string{"sell", "exclude"}),
|
||||
}).Create(&article).Error
|
||||
}
|
||||
|
||||
|
@ -29,6 +29,8 @@ type Article struct {
|
||||
Image string `json:"image"`
|
||||
// 可以购买的
|
||||
Available bool `json:"available"`
|
||||
// 排除
|
||||
Exclude bool `json:"exclude"`
|
||||
// 最低成本价(单位为分)
|
||||
CostPrice int `json:"costPrice"`
|
||||
// 供应商报价列表
|
||||
|
@ -63,6 +63,8 @@ type ProviderArticle struct {
|
||||
SkuID string `gorm:"index:providerId_sku,unique" json:"skuID"`
|
||||
// 当前成本价
|
||||
Cost ProviderPrice `json:"cost" gorm:"type:json;serializer:json"`
|
||||
// 是否排除,如果排除,就不用拉取价格
|
||||
Exclude bool `json:"exclude"`
|
||||
// 历史成本价格
|
||||
HistoryPrice []ProviderPrice `json:"historyPrice"`
|
||||
// 计算过程
|
||||
|
@ -59,6 +59,8 @@ type SellerArticle struct {
|
||||
SellerId SellerId `gorm:"index:sellerId_sku,unique" json:"sellerId"`
|
||||
// 销售商的sku
|
||||
SkuID string `gorm:"index:sellerId_sku,unique" json:"skuID"`
|
||||
// 是否排除
|
||||
Exclude bool `json:"exclude"`
|
||||
// 当前成本价
|
||||
Sell SellerPrice `json:"sell" gorm:"type:json;serializer:json"`
|
||||
// 历史出售价格
|
||||
|
Loading…
Reference in New Issue
Block a user