diff --git a/route/router.go b/route/router.go index ef4619ca97427047027b40a019169d2d4a651eec..14dbf431313769be975e6750657a7b7c80b846c8 100644 --- a/route/router.go +++ b/route/router.go @@ -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 +}