From 6bd3c2cc91c6ffe75a773eb94c2ec913fe136df8 Mon Sep 17 00:00:00 2001 From: hujiebin Date: Mon, 29 May 2023 15:18:31 +0800 Subject: [PATCH] fix --- domain/model/cp_m/rank.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/domain/model/cp_m/rank.go b/domain/model/cp_m/rank.go index 42a43d9..27451f8 100644 --- a/domain/model/cp_m/rank.go +++ b/domain/model/cp_m/rank.go @@ -41,8 +41,8 @@ func AddCpDayRank(model *domain.Model, cpRelation CpRelationTmp, score mysql.Num func PageCpDayRank(model *domain.Model, beginDate, endDate string, offset, limit int) []CpDayRank { var ranks []CpDayRank if err := model.DB().Table("cp_day_rank r").Joins("INNER JOIN cp_relation c ON c.id = r.cp_id"). - Where("r.date BETWEEN ? AND ?", beginDate, endDate). - Order("r.score DESC").Offset(offset).Limit(limit).Select("r.*").Find(&ranks).Error; err != nil { + Where("r.date BETWEEN ? AND ?", beginDate, endDate).Group("cp_id").Select("cp_id,r.user_id1,r.user_id2,SUM(r.score) score"). + Order("r.score DESC").Offset(offset).Limit(limit).Find(&ranks).Error; err != nil { model.Log.Errorf("PageCpDayRank fail:%v", err) } return ranks @@ -52,7 +52,8 @@ func PageCpDayRank(model *domain.Model, beginDate, endDate string, offset, limit func GetCpDayRank(model *domain.Model, beginDate, endDate string, cpId mysql.ID) CpDayRank { var rank CpDayRank if err := model.DB().Table("cp_day_rank"). - Where("date BETWEEN ? AND ?", beginDate, endDate).Where("cp_id = ?", cpId).First(&rank).Error; err != nil { + Where("date BETWEEN ? AND ?", beginDate, endDate).Where("cp_id = ?", cpId).Select("cp_id,user_id1,user_id2,SUM(score) score"). + First(&rank).Error; err != nil { model.Log.Errorf("GetCpDayRank fail:%v", err) } return rank -- 2.22.0