parent
70e338cdd6
commit
52e43d730b
@ -0,0 +1,25 @@
|
||||
package leshuazf
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/baidubce/bce-sdk-go/http"
|
||||
"github.com/dtapps/go-library/utils/gorequest"
|
||||
)
|
||||
|
||||
func (c *Client) Get(ctx context.Context, _method string, notMustParams ...gorequest.Params) ([]byte, error) {
|
||||
// 参数
|
||||
params := gorequest.NewParamsWith(notMustParams...)
|
||||
// 请求
|
||||
request, err := c.request(ctx, apiUrl+_method, params, http.GET)
|
||||
// 定义
|
||||
return request.ResponseBody, err
|
||||
}
|
||||
|
||||
func (c *Client) Post(ctx context.Context, _method string, notMustParams ...gorequest.Params) ([]byte, error) {
|
||||
// 参数
|
||||
params := gorequest.NewParamsWith(notMustParams...)
|
||||
// 请求
|
||||
request, err := c.request(ctx, apiUrl+_method, params, http.POST)
|
||||
// 定义
|
||||
return request.ResponseBody, err
|
||||
}
|
@ -1,54 +1,39 @@
|
||||
package leshuazf
|
||||
|
||||
import (
|
||||
"github.com/dtapps/go-library/utils/dorm"
|
||||
"github.com/dtapps/go-library/utils/golog"
|
||||
"github.com/dtapps/go-library/utils/gorequest"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ConfigClient struct {
|
||||
AgentId string // 服务商编号,由乐刷分配的接入方唯一标识,明文传输。
|
||||
Environment string // 环境
|
||||
KeyAgent string
|
||||
MongoDb *dorm.MongoClient // 日志数据库
|
||||
PgsqlDb *gorm.DB // 日志数据库
|
||||
DatabaseName string // 库名
|
||||
AgentId string // 服务商编号,由乐刷分配的接入方唯一标识,明文传输。
|
||||
Environment string // 环境
|
||||
KeyAgent string
|
||||
}
|
||||
|
||||
// Client 乐刷
|
||||
type Client struct {
|
||||
client *gorequest.App // 请求客户端
|
||||
log *golog.ApiClient // 日志服务
|
||||
config *ConfigClient // 配置
|
||||
client *gorequest.App // 请求服务
|
||||
config struct {
|
||||
agentId string // 服务商编号,由乐刷分配的接入方唯一标识,明文传输。
|
||||
environment string // 环境
|
||||
keyAgent string
|
||||
}
|
||||
log struct {
|
||||
status bool // 状态
|
||||
client *golog.ApiClient // 日志服务
|
||||
}
|
||||
}
|
||||
|
||||
func NewClient(config *ConfigClient) (*Client, error) {
|
||||
|
||||
var err error
|
||||
c := &Client{config: config}
|
||||
c := &Client{}
|
||||
|
||||
c.client = gorequest.NewHttp()
|
||||
c.config.agentId = config.AgentId
|
||||
c.config.environment = config.Environment
|
||||
c.config.keyAgent = config.KeyAgent
|
||||
|
||||
if c.config.PgsqlDb != nil {
|
||||
c.log, err = golog.NewApiClient(
|
||||
golog.WithGormClient(c.config.PgsqlDb),
|
||||
golog.WithTableName(logTable),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if c.config.MongoDb != nil {
|
||||
c.log, err = golog.NewApiClient(
|
||||
golog.WithMongoClient(c.config.MongoDb),
|
||||
golog.WithDatabaseName(c.config.DatabaseName),
|
||||
golog.WithCollectionName(logTable),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
c.client = gorequest.NewHttp()
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package leshuazf
|
||||
|
||||
import "github.com/dtapps/go-library/utils/golog"
|
||||
|
||||
// ConfigApiClientFun 日志配置
|
||||
func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) {
|
||||
apiClient := apiClientFun()
|
||||
if apiClient != nil {
|
||||
c.log.client = apiClient
|
||||
c.log.status = true
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package pconline
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/dtapps/go-library/utils/gorequest"
|
||||
)
|
||||
|
||||
func (c *Client) Get(ctx context.Context, _method string, notMustParams ...gorequest.Params) ([]byte, error) {
|
||||
// 参数
|
||||
params := gorequest.NewParamsWith(notMustParams...)
|
||||
// 请求
|
||||
request, err := c.request(ctx, apiUrl+_method, params)
|
||||
// 定义
|
||||
return request.ResponseBody, err
|
||||
}
|
@ -1,50 +1,23 @@
|
||||
package pconline
|
||||
|
||||
import (
|
||||
"github.com/dtapps/go-library/utils/dorm"
|
||||
"github.com/dtapps/go-library/utils/golog"
|
||||
"github.com/dtapps/go-library/utils/gorequest"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ConfigClient struct {
|
||||
MongoDb *dorm.MongoClient // 日志数据库
|
||||
PgsqlDb *gorm.DB // 日志数据库
|
||||
DatabaseName string // 库名
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
client *gorequest.App // 请求客户端
|
||||
log *golog.ApiClient // 日志服务
|
||||
config *ConfigClient // 配置
|
||||
client *gorequest.App // 请求服务
|
||||
log struct {
|
||||
status bool // 状态
|
||||
client *golog.ApiClient // 日志服务
|
||||
}
|
||||
}
|
||||
|
||||
func NewClient(config *ConfigClient) (*Client, error) {
|
||||
func NewClient() (*Client, error) {
|
||||
|
||||
var err error
|
||||
c := &Client{config: config}
|
||||
c := &Client{}
|
||||
|
||||
c.client = gorequest.NewHttp()
|
||||
|
||||
if c.config.PgsqlDb != nil {
|
||||
c.log, err = golog.NewApiClient(
|
||||
golog.WithGormClient(c.config.PgsqlDb),
|
||||
golog.WithTableName(logTable),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if c.config.MongoDb != nil {
|
||||
c.log, err = golog.NewApiClient(
|
||||
golog.WithMongoClient(c.config.MongoDb),
|
||||
golog.WithDatabaseName(c.config.DatabaseName),
|
||||
golog.WithCollectionName(logTable),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package pconline
|
||||
|
||||
import "github.com/dtapps/go-library/utils/golog"
|
||||
|
||||
// ConfigApiClientFun 日志配置
|
||||
func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) {
|
||||
apiClient := apiClientFun()
|
||||
if apiClient != nil {
|
||||
c.log.client = apiClient
|
||||
c.log.status = true
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package sendcloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/baidubce/bce-sdk-go/http"
|
||||
"github.com/dtapps/go-library/utils/gorequest"
|
||||
)
|
||||
|
||||
func (c *Client) Get(ctx context.Context, _method string, notMustParams ...gorequest.Params) ([]byte, error) {
|
||||
// 参数
|
||||
params := gorequest.NewParamsWith(notMustParams...)
|
||||
// 请求
|
||||
request, err := c.request(ctx, apiUrl+_method, params, http.GET)
|
||||
// 定义
|
||||
return request.ResponseBody, err
|
||||
}
|
||||
|
||||
func (c *Client) Post(ctx context.Context, _method string, notMustParams ...gorequest.Params) ([]byte, error) {
|
||||
// 参数
|
||||
params := gorequest.NewParamsWith(notMustParams...)
|
||||
// 请求
|
||||
request, err := c.request(ctx, apiUrl+_method, params, http.POST)
|
||||
// 定义
|
||||
return request.ResponseBody, err
|
||||
}
|
@ -1,52 +1,35 @@
|
||||
package sendcloud
|
||||
|
||||
import (
|
||||
"github.com/dtapps/go-library/utils/dorm"
|
||||
"github.com/dtapps/go-library/utils/golog"
|
||||
"github.com/dtapps/go-library/utils/gorequest"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ConfigClient struct {
|
||||
ApiUser string // API_USER
|
||||
ApiKey string // API_KEY
|
||||
MongoDb *dorm.MongoClient // 日志数据库
|
||||
PgsqlDb *gorm.DB // 日志数据库
|
||||
DatabaseName string // 库名
|
||||
ApiUser string // API_USER
|
||||
ApiKey string // API_KEY
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
client *gorequest.App // 请求客户端
|
||||
log *golog.ApiClient // 日志服务
|
||||
config *ConfigClient // 配置
|
||||
client *gorequest.App // 请求服务
|
||||
config struct {
|
||||
apiUser string // API_USER
|
||||
apiKey string // API_KEY
|
||||
}
|
||||
log struct {
|
||||
status bool // 状态
|
||||
client *golog.ApiClient // 日志服务
|
||||
}
|
||||
}
|
||||
|
||||
func NewClient(config *ConfigClient) (*Client, error) {
|
||||
|
||||
var err error
|
||||
c := &Client{config: config}
|
||||
c := &Client{}
|
||||
|
||||
c.client = gorequest.NewHttp()
|
||||
c.config.apiUser = config.ApiUser
|
||||
c.config.apiKey = config.ApiKey
|
||||
|
||||
if c.config.PgsqlDb != nil {
|
||||
c.log, err = golog.NewApiClient(
|
||||
golog.WithGormClient(c.config.PgsqlDb),
|
||||
golog.WithTableName(logTable),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if c.config.MongoDb != nil {
|
||||
c.log, err = golog.NewApiClient(
|
||||
golog.WithMongoClient(c.config.MongoDb),
|
||||
golog.WithDatabaseName(c.config.DatabaseName),
|
||||
golog.WithCollectionName(logTable),
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
c.client = gorequest.NewHttp()
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
package sendcloud
|
||||
|
||||
import "github.com/dtapps/go-library/utils/golog"
|
||||
|
||||
// ConfigApiClientFun 日志配置
|
||||
func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) {
|
||||
apiClient := apiClientFun()
|
||||
if apiClient != nil {
|
||||
c.log.client = apiClient
|
||||
c.log.status = true
|
||||
}
|
||||
}
|
Loading…
Reference in new issue