feat 添加得物历史价格字段
This commit is contained in:
parent
570e19d76c
commit
d4b2d1596c
@ -44,7 +44,9 @@ type Product struct {
|
|||||||
Rate float64 `json:"rate" gorm:"index"` //利润率
|
Rate float64 `json:"rate" gorm:"index"` //利润率
|
||||||
PriceStatus PriceStatus `json:"priceStatus"` //价格状态
|
PriceStatus PriceStatus `json:"priceStatus"` //价格状态
|
||||||
Remark string `json:"remark"` //备注
|
Remark string `json:"remark"` //备注
|
||||||
|
|
||||||
HistoryPrices []HistoryPrice `gorm:"foreignKey:Pid;references:Pid" json:"historyPrices"`
|
HistoryPrices []HistoryPrice `gorm:"foreignKey:Pid;references:Pid" json:"historyPrices"`
|
||||||
|
DWHistoryPrices []DWHistoryPrice `gorm:"foreignKey:Pid;references:Pid" json:"dwHistoryPrices"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *Product) TableName() string {
|
func (p *Product) TableName() string {
|
||||||
@ -118,3 +120,11 @@ type HistoryPrice struct {
|
|||||||
Pid string `gorm:"index" json:"pid"`
|
Pid string `gorm:"index" json:"pid"`
|
||||||
USPrice float64 `json:"usPrice"`
|
USPrice float64 `json:"usPrice"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type DWHistoryPrice struct {
|
||||||
|
ID uint `gorm:"primary_key" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
|
||||||
|
Pid string `gorm:"index" json:"pid"`
|
||||||
|
DWPrice float64 `json:"dwPrice"`
|
||||||
|
}
|
||||||
|
@ -56,3 +56,19 @@ func TestUpdate(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetConfig(t *testing.T) {
|
||||||
|
db, err := database.InitDatabase(&database.DBOption{
|
||||||
|
Host: "192.168.31.55",
|
||||||
|
User: "timerzz",
|
||||||
|
Password: "zhhg1997",
|
||||||
|
Port: "5432",
|
||||||
|
DBName: "kedaya_dev",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
var exchangeRate float64
|
||||||
|
db.Table("options").Select("exchange_rate").Where("id = ?", 1).Scan(&exchangeRate)
|
||||||
|
t.Log(exchangeRate)
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user