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
24b5fa82
Commit
24b5fa82
authored
Aug 28, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature/mic hget
parent
4fd91f6e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
0 deletions
+34
-0
keys.go
_const/redis_key/mic_k/keys.go
+9
-0
factory.go
domain/model/group_m/factory.go
+15
-0
mic.go
domain/model/group_m/mic.go
+10
-0
No files found.
_const/redis_key/mic_k/keys.go
View file @
24b5fa82
...
@@ -13,6 +13,8 @@ const (
...
@@ -13,6 +13,8 @@ const (
MicGroupPowerOnMic
=
MicPrefix
+
"groupPower:${userId}:${date}"
// 家族内群上麦分钟数
MicGroupPowerOnMic
=
MicPrefix
+
"groupPower:${userId}:${date}"
// 家族内群上麦分钟数
MicUserOnMic
=
MicPrefix
+
"user:onMic:${tz}:${userId}:${date}"
MicUserOnMic
=
MicPrefix
+
"user:onMic:${tz}:${userId}:${date}"
MicGroupOnMic
=
MicPrefix
+
"group:onMic:${groupId}"
// 在群组麦位上的人 hset field:micIndex member:userId
)
)
func
GetUserMicDayInvite
(
userId
mysql
.
ID
)
string
{
func
GetUserMicDayInvite
(
userId
mysql
.
ID
)
string
{
...
@@ -31,3 +33,10 @@ func GetMicGroupPowerOnMic(userId uint64) string {
...
@@ -31,3 +33,10 @@ func GetMicGroupPowerOnMic(userId uint64) string {
func
GetUserOnMicKey
(
userId
uint64
,
tz
,
date
string
)
string
{
func
GetUserOnMicKey
(
userId
uint64
,
tz
,
date
string
)
string
{
return
redis_key
.
ReplaceKey
(
MicUserOnMic
,
tz
,
fmt
.
Sprintf
(
"%d"
,
userId
),
date
)
return
redis_key
.
ReplaceKey
(
MicUserOnMic
,
tz
,
fmt
.
Sprintf
(
"%d"
,
userId
),
date
)
}
}
// 获取群组麦位上的人
// 可能会有数据不一致,已原来麦位的key为准
// 这里用户快速获取群上麦位的人用,代替大量mget命令慢查询
func
GetGroupOnMicUser
(
groupId
string
)
string
{
return
redis_key
.
ReplaceKey
(
MicGroupOnMic
,
groupId
)
}
domain/model/group_m/factory.go
View file @
24b5fa82
...
@@ -13,6 +13,7 @@ import (
...
@@ -13,6 +13,7 @@ import (
"gorm.io/gorm"
"gorm.io/gorm"
"hilo-group/_const/enum/group_e"
"hilo-group/_const/enum/group_e"
"hilo-group/_const/redis_key"
"hilo-group/_const/redis_key"
"hilo-group/_const/redis_key/mic_k"
"hilo-group/myerr"
"hilo-group/myerr"
"strconv"
"strconv"
"strings"
"strings"
...
@@ -242,6 +243,20 @@ func BatchGetAllMicUser(model *domain.Model, groupIds []string) (map[string][]my
...
@@ -242,6 +243,20 @@ func BatchGetAllMicUser(model *domain.Model, groupIds []string) (map[string][]my
if
len
(
groupIds
)
<=
0
{
if
len
(
groupIds
)
<=
0
{
return
result
,
nil
return
result
,
nil
}
}
// 获取群组中上麦用户
for
_
,
groupId
:=
range
groupIds
{
groupMicUserKey
:=
mic_k
.
GetGroupOnMicUser
(
groupId
)
userIds
,
err
:=
model
.
Redis
.
HVals
(
model
,
groupMicUserKey
)
.
Result
()
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"BatchGetAllMicUser fail:%v"
,
err
)
}
for
_
,
userIdStr
:=
range
userIds
{
if
userId
,
_
:=
strconv
.
ParseUint
(
userIdStr
,
10
,
64
);
userId
>
0
{
result
[
groupId
]
=
append
(
result
[
groupId
],
userId
)
}
}
}
return
result
,
nil
keys
:=
make
([]
string
,
0
)
keys
:=
make
([]
string
,
0
)
for
_
,
g
:=
range
groupIds
{
for
_
,
g
:=
range
groupIds
{
...
...
domain/model/group_m/mic.go
View file @
24b5fa82
...
@@ -3,6 +3,7 @@ package group_m
...
@@ -3,6 +3,7 @@ package group_m
import
(
import
(
"context"
"context"
"encoding/json"
"encoding/json"
"fmt"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/resource/config"
"git.hilo.cn/hilo-common/resource/config"
...
@@ -14,6 +15,7 @@ import (
...
@@ -14,6 +15,7 @@ import (
"gorm.io/gorm"
"gorm.io/gorm"
"hilo-group/_const/enum/group_e"
"hilo-group/_const/enum/group_e"
"hilo-group/_const/redis_key"
"hilo-group/_const/redis_key"
"hilo-group/_const/redis_key/mic_k"
"hilo-group/common"
"hilo-group/common"
"hilo-group/domain/model/noble_m"
"hilo-group/domain/model/noble_m"
"hilo-group/domain/model/res_m"
"hilo-group/domain/model/res_m"
...
@@ -255,6 +257,10 @@ func (mic *Mic) In(userId uint64, externalId string) error {
...
@@ -255,6 +257,10 @@ func (mic *Mic) In(userId uint64, externalId string) error {
return
bizerr
.
GroupMicUserHasIn
return
bizerr
.
GroupMicUserHasIn
}
}
// 增加群组中上麦用户
groupMicUserKey
:=
mic_k
.
GetGroupOnMicUser
(
mic
.
GroupUuid
)
mic
.
model
.
Redis
.
HSet
(
mic
.
model
,
groupMicUserKey
,
mic
.
I
,
userId
)
//离开动作已结束,增加到队列中
//离开动作已结束,增加到队列中
MicChangeRPush
(
mic
.
model
,
mic
.
GroupUuid
,
mic
.
I
)
MicChangeRPush
(
mic
.
model
,
mic
.
GroupUuid
,
mic
.
I
)
...
@@ -385,6 +391,10 @@ func (micUser *MicUser) leave(operateUserId uint64, operateExternalId string) er
...
@@ -385,6 +391,10 @@ func (micUser *MicUser) leave(operateUserId uint64, operateExternalId string) er
//return bizerr.GroupMicErr
//return bizerr.GroupMicErr
}
}
// 减少群组中上麦用户
groupMicUserKey
:=
mic_k
.
GetGroupOnMicUser
(
micUser
.
GroupUuid
)
micUser
.
model
.
Redis
.
HDel
(
micUser
.
model
,
groupMicUserKey
,
fmt
.
Sprintf
(
"%d"
,
micUser
.
I
))
//离开动作已结束,增加到队列中
//离开动作已结束,增加到队列中
MicChangeRPush
(
micUser
.
model
,
micUser
.
GroupUuid
,
micUser
.
I
)
MicChangeRPush
(
micUser
.
model
,
micUser
.
GroupUuid
,
micUser
.
I
)
...
...
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