Commit ec2ad090 authored by hujiebin's avatar hujiebin

feat:临时兼容

parent 32c52c48
......@@ -251,7 +251,7 @@ type CvCountry struct {
AreaCodeName *string `json:"areaShortName"`
}
func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, originGroupIds []string, pageSize, pageIndex int) ([]JoinedGroupInfo, int, error) {
func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, originGroupIds []string, pageSize, pageIndex int, _roomEnterTime ...map[string]int64) ([]JoinedGroupInfo, int, error) {
model := domain.CreateModel(myService.CtxAndDb)
groupInfo, err := group_m.BatchGetGroupInfo(model, originGroupIds)
......@@ -321,6 +321,9 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, originGrou
if err != nil {
return nil, 0, err
}
if len(_roomEnterTime) > 0 {
roomEnterTime = _roomEnterTime[0]
}
//model.Log.Infof("BuildJoinedGroupInfo, roomEnterTime: %v", roomEnterTime)
// 排序优先级V8.0版本
......
......@@ -4,6 +4,7 @@ import (
"fmt"
"git.hilo.cn/hilo-common/domain"
"github.com/go-redis/redis/v8"
"github.com/spf13/cast"
"hilo-group/_const/redis_key/group_k"
"strconv"
"time"
......@@ -49,16 +50,21 @@ func GetLastRoomVisitors(model *domain.Model, imGroupId string) (userIds []uint6
// 获取最近进入的房间
// 3个月
func GetUserRecentRooms(model *domain.Model, userId uint64) (imGroupIds []string) {
func GetUserRecentRooms(model *domain.Model, userId uint64) (imGroupIds []string, roomEnterTime map[string]int64) {
roomEnterTime = make(map[string]int64)
userKey := group_k.GetUserEnterRoomUserKey(userId)
var err error
imGroupIds, err = model.Redis.ZRangeByScore(model, userKey, &redis.ZRangeBy{
res, err := model.Redis.ZRangeByScoreWithScores(model, userKey, &redis.ZRangeBy{
Min: fmt.Sprintf("%d", time.Now().AddDate(0, -3, 0).Unix()),
Max: "+inf",
}).Result()
if err != nil {
return
}
for _, v := range res {
imGroupId := cast.ToString(v.Member)
imGroupIds = append(imGroupIds, imGroupId)
roomEnterTime[imGroupId] = int64(v.Score)
}
return
}
......
......@@ -718,7 +718,7 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) {
//if err != nil {
// return myContext, err
//}
rec := group_c.GetUserRecentRooms(model, userId)
rec, roomEnterTime := group_c.GetUserRecentRooms(model, userId)
myGroups, err := group_m.FindGroupMapByOwner(model, userId)
if err != nil {
......@@ -734,7 +734,7 @@ func GetRecentGroup(c *gin.Context) (*mycontext.MyContext, error) {
}
myService := domain.CreateService(myContext)
result, _, err := group_cv.BuildJoinedGroupInfo(myService, userId, groupIds, 30, 1)
result, _, err := group_cv.BuildJoinedGroupInfo(myService, userId, groupIds, 30, 1,roomEnterTime)
if 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