From 1e4f388d08489a447c2492a73cec4ec7df75b791 Mon Sep 17 00:00:00 2001 From: chenweijian <820961417@qq.com> Date: Fri, 21 Apr 2023 16:35:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=B6=E6=97=8F=E6=B6=88=E6=81=AF=E5=85=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cv/group_cv/group.go | 17 +++++++++-------- domain/model/group_m/groupMedal.go | 7 +++++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/cv/group_cv/group.go b/cv/group_cv/group.go index 28cb11b..54e20f2 100644 --- a/cv/group_cv/group.go +++ b/cv/group_cv/group.go @@ -357,6 +357,15 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, groupIds [ } medals := make([]medal_cv.PicElement, 0) + // 补上房间流水勋章 + var pe *medal_cv.PicElement + _, pe, err = medal_cv.GetGroupConsumeMedal(model, i) + if err != nil { + model.Log.Infof("BuildJoinedGroupInfo: GetGroupConsumeMedal: %s", err.Error()) + } else if pe != nil { + medals = append(medals, medal_cv.PicElement{PicUrl: pe.PicUrl}) + } + // res_medal if m, ok := groupMedals[i]; ok { for _, j := range m { mId := uint32(j) @@ -367,14 +376,6 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, groupIds [ } } } - // 补上房间流水勋章 - var pe *medal_cv.PicElement - _, pe, err = medal_cv.GetGroupConsumeMedal(model, i) - if err != nil { - model.Log.Infof("BuildJoinedGroupInfo: GetGroupConsumeMedal: %s", err.Error()) - } else if pe != nil { - medals = append(medals, medal_cv.PicElement{PicUrl: pe.PicUrl}) - } var password *string = nil if len(g.Password) > 0 && g.Owner != myUserId { diff --git a/domain/model/group_m/groupMedal.go b/domain/model/group_m/groupMedal.go index f79e621..71f2424 100644 --- a/domain/model/group_m/groupMedal.go +++ b/domain/model/group_m/groupMedal.go @@ -3,9 +3,11 @@ package group_m import ( "git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/resource/mysql" + "git.hilo.cn/hilo-common/utils" "gorm.io/gorm" "gorm.io/gorm/clause" "hilo-group/myerr" + "time" ) //群组勋章 @@ -30,7 +32,6 @@ func (groupInfo *GroupInfo) GroupMedalMgrAdd(model *domain.Model, resMedalId uin } } - func GetGroupMedalOrErr(model *domain.Model, id mysql.ID) (*GroupMedal, error) { groupMedal := GroupMedal{} if err := model.Db.Model(&GroupMedal{}).First(&groupMedal, id).Error; err != nil { @@ -65,7 +66,9 @@ 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).Find(&rows).Error; err != nil { + 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)). + Find(&rows).Error; err != nil { return nil, err } result := make(map[string][]uint64, 0) -- 2.22.0