Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-user
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenweijian
hilo-user
Commits
8c36debc
Commit
8c36debc
authored
Sep 03, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/group_room_living' into 'master'
Feature/group room living See merge request
!35
parents
484f4349
e3fb3ad7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
4 deletions
+26
-4
room.go
domain/model/group_m/room.go
+2
-4
router.go
route/router.go
+24
-0
No files found.
domain/model/group_m/room.go
View file @
8c36debc
...
...
@@ -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
.
Redis
Cluster
.
ZRemRangeByScore
(
model
,
key
,
"0"
,
strconv
.
FormatInt
(
time
.
Now
()
.
Unix
()
-
expireSec
,
10
))
.
Err
()
}
...
...
route/router.go
View file @
8c36debc
...
...
@@ -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
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment