From 522484456239a17caad89850c4ad7aa19cf89f5f Mon Sep 17 00:00:00 2001 From: iamhujiebin <458249864@qq.com> Date: Sun, 6 Aug 2023 11:23:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:redis=E8=AF=BB=E5=8F=96=E6=9C=80=E8=BF=91?= =?UTF-8?q?=E8=BF=9B=E6=88=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- route/group_r/group_list.go | 41 ++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/route/group_r/group_list.go b/route/group_r/group_list.go index 03e570d..8a21ddf 100644 --- a/route/group_r/group_list.go +++ b/route/group_r/group_list.go @@ -16,6 +16,7 @@ import ( "hilo-group/cv/group_power_cv" "hilo-group/cv/medal_cv" "hilo-group/cv/user_cv" + "hilo-group/domain/cache/group_c" "hilo-group/domain/cache/res_c" "hilo-group/domain/cache/room_c" "hilo-group/domain/model/game_m" @@ -703,11 +704,12 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) { model := domain.CreateModelContext(myContext) - uer := group_m.UserEnterRoom{UserId: userId} - rec, err := uer.Find(model.Db) - if err != nil { - return myContext, err - } + //uer := group_m.UserEnterRoom{UserId: userId} + //rec, err := uer.Find(model.Db) + //if err != nil { + // return myContext, err + //} + rec := group_c.GetUserRecentRooms(model, userId) myGroups, err := group_m.FindGroupMapByOwner(model, userId) if err != nil { @@ -716,9 +718,9 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) { // 剔除自己创建的群 groupIds := make([]string, 0) - for _, i := range rec { - if _, ok := myGroups[i.GroupId]; !ok { - groupIds = append(groupIds, i.GroupId) + for _, groupId := range rec { + if _, ok := myGroups[groupId]; !ok { + groupIds = append(groupIds, groupId) } } @@ -827,19 +829,20 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) { return myContext, err } - uer := group_m.UserEnterRoom{GroupId: groupId} - rows, err := uer.Find(model.Db) - if err != nil { - return myContext, err - } + //uer := group_m.UserEnterRoom{GroupId: groupId} + //rows, err := uer.Find(model.Db) + //if err != nil { + // return myContext, err + //} + rows := group_c.GetLastRoomVisitors(model, groupId) - now := time.Now() - t := now.AddDate(0, 0, -15) // 只要15天内进入房间的人 + //now := time.Now() + //t := now.AddDate(0, 0, -15) // 只要15天内进入房间的人 userIds := make([]uint64, 0) - for _, i := range rows { - if i.EnterTime.After(t) { - userIds = append(userIds, i.UserId) - } + for _, u := range rows { + //if i.EnterTime.After(t) { + userIds = append(userIds, u) + //} } users, err := user_m.GetUserMapByIds(model, userIds) if err != nil { -- 2.22.0