Commit e843d51f authored by hujiebin's avatar hujiebin

fix:

parent fe887a88
...@@ -45,7 +45,7 @@ func UpdateCpAchievement(model *domain.Model, cpId, userId1, userId2 mysql.ID, T ...@@ -45,7 +45,7 @@ func UpdateCpAchievement(model *domain.Model, cpId, userId1, userId2 mysql.ID, T
func GetCpAchievements(model *domain.Model) []CpAchievement { func GetCpAchievements(model *domain.Model) []CpAchievement {
var achievements []CpAchievement var achievements []CpAchievement
subQuery := model.DB().Table("cp_achievement a").Joins("JOIN cp_relation r ON a.cp_id = r.id").Select("type,MAX(score) AS max_score").Group("type") subQuery := model.DB().Table("cp_achievement a").Joins("JOIN cp_relation r ON a.cp_id = r.id").Select("type,MAX(score) AS max_score").Group("type")
if err := model.DB().Model(CpAchievement{}).Where("(type, score) IN (?)", subQuery).Find(&achievements).Error; err != nil { if err := model.DB().Model(CpAchievement{}).Joins("INNER JOIN cp_relation r ON cp_id = r.id").Where("(type, score) IN (?)", subQuery).Find(&achievements).Error; err != nil {
model.Log.Errorf("GetAchievements fail:%v", err) model.Log.Errorf("GetAchievements fail:%v", err)
} }
return achievements return achievements
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment