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 }