Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-common
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-common
Commits
9c426cb6
Commit
9c426cb6
authored
Apr 11, 2023
by
hujiebin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
param tz 时区,0:北京时间 1:沙特时间
parent
e2d8bb39
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
2 deletions
+30
-2
tz.go
_const/enum/timezone_e/tz.go
+21
-0
group.go
rpc/group.go
+8
-1
utils_test.go
script/utils/utils_test.go
+1
-1
No files found.
_const/enum/timezone_e/tz.go
0 → 100644
View file @
9c426cb6
package
timezone_e
import
"time"
type
Timezone
int
const
(
TimezoneBeijing
Timezone
=
0
TimezoneKSA
Timezone
=
1
)
var
Timezones
=
[]
Timezone
{
TimezoneBeijing
,
TimezoneKSA
}
var
(
BeijingTimezoneLoc
=
time
.
FixedZone
(
"CST"
,
8
*
3600
)
// 东八
KSATimezoneLoc
=
time
.
FixedZone
(
"CST"
,
3
*
3600
)
// 东三
)
var
TimezoneLocMap
=
map
[
Timezone
]
*
time
.
Location
{
TimezoneBeijing
:
BeijingTimezoneLoc
,
TimezoneKSA
:
KSATimezoneLoc
,
}
rpc/group.go
View file @
9c426cb6
...
...
@@ -3,6 +3,7 @@ package rpc
import
(
"encoding/json"
"fmt"
"git.hilo.cn/hilo-common/_const/enum/timezone_e"
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/resource/consul"
...
...
@@ -119,8 +120,9 @@ func MGetGroupPower(model *domain.Model, groupPowerIds []mysql.ID) (map[mysql.ID
// 批量获取用户上麦时长
// param day 获取的天,格式 2006-01-02
// param tz 时区,0:北京时间 1:沙特时间
// return userId->seconds
func
MGetUserOnMic
(
model
*
domain
.
Model
,
day
string
,
userIds
[]
mysql
.
ID
)
(
map
[
mysql
.
ID
]
mysql
.
Num
,
error
)
{
func
MGetUserOnMic
(
model
*
domain
.
Model
,
day
string
,
userIds
[]
mysql
.
ID
,
tz
...
timezone_e
.
Timezone
)
(
map
[
mysql
.
ID
]
mysql
.
Num
,
error
)
{
type
Response
struct
{
Code
int
`json:"code"`
Message
string
`json:"message"`
...
...
@@ -135,9 +137,14 @@ func MGetUserOnMic(model *domain.Model, day string, userIds []mysql.ID) (map[mys
userIdsStr
=
append
(
userIdsStr
,
fmt
.
Sprintf
(
"%d"
,
userId
))
}
_url
:=
fmt
.
Sprintf
(
"%v://%v/inner/mic/onMicSeconds"
,
defaultGroupServerScheme
,
getGroupHost
())
_tz
:=
timezone_e
.
TimezoneBeijing
if
len
(
tz
)
>
0
{
_tz
=
tz
[
0
]
}
resp
,
err
:=
HttpGet
(
model
,
_url
,
nil
,
map
[
string
][]
string
{
"ids"
:
userIdsStr
,
"day"
:
{
day
},
"tz"
:
{
fmt
.
Sprintf
(
"%d"
,
_tz
)},
})
if
err
!=
nil
{
model
.
Log
.
Errorf
(
"MGetUserOnMic fail:%v"
,
err
)
...
...
script/utils/utils_test.go
View file @
9c426cb6
...
...
@@ -10,6 +10,6 @@ func TestTestCommon(t *testing.T) {
}
func
TestJwt
(
t
*
testing
.
T
)
{
token
,
_
:=
jwt
.
GenerateToken
(
2781
,
"6373ff5c318c4057886a669b5c9b5301
"
,
"hiloApi"
)
token
,
_
:=
jwt
.
GenerateToken
(
3951
,
"7b0535559da045a187ba25a2d27482c0
"
,
"hiloApi"
)
t
.
Logf
(
token
)
}
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