diff --git a/api/models.go b/api/models.go index b1cca6f..141262d 100644 --- a/api/models.go +++ b/api/models.go @@ -22,3 +22,17 @@ func GetBinanceLatestPrice(symbol string) float64 { global.DB.Where("symbol = ?", symbol).Last(&binancePrice) return binancePrice.Price } + +type CMBGold struct { + gorm.Model + Variety string + CurPrice float64 + UpDown float64 + GoldNo string +} + +func GetCMBGoldLatestPrice(goldNo string) float64 { + var cmbGold CMBGold + global.DB.Where("gold_no = ?", goldNo).Last(&cmbGold) + return cmbGold.CurPrice +} diff --git a/handle/replyText.go b/handle/replyText.go index c342a71..ee71bf2 100644 --- a/handle/replyText.go +++ b/handle/replyText.go @@ -39,11 +39,13 @@ func cmdExec(msgContent MsgContent) (replyContent string) { case "eth", "btc", "虚拟货币": priceBTC := api.GetBinanceLatestPrice("BTCUSDT") priceETH := api.GetBinanceLatestPrice("ETHUSDT") - replyContent = fmt.Sprintf("BTC: %f \n ETH: %f", priceBTC, priceETH) + replyContent = fmt.Sprintf("BTC价格: %f \n ETH价格: %f", priceBTC, priceETH) return case "gold", "黄金": - replyContent = "黄金黄金黄金黄金黄金" + goldPrice := api.GetCMBGoldLatestPrice("AU100G") + replyContent = fmt.Sprintf("黄金价格: %f", goldPrice) + return default: cmdString = msgContent.Content }