Commit 2ee63f75 authored by iamhujiebin's avatar iamhujiebin

Merge branch 'feature/group_room_living' into test

parents 1ad2e2df 46b62868
......@@ -4,7 +4,6 @@ import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/resource/redisCli"
"hilo-user/_const/redis_key/group_k"
"hilo-user/myerr"
"strconv"
......@@ -26,7 +25,7 @@ func RoomLivingUserIdFilter(model *domain.Model, userIds []mysql.ID) (map[mysql.
return nil, myerr.WrapErr(err)
}
groupUserIdstrs, err := redisCli.GetRedis().ZRange(model, key, 0, -1).Result()
groupUserIdstrs, err := model.RedisCluster.ZRange(model, key, 0, -1).Result()
if err != nil {
return nil, myerr.WrapErr(err)
}
......@@ -34,7 +33,6 @@ func RoomLivingUserIdFilter(model *domain.Model, userIds []mysql.ID) (map[mysql.
resultUserSet := map[mysql.ID]string{}
for i, _ := range groupUserIdstrs {
tempGroupUid, userId := analysisMemberStr(groupUserIdstrs[i])
mylogrus.MyLog.Debugf("RoomLivingUserIdFilter, analysisMemberStr %s, %d", tempGroupUid, userId)
if _, flag := userIdSet[userId]; flag {
resultUserSet[userId] = tempGroupUid
......@@ -44,7 +42,7 @@ func RoomLivingUserIdFilter(model *domain.Model, userIds []mysql.ID) (map[mysql.
}
func ClearExpired(model *domain.Model, key string, expireSec int64) error {
return model.Redis.ZRemRangeByScore(model, key,
return model.RedisCluster.ZRemRangeByScore(model, key,
"0", strconv.FormatInt(time.Now().Unix()-expireSec, 10)).Err()
}
......
......@@ -5,9 +5,11 @@ import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext"
"github.com/gin-gonic/gin"
"github.com/go-redis/redis/v8"
ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles"
"hilo-user/_const/enum/msg_e"
"hilo-user/_const/redis_key/group_k"
_ "hilo-user/docs"
"hilo-user/domain/model/msg_m"
"hilo-user/resp"
......@@ -88,6 +90,7 @@ func InitRouter() *gin.Engine {
innerProp.POST("/ride/send", wrapper(user_r.SendUserRide)) // 下发座驾
}
r.GET("/test", wrapper(Test))
r.GET("/sync/group_room_living", wrapper(SyncGroupRoomLiving))
return r
}
......@@ -103,3 +106,24 @@ func Test(c *gin.Context) (*mycontext.MyContext, error) {
resp.ResponseOk(c, struct{}{})
return myCtx, nil
}
func SyncGroupRoomLiving(c *gin.Context) (*mycontext.MyContext, error) {
myCtx := mycontext.CreateMyContext(c.Keys)
var model = domain.CreateModelContext(myCtx)
key := group_k.GetPrefixGroupRoomLiving()
res, err := model.Redis.ZRangeWithScores(model, key, 0, -1).Result()
if err != nil {
return myCtx, err
}
for _, v := range res {
err := model.RedisCluster.ZAdd(model, key, &redis.Z{
Score: v.Score,
Member: v.Member,
}).Err()
if err != nil {
return myCtx, err
}
}
resp.ResponseOk(c, struct{}{})
return myCtx, 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