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
a253184f
Commit
a253184f
authored
Apr 13, 2023
by
chenweijian
Committed by
hujiebin
Apr 13, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
接入trtc
parent
11aa56d4
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
99 additions
and
5 deletions
+99
-5
enum.go
_const/enum/group_e/enum.go
+8
-0
group.go
cv/group_cv/group.go
+1
-0
debug.ini
debug.ini
+3
-0
groupInfo.go
domain/model/group_m/groupInfo.go
+24
-0
group_op.go
domain/service/group_s/group_op.go
+10
-2
local.ini
local.ini
+3
-0
trtc.sql
mysql/trtc.sql
+9
-0
release.ini
release.ini
+3
-0
group_op.go
route/group_r/group_op.go
+28
-1
group_power_test.go
test/group_power_test.go
+10
-2
No files found.
_const/enum/group_e/enum.go
View file @
a253184f
...
...
@@ -156,3 +156,11 @@ var GROUP_NOBLE4_JOIN_LIMIT uint = 1000
var
GROUP_ROLE_PERSONAL_VIEW_LIMIT
=
5
var
GROUP_MANAGER_LIMIT
uint
=
30
var
GROUP_ADMIN_LIMIT
uint
=
50
type
GroupProvider
=
uint8
const
(
// 群组声音供应商
GroupProvider_SW
GroupProvider
=
0
// 声网
GroupProvider_TRTC
GroupProvider
=
1
// 腾讯trtc
)
cv/group_cv/group.go
View file @
a253184f
...
...
@@ -221,6 +221,7 @@ type GroupChannelId struct {
Token
string
`json:"token"`
AgoraId
uint32
`json:"agoraId"`
MicNumType
uint8
`json:"micNumType"`
Provider
uint8
`json:"provider"`
// 供应商 1.声网 2.腾讯trtc
}
//国籍视图
...
...
debug.ini
View file @
a253184f
...
...
@@ -72,6 +72,9 @@ APP_CERTIFICATE=ff29c100a613433db82324e8411eabc8
CUSTOMER_KEY
=
6b132c0ff7164560a2bc53fda06ea85a
CUSTOMER_SECRET
=
eedad2cd16d24834990d5450ace9f1ce
CALLBACK_SECRET
=
n_ZizS_N8
[TRTC]
APP_ID
=
1400548270
APP_CERTIFICATE
=
321bd60f73096b059c7350f1cd97d51028850b34fa58c5c0d26bb4a19e783de8
[CHECKOUT]
AUTHORIZATION
=
sk_test_9b5e771c-5a3f-4a8d-a4da-31b19bd43d83
URL
=
https://api.sandbox.checkout.com/hosted-payments
...
...
domain/model/group_m/groupInfo.go
View file @
a253184f
...
...
@@ -7,6 +7,7 @@ import (
"git.hilo.cn/hilo-common/utils"
"github.com/bluele/gcache"
"gorm.io/gorm"
"gorm.io/gorm/clause"
"hilo-group/_const/enum/group_e"
"hilo-group/myerr"
"hilo-group/myerr/bizerr"
...
...
@@ -566,3 +567,26 @@ func GetFamilyRooms(model *domain.Model, familyId uint64, pageSize, pageIndex in
return
res
,
nextIdx
,
hasNext
,
nil
}
func
IsUseTRTC
(
model
*
domain
.
Model
,
imGroupId
string
)
bool
{
var
count
int64
if
err
:=
model
.
DB
()
.
Table
(
"group_trtc"
)
.
Where
(
"im_group_id=?"
,
imGroupId
)
.
Count
(
&
count
)
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"IsUseTRTC err:%v, groupId:%s"
,
err
,
imGroupId
)
return
false
}
return
count
>
0
}
type
GroupTrtc
struct
{
mysql
.
Entity
ImGroupId
mysql
.
Str
}
// 初始化trtc房间
func
InitTRTC
(
model
*
domain
.
Model
,
imGroupId
string
)
error
{
if
err
:=
model
.
DB
()
.
Model
(
GroupTrtc
{})
.
Clauses
(
clause
.
OnConflict
{
DoNothing
:
true
})
.
Create
(
&
GroupTrtc
{
ImGroupId
:
imGroupId
})
.
Error
;
err
!=
nil
{
model
.
Log
.
Errorf
(
"InitTRTC err:%v, groupId:%s"
,
err
,
imGroupId
)
return
err
}
return
nil
}
domain/service/group_s/group_op.go
View file @
a253184f
...
...
@@ -6,11 +6,13 @@ import (
"fmt"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/resource/config"
"git.hilo.cn/hilo-common/resource/mysql"
"git.hilo.cn/hilo-common/resource/redisCli"
"git.hilo.cn/hilo-common/rpc"
"git.hilo.cn/hilo-common/sdk/agora"
"git.hilo.cn/hilo-common/sdk/tencentyun"
"git.hilo.cn/hilo-common/sdk/trtc"
"git.hilo.cn/hilo-common/utils"
"gorm.io/gorm"
"hilo-group/_const/enum/group_e"
...
...
@@ -115,7 +117,7 @@ func (s *GroupService) LeaveGroupMember(model *domain.Model, groupId string, use
}
//进入房间, 返回channelId, err
func
(
s
*
GroupService
)
GroupIn
(
userId
uint64
,
externalId
string
,
groupUuid
string
,
password
,
imei
,
ip
string
)
(
string
,
string
,
error
)
{
func
(
s
*
GroupService
)
GroupIn
(
userId
uint64
,
externalId
string
,
groupUuid
string
,
password
,
imei
,
ip
string
,
provider
group_e
.
GroupProvider
)
(
string
,
string
,
error
)
{
var
channelId
string
var
token
string
err
:=
s
.
svc
.
Transactional
(
func
()
error
{
...
...
@@ -171,7 +173,13 @@ func (s *GroupService) GroupIn(userId uint64, externalId string, groupUuid strin
if
err
!=
nil
{
return
err
}
channelId
,
token
,
err
=
agora
.
CreateGroupAgora
(
groupInfo
.
ChannelId
,
uint32
(
userId
))
if
provider
==
group_e
.
GroupProvider_TRTC
{
channelId
=
groupInfo
.
ChannelId
token
=
trtc
.
CreateGroupTRTCUserSig
(
userId
,
config
.
GetTRTCConfig
())
model
.
Log
.
Infof
(
"enter trtc group userId:%v, groupId:%v"
,
userId
,
groupUuid
)
}
else
{
channelId
,
token
,
err
=
agora
.
CreateGroupAgora
(
groupInfo
.
ChannelId
,
uint32
(
userId
))
}
if
err
!=
nil
{
return
err
}
else
{
...
...
local.ini
View file @
a253184f
...
...
@@ -72,6 +72,9 @@ APP_CERTIFICATE=ff29c100a613433db82324e8411eabc8
CUSTOMER_KEY
=
6b132c0ff7164560a2bc53fda06ea85a
CUSTOMER_SECRET
=
eedad2cd16d24834990d5450ace9f1ce
CALLBACK_SECRET
=
n_ZizS_N8
[TRTC]
APP_ID
=
1400548270
APP_CERTIFICATE
=
321bd60f73096b059c7350f1cd97d51028850b34fa58c5c0d26bb4a19e783de8
[CHECKOUT]
AUTHORIZATION
=
sk_test_9b5e771c-5a3f-4a8d-a4da-31b19bd43d83
URL
=
https://api.sandbox.checkout.com/hosted-payments
...
...
mysql/trtc.sql
0 → 100644
View file @
a253184f
-
CREATE
TABLE
`group_trtc`
(
`id`
bigint
unsigned
NOT
NULL
AUTO_INCREMENT
COMMENT
'id'
,
`im_group_id`
char
(
32
)
COLLATE
utf8mb4_unicode_ci
NOT
NULL
,
`created_time`
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
,
`updated_time`
timestamp
NOT
NULL
DEFAULT
CURRENT_TIMESTAMP
ON
UPDATE
CURRENT_TIMESTAMP
,
PRIMARY
KEY
(
`id`
),
UNIQUE
KEY
`im_group_id`
(
`im_group_id`
),
KEY
`created_time`
(
`created_time`
)
USING
BTREE
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8mb4
COLLATE
=
utf8mb4_unicode_ci
COMMENT
=
'使用trtc的群组'
;
\ No newline at end of file
release.ini
View file @
a253184f
...
...
@@ -72,6 +72,9 @@ APP_ID=6291d069123642d9929a49c734c50719
APP_CERTIFICATE
=
d5de40350aa54e60bcdce90c71e9598a
CUSTOMER_KEY
=
6b132c0ff7164560a2bc53fda06ea85a
CUSTOMER_SECRET
=
eedad2cd16d24834990d5450ace9f1ce
[TRTC]
APP_ID
=
40000066
APP_CERTIFICATE
=
3ab68ea5bddc8774d90b8c764ae71188914bd5fd06f30b28790c51e44ca7885c
[CHECKOUT]
AUTHORIZATION
=
sk_fca6e213-b7df-4bd7-99f4-7c0a9f7c778c
URL
=
https://api.checkout.com/hosted-payments
...
...
route/group_r/group_op.go
View file @
a253184f
...
...
@@ -1751,7 +1751,33 @@ func GroupIn(c *gin.Context) (*mycontext.MyContext, error) {
}
model
.
Log
.
Infof
(
"GroupIn ip userId:%v,imGroupId:%v,ip:%v,imei:%v"
,
userId
,
groupId
,
ip
,
imei
)
if
channelId
,
token
,
err
:=
group_s
.
NewGroupService
(
myContext
)
.
GroupIn
(
userId
,
externalId
,
groupId
,
password
,
imei
,
ip
);
err
!=
nil
{
provider
:=
group_e
.
GroupProvider_SW
if
group_m
.
IsUseTRTC
(
model
,
groupId
)
{
provider
=
group_e
.
GroupProvider_TRTC
}
else
{
if
time
.
Now
()
.
Unix
()
>
1683820800
{
// todo 1683820800=5月2号,等过审再修改
roomUser
,
err
:=
group_m
.
GetRoomOnlineUser
(
myContext
,
groupId
)
if
err
==
nil
&&
roomUser
.
Total
==
0
{
if
err
:=
group_m
.
InitTRTC
(
model
,
groupId
);
err
!=
nil
{
return
myContext
,
err
}
provider
=
group_e
.
GroupProvider_TRTC
model
.
Log
.
Infof
(
"auto shift trtc room groupId:%v,%+v-%v"
,
groupId
,
roomUser
,
err
)
}
}
}
if
provider
==
group_e
.
GroupProvider_TRTC
{
// 版本升级提示,旧版本(3.6.0以下),提示升级
_
,
major
,
minor
,
_
,
err
:=
req
.
GetAppVersion
(
c
)
if
err
!=
nil
{
return
myContext
,
err
}
if
(
major
<
3
)
||
(
major
==
3
&&
minor
<
6
)
{
return
myContext
,
bizerr
.
UpgradeRequired
}
}
if
channelId
,
token
,
err
:=
group_s
.
NewGroupService
(
myContext
)
.
GroupIn
(
userId
,
externalId
,
groupId
,
password
,
imei
,
ip
,
provider
);
err
!=
nil
{
return
myContext
,
err
}
else
{
// 加入房间缓存
...
...
@@ -1767,6 +1793,7 @@ func GroupIn(c *gin.Context) (*mycontext.MyContext, error) {
Token
:
token
,
AgoraId
:
uint32
(
userId
),
MicNumType
:
gi
.
MicNumType
,
Provider
:
provider
,
})
// v2.26及以后,客户端自己加TIM群,不再由服务器代加
...
...
test/group_power_test.go
View file @
a253184f
package
test
import
(
"fmt"
"git.hilo.cn/hilo-common/domain"
"hilo-group/domain/model/groupPower_m"
"hilo-group/domain/model/group_m"
"testing"
)
func
TestGetAllGroupPowerOwner
(
t
*
testing
.
T
)
{
owners
,
err
:=
groupPower_m
.
BatchGetAllGroupPowerUsers
(
domain
.
CreateModelNil
()
)
owners
,
_
,
err
:=
groupPower_m
.
BatchGetAllGroupPowerUsers
(
domain
.
CreateModelNil
(),
1
,
1
)
println
(
owners
,
err
)
}
func
TestGetGroupPowerMonthStartTop1
(
t
*
testing
.
T
)
{
res
,
err
:=
groupPower_m
.
GetGroupPowerMonthStartTop1
(
domain
.
CreateModelNil
(),
250
)
println
(
res
,
err
)
println
(
res
,
err
)
}
func
TestIsUseTRTC
(
t
*
testing
.
T
)
{
if
group_m
.
IsUseTRTC
(
domain
.
CreateModelNil
(),
"@TGS#3I57DMRIB"
)
{
fmt
.
Println
(
"true--------------"
)
}
}
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