From 5ca677c95bc3effdcefaa98ed65f9d78d63e3778 Mon Sep 17 00:00:00 2001 From: dustoair <107600816+dustoair@users.noreply.github.com> Date: Mon, 12 Sep 2022 21:35:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=BB=84=E9=87=91=E4=BB=B7=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/baiduReport.go | 31 +++++++++++++++++++++++++++++++ api/binancePrice.go | 25 +++++++++++++++++++++++++ api/{models.go => goldPrice.go} | 19 ++++--------------- global/cmds.go | 1 + handle/replyText.go | 4 ++++ 5 files changed, 65 insertions(+), 15 deletions(-) create mode 100644 api/baiduReport.go create mode 100644 api/binancePrice.go rename api/{models.go => goldPrice.go} (60%) diff --git a/api/baiduReport.go b/api/baiduReport.go new file mode 100644 index 0000000..2c91159 --- /dev/null +++ b/api/baiduReport.go @@ -0,0 +1,31 @@ +package api + +import ( + "WechatGateWay/global" + "github.com/jinzhu/gorm" +) + +/* +* +@author: sre +@date: 2022/9/12 0012 +@desc: todo +* +*/ +type BaiduReportInfo struct { + gorm.Model + siteId int64 + Domain string + YesterdayPvCount int + YesterdayVisitorCount int + YesterdayIpCount int + TodayPvCount int + TodayVisitorCount int + TodayIpCount int +} + +func GetLatestBaiduReportInfo(domain string) (int, int, int) { + var baiduReportInfo BaiduReportInfo + global.DB.Where("domain = ?", domain).Last(&baiduReportInfo) + return baiduReportInfo.TodayPvCount, baiduReportInfo.TodayVisitorCount, baiduReportInfo.TodayIpCount +} diff --git a/api/binancePrice.go b/api/binancePrice.go new file mode 100644 index 0000000..32eb24a --- /dev/null +++ b/api/binancePrice.go @@ -0,0 +1,25 @@ +package api + +import ( + "WechatGateWay/global" + "github.com/jinzhu/gorm" +) + +/* +* +@author: sre +@date: 2022/9/12 0012 +@desc: todo +* +*/ +type BinancePrice struct { + gorm.Model + Symbol string + Price float64 +} + +func GetBinanceLatestPrice(symbol string) float64 { + var binancePrice BinancePrice + global.DB.Where("symbol = ?", symbol).Last(&binancePrice) + return binancePrice.Price +} diff --git a/api/models.go b/api/goldPrice.go similarity index 60% rename from api/models.go rename to api/goldPrice.go index 141262d..d057fa5 100644 --- a/api/models.go +++ b/api/goldPrice.go @@ -5,24 +5,13 @@ import ( "github.com/jinzhu/gorm" ) -/** +/* +* @author: sre @date: 2022/9/12 0012 @desc: todo -**/ - -type BinancePrice struct { - gorm.Model - Symbol string - Price float64 -} - -func GetBinanceLatestPrice(symbol string) float64 { - var binancePrice BinancePrice - global.DB.Where("symbol = ?", symbol).Last(&binancePrice) - return binancePrice.Price -} - +* +*/ type CMBGold struct { gorm.Model Variety string diff --git a/global/cmds.go b/global/cmds.go index 7b28f1e..1cdfcf0 100644 --- a/global/cmds.go +++ b/global/cmds.go @@ -13,4 +13,5 @@ var CMDList = []string{ "虚拟货币", "gold", "黄金", + "ip", } diff --git a/handle/replyText.go b/handle/replyText.go index ee71bf2..d93b353 100644 --- a/handle/replyText.go +++ b/handle/replyText.go @@ -46,6 +46,10 @@ func cmdExec(msgContent MsgContent) (replyContent string) { goldPrice := api.GetCMBGoldLatestPrice("AU100G") replyContent = fmt.Sprintf("黄金价格: %f", goldPrice) return + case "ip", "百度统计": + todayPvCount, todayVisitorCount, todayIpCount := api.GetLatestBaiduReportInfo("sre.ink") + replyContent = fmt.Sprintf("今日百度统计: PV %d, VC %d IP %d", todayPvCount, todayVisitorCount, todayIpCount) + return default: cmdString = msgContent.Content }