Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-group
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
hujiebin
hilo-group
Commits
77fa9ad1
Commit
77fa9ad1
authored
Aug 06, 2023
by
iamhujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3个月 / 15天
parent
ace0492e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
enter_room.go
_const/redis_key/group_k/enter_room.go
+1
-1
enter_room.go
domain/cache/group_c/enter_room.go
+3
-1
No files found.
_const/redis_key/group_k/enter_room.go
View file @
77fa9ad1
...
@@ -9,7 +9,7 @@ import (
...
@@ -9,7 +9,7 @@ import (
const
(
const
(
UserEnterRoomPrefix
=
"uer:"
UserEnterRoomPrefix
=
"uer:"
UserEnterRoomUserKey
=
UserEnterRoomPrefix
+
"u:${user_id}"
UserEnterRoomUserKey
=
UserEnterRoomPrefix
+
"u:${user_id}"
UserEnterRoomGroupKey
=
UserEnterRoomPrefix
+
"g:${
user
_id}"
UserEnterRoomGroupKey
=
UserEnterRoomPrefix
+
"g:${
group
_id}"
)
)
func
GetUserEnterRoomUserKey
(
userId
uint64
)
string
{
func
GetUserEnterRoomUserKey
(
userId
uint64
)
string
{
...
...
domain/cache/group_c/enter_room.go
View file @
77fa9ad1
...
@@ -28,6 +28,7 @@ func ZAddUserEnterRoom(model *domain.Model, userId uint64, imGroupId string) {
...
@@ -28,6 +28,7 @@ func ZAddUserEnterRoom(model *domain.Model, userId uint64, imGroupId string) {
}
}
// 获取最近房间访客
// 获取最近房间访客
// 15天
func
GetLastRoomVisitors
(
model
*
domain
.
Model
,
imGroupId
string
)
(
userIds
[]
uint64
)
{
func
GetLastRoomVisitors
(
model
*
domain
.
Model
,
imGroupId
string
)
(
userIds
[]
uint64
)
{
groupKey
:=
group_k
.
GetUserEnterRoomGroupKey
(
imGroupId
)
groupKey
:=
group_k
.
GetUserEnterRoomGroupKey
(
imGroupId
)
res
,
err
:=
model
.
Redis
.
ZRangeByScore
(
model
,
groupKey
,
&
redis
.
ZRangeBy
{
res
,
err
:=
model
.
Redis
.
ZRangeByScore
(
model
,
groupKey
,
&
redis
.
ZRangeBy
{
...
@@ -47,11 +48,12 @@ func GetLastRoomVisitors(model *domain.Model, imGroupId string) (userIds []uint6
...
@@ -47,11 +48,12 @@ 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
)
{
userKey
:=
group_k
.
GetUserEnterRoomUserKey
(
userId
)
userKey
:=
group_k
.
GetUserEnterRoomUserKey
(
userId
)
var
err
error
var
err
error
imGroupIds
,
err
=
model
.
Redis
.
ZRangeByScore
(
model
,
userKey
,
&
redis
.
ZRangeBy
{
imGroupIds
,
err
=
model
.
Redis
.
ZRangeByScore
(
model
,
userKey
,
&
redis
.
ZRangeBy
{
Min
:
fmt
.
Sprintf
(
"%d"
,
time
.
Now
()
.
AddDate
(
0
,
0
,
-
15
)
.
Unix
()),
Min
:
fmt
.
Sprintf
(
"%d"
,
time
.
Now
()
.
AddDate
(
0
,
-
3
,
0
)
.
Unix
()),
Max
:
"+inf"
,
Max
:
"+inf"
,
})
.
Result
()
})
.
Result
()
if
err
!=
nil
{
if
err
!=
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