Commit 0acbb4e6 authored by sven's avatar sven

增加监控数据获取

parent 98b17b50
...@@ -172,4 +172,10 @@ oss: ...@@ -172,4 +172,10 @@ oss:
# dtu设备配置 # dtu设备配置
dtuServer: dtuServer:
addr: 0.0.0.0:9804 addr: 0.0.0.0:9804
enable: false enable: false
\ No newline at end of file
# 莹石云帐号
yinShiYun:
13625717783:
appKey: e910fbb3530f4385b8758f1ab268a5f7
secret: 11d99e61b7a0998c18a7fcb557bdaa87
\ No newline at end of file
...@@ -3,11 +3,12 @@ module github.com/flipped-aurora/gin-vue-admin/server ...@@ -3,11 +3,12 @@ module github.com/flipped-aurora/gin-vue-admin/server
go 1.16 go 1.16
require ( require (
gitee.com/zjlsliupei/ghelp v0.0.16 // indirect gitee.com/zjlsliupei/ghelp v0.0.16
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/aliyun/aliyun-oss-go-sdk v2.1.6+incompatible github.com/aliyun/aliyun-oss-go-sdk v2.1.6+incompatible
github.com/aws/aws-sdk-go v1.42.27 github.com/aws/aws-sdk-go v1.42.27
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
github.com/beego/beego/v2 v2.0.5
github.com/casbin/casbin/v2 v2.11.0 github.com/casbin/casbin/v2 v2.11.0
github.com/casbin/gorm-adapter/v3 v3.0.2 github.com/casbin/gorm-adapter/v3 v3.0.2
github.com/flipped-aurora/ws v1.0.2 github.com/flipped-aurora/ws v1.0.2
...@@ -18,20 +19,17 @@ require ( ...@@ -18,20 +19,17 @@ require (
github.com/go-openapi/spec v0.20.3 // indirect github.com/go-openapi/spec v0.20.3 // indirect
github.com/go-openapi/swag v0.19.15 // indirect github.com/go-openapi/swag v0.19.15 // indirect
github.com/go-redis/redis/v8 v8.11.0 github.com/go-redis/redis/v8 v8.11.0
github.com/go-sql-driver/mysql v1.5.0 github.com/go-sql-driver/mysql v1.6.0
github.com/golang-jwt/jwt/v4 v4.3.0 github.com/golang-jwt/jwt/v4 v4.3.0
github.com/gookit/color v1.3.1 github.com/gookit/color v1.3.1
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.8+incompatible github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.8+incompatible
github.com/jackc/pgx/v4 v4.15.0 // indirect github.com/jackc/pgx/v4 v4.15.0 // indirect
github.com/jordan-wright/email v0.0.0-20200824153738-3f5bafa1cd84 github.com/jordan-wright/email v0.0.0-20200824153738-3f5bafa1cd84
github.com/json-iterator/go v1.1.10 // indirect
github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible github.com/lestrrat-go/file-rotatelogs v2.4.0+incompatible
github.com/lestrrat-go/strftime v1.0.6 // indirect github.com/lestrrat-go/strftime v1.0.6 // indirect
github.com/mailru/easyjson v0.7.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.2.2 // indirect
github.com/mojocn/base64Captcha v1.3.1 github.com/mojocn/base64Captcha v1.3.1
github.com/otiai10/copy v1.7.0 github.com/otiai10/copy v1.7.0
github.com/pelletier/go-toml v1.6.0 // indirect
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/qiniu/api.v7/v7 v7.4.1 github.com/qiniu/api.v7/v7 v7.4.1
github.com/robfig/cron/v3 v3.0.1 github.com/robfig/cron/v3 v3.0.1
...@@ -43,13 +41,13 @@ require ( ...@@ -43,13 +41,13 @@ require (
github.com/spf13/jwalterweatherman v1.1.0 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.7.0 github.com/spf13/viper v1.7.0
github.com/stretchr/testify v1.7.1 github.com/stretchr/testify v1.8.0
github.com/swaggo/gin-swagger v1.3.0 github.com/swaggo/gin-swagger v1.3.0
github.com/swaggo/swag v1.7.0 github.com/swaggo/swag v1.7.0
github.com/tencentyun/cos-go-sdk-v5 v0.7.19 github.com/tencentyun/cos-go-sdk-v5 v0.7.19
github.com/unrolled/secure v1.0.7 github.com/unrolled/secure v1.0.7
github.com/xuri/excelize/v2 v2.4.1 github.com/xuri/excelize/v2 v2.4.1
go.uber.org/zap v1.16.0 go.uber.org/zap v1.17.0
golang.org/x/crypto v0.0.0-20220213190939-1e6e3497d506 golang.org/x/crypto v0.0.0-20220213190939-1e6e3497d506
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/text v0.3.7 golang.org/x/text v0.3.7
......
This source diff could not be displayed because it is too large. You can view the blob instead.
package utils package utils
import (
"context"
"errors"
"fmt"
"github.com/beego/beego/v2/client/httplib"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/songzhibin97/gkit/tools/gjson"
"time"
)
type PageInfo struct { type PageInfo struct {
Page int `json:"page" form:"page"` // 页码 Page int `json:"page" form:"page"` // 页码
PageSize int `json:"page_size" form:"page_size"` // 每页大小 PageSize int `json:"page_size" form:"page_size"` // 每页大小
} }
// GetYinShiAccessToken 获取指定帐号下accessToken
// example: utils.GetYinShiAccessToken("13625717783")
func GetYinShiAccessToken(userName string) (string, error) {
key := fmt.Sprintf("%syinshui_accesstoken_%s", global.GVA_VP.GetString("redis.prefix"), userName)
if accessToken := global.GVA_REDIS.Get(context.Background(), key).Val(); accessToken != "" {
return accessToken, nil
}
req := httplib.Post("https://open.ys7.com/api/lapp/token/get")
req.Param("appKey", global.GVA_VP.GetString(fmt.Sprintf("yinShiYun.%s.appKey", userName)))
req.Param("appSecret", global.GVA_VP.GetString(fmt.Sprintf("yinShiYun.%s.secret", userName)))
res, err := req.String()
if err != nil {
return "", err
}
resJson := gjson.Parse(res)
if resJson.Get("code").Exists() && resJson.Get("code").Int() == 200 {
_accessToken := resJson.Get("data.accessToken").String()
global.GVA_REDIS.Set(context.Background(), key, _accessToken, 6*24*time.Hour)
return _accessToken, nil
} else {
return "", errors.New("获取accessToken失败")
}
}
// GetCameraUrl 获取监控播放地址
func GetCameraUrl(deviceId string) string {
return fmt.Sprintf("ezopen://open.ys7.com/%s/1.hd.live", deviceId)
}
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