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
fe84d78f
Commit
fe84d78f
authored
Jul 28, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into feature/4.3_cwj
parents
0615a602
d2e3fc55
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
2 deletions
+96
-2
enter_room.go
_const/redis_key/group_k/enter_room.go
+21
-0
enter_room.go
domain/cache/group_c/enter_room.go
+71
-0
event_init.go
domain/service/event_s/event_init.go
+2
-0
release.ini
release.ini
+1
-1
group_op.go
route/group_r/group_op.go
+1
-1
No files found.
_const/redis_key/group_k/enter_room.go
0 → 100644
View file @
fe84d78f
package
group_k
import
(
"fmt"
"hilo-group/_const/redis_key"
)
// 用户进房的key
const
(
UserEnterRoomPrefix
=
"uer:"
UserEnterRoomUserKey
=
UserEnterRoomPrefix
+
"u:${user_id}"
UserEnterRoomGroupKey
=
UserEnterRoomPrefix
+
"g:${user_id}"
)
func
GetUserEnterRoomUserKey
(
userId
uint64
)
string
{
return
redis_key
.
ReplaceKey
(
UserEnterRoomUserKey
,
fmt
.
Sprintf
(
"%d"
,
userId
))
}
func
GetUserEnterRoomGroupKey
(
groupId
string
)
string
{
return
redis_key
.
ReplaceKey
(
UserEnterRoomGroupKey
,
groupId
)
}
domain/cache/group_c/enter_room.go
0 → 100644
View file @
fe84d78f
package
group_c
import
(
"fmt"
"git.hilo.cn/hilo-common/domain"
"github.com/go-redis/redis/v8"
"hilo-group/_const/redis_key/group_k"
"strconv"
"time"
)
// 用户进房
func
ZAddUserEnterRoom
(
model
*
domain
.
Model
,
userId
uint64
,
imGroupId
string
)
{
userKey
:=
group_k
.
GetUserEnterRoomUserKey
(
userId
)
groupKey
:=
group_k
.
GetUserEnterRoomGroupKey
(
imGroupId
)
if
err
:=
model
.
Redis
.
ZAdd
(
model
,
userKey
,
&
redis
.
Z
{
Score
:
float64
(
time
.
Now
()
.
Unix
()),
Member
:
imGroupId
,
})
.
Err
();
err
!=
nil
{
model
.
Log
.
Errorf
(
"ZAddUserEnterRoom user fail:%v"
,
err
)
}
if
err
:=
model
.
Redis
.
ZAdd
(
model
,
groupKey
,
&
redis
.
Z
{
Score
:
float64
(
time
.
Now
()
.
Unix
()),
Member
:
userId
,
})
.
Err
();
err
!=
nil
{
model
.
Log
.
Errorf
(
"ZAddUserEnterRoom room fail:%v"
,
err
)
}
}
// 获取最近房间访客
func
GetLastRoomVisitors
(
model
*
domain
.
Model
,
imGroupId
string
)
(
userIds
[]
uint64
)
{
groupKey
:=
group_k
.
GetUserEnterRoomGroupKey
(
imGroupId
)
res
,
err
:=
model
.
Redis
.
ZRangeByScore
(
model
,
groupKey
,
&
redis
.
ZRangeBy
{
Min
:
fmt
.
Sprintf
(
"%d"
,
time
.
Now
()
.
AddDate
(
0
,
0
,
-
15
)
.
Unix
()),
Max
:
"+inf"
,
})
.
Result
()
if
err
!=
nil
{
return
}
for
_
,
u
:=
range
res
{
uid
,
_
:=
strconv
.
ParseUint
(
u
,
10
,
64
)
if
uid
>
0
{
userIds
=
append
(
userIds
,
uid
)
}
}
return
}
// 获取最近进入的房间
func
GetUserRecentRooms
(
model
*
domain
.
Model
,
userId
uint64
)
(
imGroupIds
[]
string
)
{
userKey
:=
group_k
.
GetUserEnterRoomUserKey
(
userId
)
var
err
error
imGroupIds
,
err
=
model
.
Redis
.
ZRangeByScore
(
model
,
userKey
,
&
redis
.
ZRangeBy
{
Min
:
fmt
.
Sprintf
(
"%d"
,
time
.
Now
()
.
AddDate
(
0
,
0
,
-
15
)
.
Unix
()),
Max
:
"+inf"
,
})
.
Result
()
if
err
!=
nil
{
return
}
return
}
// 清理房间访客
// 15天前访问的
func
RemoveRoomVisitors
(
model
*
domain
.
Model
,
imGroupId
string
)
{
groupKey
:=
group_k
.
GetUserEnterRoomGroupKey
(
imGroupId
)
err
:=
model
.
Redis
.
ZRemRangeByScore
(
model
,
groupKey
,
"-inf"
,
fmt
.
Sprintf
(
"%d"
,
time
.
Now
()
.
AddDate
(
0
,
0
,
-
15
)
.
Unix
()))
.
Err
()
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"RemoveRoomVisitors fail:%v"
,
err
)
}
}
domain/service/event_s/event_init.go
View file @
fe84d78f
...
@@ -10,6 +10,7 @@ import (
...
@@ -10,6 +10,7 @@ import (
"hilo-group/_const/enum/group_e"
"hilo-group/_const/enum/group_e"
"hilo-group/_const/enum/msg_e"
"hilo-group/_const/enum/msg_e"
"hilo-group/_const/enum/task_e"
"hilo-group/_const/enum/task_e"
"hilo-group/domain/cache/group_c"
"hilo-group/domain/event/gift_ev"
"hilo-group/domain/event/gift_ev"
"hilo-group/domain/event/group_ev"
"hilo-group/domain/event/group_ev"
"hilo-group/domain/event/group_power_ev"
"hilo-group/domain/event/group_power_ev"
...
@@ -246,6 +247,7 @@ func GroupEvents() {
...
@@ -246,6 +247,7 @@ func GroupEvents() {
}
}
err
:=
uer
.
Save
(
model
.
Db
)
err
:=
uer
.
Save
(
model
.
Db
)
model
.
Log
.
Infof
(
"AddGroupInAsync, UserEnterRoom err: %v"
,
err
)
model
.
Log
.
Infof
(
"AddGroupInAsync, UserEnterRoom err: %v"
,
err
)
group_c
.
ZAddUserEnterRoom
(
model
,
event
.
UserId
,
event
.
GroupId
)
// redis存储
return
err
return
err
})
})
...
...
release.ini
View file @
fe84d78f
[DATABASE]
[DATABASE]
MYSQL_HOST
=
ua4papc3hmgqf351pbej-rw4rm.rwlb.dubai.rds.aliyuncs.com
MYSQL_HOST
=
ua4papc3hmgqf351pbej-rw4rm.rwlb.dubai.rds.aliyuncs.com
MYSQL_USERNAME
=
nextvideo
MYSQL_USERNAME
=
hilo_group
MYSQL_PASSWORD
=
ihlUwI4nhi9W88MI
MYSQL_PASSWORD
=
ihlUwI4nhi9W88MI
MYSQL_DB
=
hilo
MYSQL_DB
=
hilo
[DATABASECODE]
[DATABASECODE]
...
...
route/group_r/group_op.go
View file @
fe84d78f
...
@@ -448,7 +448,7 @@ func GetGroupDetail(c *gin.Context) (*mycontext.MyContext, error) {
...
@@ -448,7 +448,7 @@ func GetGroupDetail(c *gin.Context) (*mycontext.MyContext, error) {
result
.
Role
=
group_e
.
GROUP_MEMBER
result
.
Role
=
group_e
.
GROUP_MEMBER
}
}
groupUser
:=
group_m
.
GroupUser
{
Model
:
model
,
UserId
:
userId
}
groupUser
:=
group_m
.
GroupUser
{
Model
:
model
,
UserId
:
userId
,
GroupId
:
groupId
}
msgStatus
,
err
:=
groupUser
.
Get
()
msgStatus
,
err
:=
groupUser
.
Get
()
if
err
!=
nil
{
if
err
!=
nil
{
return
myContext
,
err
return
myContext
,
err
...
...
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