Commit 52248445 authored by iamhujiebin's avatar iamhujiebin

feat:redis读取最近进房

parent 77fa9ad1
...@@ -16,6 +16,7 @@ import ( ...@@ -16,6 +16,7 @@ import (
"hilo-group/cv/group_power_cv" "hilo-group/cv/group_power_cv"
"hilo-group/cv/medal_cv" "hilo-group/cv/medal_cv"
"hilo-group/cv/user_cv" "hilo-group/cv/user_cv"
"hilo-group/domain/cache/group_c"
"hilo-group/domain/cache/res_c" "hilo-group/domain/cache/res_c"
"hilo-group/domain/cache/room_c" "hilo-group/domain/cache/room_c"
"hilo-group/domain/model/game_m" "hilo-group/domain/model/game_m"
...@@ -703,11 +704,12 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -703,11 +704,12 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) {
model := domain.CreateModelContext(myContext) model := domain.CreateModelContext(myContext)
uer := group_m.UserEnterRoom{UserId: userId} //uer := group_m.UserEnterRoom{UserId: userId}
rec, err := uer.Find(model.Db) //rec, err := uer.Find(model.Db)
if err != nil { //if err != nil {
return myContext, err // return myContext, err
} //}
rec := group_c.GetUserRecentRooms(model, userId)
myGroups, err := group_m.FindGroupMapByOwner(model, userId) myGroups, err := group_m.FindGroupMapByOwner(model, userId)
if err != nil { if err != nil {
...@@ -716,9 +718,9 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -716,9 +718,9 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) {
// 剔除自己创建的群 // 剔除自己创建的群
groupIds := make([]string, 0) groupIds := make([]string, 0)
for _, i := range rec { for _, groupId := range rec {
if _, ok := myGroups[i.GroupId]; !ok { if _, ok := myGroups[groupId]; !ok {
groupIds = append(groupIds, i.GroupId) groupIds = append(groupIds, groupId)
} }
} }
...@@ -827,19 +829,20 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -827,19 +829,20 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) {
return myContext, err return myContext, err
} }
uer := group_m.UserEnterRoom{GroupId: groupId} //uer := group_m.UserEnterRoom{GroupId: groupId}
rows, err := uer.Find(model.Db) //rows, err := uer.Find(model.Db)
if err != nil { //if err != nil {
return myContext, err // return myContext, err
} //}
rows := group_c.GetLastRoomVisitors(model, groupId)
now := time.Now() //now := time.Now()
t := now.AddDate(0, 0, -15) // 只要15天内进入房间的人 //t := now.AddDate(0, 0, -15) // 只要15天内进入房间的人
userIds := make([]uint64, 0) userIds := make([]uint64, 0)
for _, i := range rows { for _, u := range rows {
if i.EnterTime.After(t) { //if i.EnterTime.After(t) {
userIds = append(userIds, i.UserId) userIds = append(userIds, u)
} //}
} }
users, err := user_m.GetUserMapByIds(model, userIds) users, err := user_m.GetUserMapByIds(model, userIds)
if err != nil { if err != nil {
......
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