Commit 9c426cb6 authored by hujiebin's avatar hujiebin

param tz 时区,0:北京时间 1:沙特时间

parent e2d8bb39
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,
}
......@@ -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)
......
......@@ -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)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment