Commit b6951346 authored by chenweijian's avatar chenweijian

房间勋章排序

parent 1e4f388d
......@@ -66,8 +66,10 @@ func BatchGetMedals(db *gorm.DB, groupIds []string) (map[string][]uint64, error)
return nil, nil
}
rows := make([]GroupMedal, 0)
if err := db.Model(&GroupMedal{}).Where("im_group_id IN ?", groupIds).
Where("(expire_at is null or expire_at > ?)", time.Now().Format(utils.DATETIME_FORMAT)).
if err := db.Table("group_medal gm").Joins("left join res_medal rm on rm.id = gm.res_medal_id").
Where("gm.im_group_id IN ?", groupIds).
Where("(gm.expire_at is null or gm.expire_at > ?)", time.Now().Format(utils.DATETIME_FORMAT)).
Order("rm.sort").
Find(&rows).Error; err != nil {
return nil, err
}
......
......@@ -558,7 +558,7 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) {
Joins("INNER JOIN group_medal m ON m.res_medal_id = res_medal.id").
Where("m.im_group_id = ?", groupId).
Where("(expire_at is null or expire_at > ?)", time.Now().Format(utils.DATETIME_FORMAT)).
Order("m.id desc").
Order("res_medal.sort").
Find(&resMedals).Error
if err == nil {
for _, r := range resMedals {
......@@ -1174,7 +1174,7 @@ func GroupMedalAll(c *gin.Context) (*mycontext.MyContext, error) {
if err := mysql.Db.Model(&res_m.ResMedal{}).Joins("inner join group_medal m on m.res_medal_id = res_medal.id").
Where("m.im_group_id = ?", groupId).
Where("(expire_at is null or expire_at > ?)", time.Now().Format(utils.DATETIME_FORMAT)).
Order("m.id desc").Find(&resMedals).Error; err != nil {
Order("m.sort").Find(&resMedals).Error; err != nil {
return myContext, err
}
......
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