Commit 46b62868 authored by iamhujiebin's avatar iamhujiebin

SyncGroupRoomLiving

parent fa6cfda8
...@@ -5,9 +5,11 @@ import ( ...@@ -5,9 +5,11 @@ import (
"git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mycontext" "git.hilo.cn/hilo-common/mycontext"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/go-redis/redis/v8"
ginSwagger "github.com/swaggo/gin-swagger" ginSwagger "github.com/swaggo/gin-swagger"
"github.com/swaggo/gin-swagger/swaggerFiles" "github.com/swaggo/gin-swagger/swaggerFiles"
"hilo-user/_const/enum/msg_e" "hilo-user/_const/enum/msg_e"
"hilo-user/_const/redis_key/group_k"
_ "hilo-user/docs" _ "hilo-user/docs"
"hilo-user/domain/model/msg_m" "hilo-user/domain/model/msg_m"
"hilo-user/resp" "hilo-user/resp"
...@@ -88,6 +90,7 @@ func InitRouter() *gin.Engine { ...@@ -88,6 +90,7 @@ func InitRouter() *gin.Engine {
innerProp.POST("/ride/send", wrapper(user_r.SendUserRide)) // 下发座驾 innerProp.POST("/ride/send", wrapper(user_r.SendUserRide)) // 下发座驾
} }
r.GET("/test", wrapper(Test)) r.GET("/test", wrapper(Test))
r.GET("/sync/group_room_living", wrapper(SyncGroupRoomLiving))
return r return r
} }
...@@ -103,3 +106,24 @@ func Test(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -103,3 +106,24 @@ func Test(c *gin.Context) (*mycontext.MyContext, error) {
resp.ResponseOk(c, struct{}{}) resp.ResponseOk(c, struct{}{})
return myCtx, nil 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