From d5ae2cb9022587379cbf773506860e69d92df0fa Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Sun, 6 Apr 2025 15:07:35 +0800 Subject: [PATCH] =?UTF-8?q?dashboard=E9=83=A8=E5=88=86=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=9C=80=E8=BF=91=E4=B8=80=E5=91=A8=E3=80=81=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=BB=9F=E8=AE=A1=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- proto/tool.go | 4 ++-- service/toolService.go | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/proto/tool.go b/proto/tool.go index 3000c71..e4ea6dc 100644 --- a/proto/tool.go +++ b/proto/tool.go @@ -10,8 +10,8 @@ type DashBoardStatisticsSt struct { // 统计过去一周每天的会话数、消息数 type DashBoardStatisticsWeekSt struct { - SessionCount []int64 `json:"session_count"` - MessageCount []int64 `json:"message_count"` + SessionCount map[int]int64 `json:"session_count"` + MessageCount map[int]int64 `json:"message_count"` } type DashBoardStatisticsResp struct { diff --git a/service/toolService.go b/service/toolService.go index 494399e..0d6f14d 100644 --- a/service/toolService.go +++ b/service/toolService.go @@ -132,17 +132,22 @@ func GetBaseDashboardInfo() proto.DashBoardStatisticsSt { // 获取最近7天的消息、会话数量 func GetRecent7DaysMessageSessionCount() (proto.DashBoardStatisticsWeekSt, error) { var res proto.DashBoardStatisticsWeekSt - var err error - res.SessionCount, err = dao.FindSessionCountByDate() + SessionCounts, err := dao.FindSessionCountByDate() if err != nil { log.Println("get recent 7 days session count error:", err) return res, err } - res.MessageCount, err = dao.FindMessageCountByDate() + for i := 0; i < len(SessionCounts); i++ { + res.SessionCount[i] = SessionCounts[i] + } + MessageCounts, err := dao.FindMessageCountByDate() if err != nil { log.Println("get recent 7 days message count error:", err) return res, err } + for i := 0; i < len(MessageCounts); i++ { + res.MessageCount[i] = MessageCounts[i] + } return res, nil }