风险监控Go语言SDK
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
risk-sdk-go/README.md

76 lines
1.4 KiB

## 如果使用了go的代理,需要设置私有仓库代理
```
go env -w GOPRIVATE="gitea.drugeyes.vip/*"
```
## examples
```go
package main
import (
"context"
"fmt"
"time"
risk "gitea.drugeyes.vip/pharnexbase/risk-sdk-go"
)
func main() {
var client = risk.NewClient(
// 添加对应版本的APPID和Secret信息
risk.WithAppID("01b60cd2aacaf411"),
risk.WithAppSecret("2D6MDRfFg7EudhW90UXOFrEI9td"),
// 填写对应不同版本的服务器地址
risk.WithServerHost("http://risk-sensor.drugeyes.vip:7031/"),
// 设置请求过期时间
risk.WithTimeOut(time.Second*30),
// 设置debug模式
risk.WithDebug(true),
)
// 日志写入
err := client.WriteLog(context.Background(), &risk.LogData{
Organize: "测试",
User: "1",
Ip: "127.0.0.1",
UserAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
PageType: "LIST",
Value: 12,
Request: "测试库dd",
DbCount: []*risk.DBCount{
{
UniqueKey: "00014",
DB: "db1",
},
},
})
fmt.Printf("wirte log %v", err)
// 数据库同步
err = client.SyncDatabase(context.Background(), []*risk.SyncData{
{
DbKey: "db1",
DbName: "测试库aa",
DbCount: 255,
},
{
DbKey: "db2",
DbName: "测试库bb",
DbCount: 255,
},
{
DbKey: "db3",
DbName: "测试库cc",
DbCount: 255,
},
})
fmt.Printf("sync database %v", err)
}
```