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
|
package leshuazf
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/dtapps/go-library/utils/dorm"
|
|
||||||
"github.com/dtapps/go-library/utils/golog"
|
"github.com/dtapps/go-library/utils/golog"
|
||||||
"github.com/dtapps/go-library/utils/gorequest"
|
"github.com/dtapps/go-library/utils/gorequest"
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConfigClient struct {
|
type ConfigClient struct {
|
||||||
AgentId string // 服务商编号,由乐刷分配的接入方唯一标识,明文传输。
|
AgentId string // 服务商编号,由乐刷分配的接入方唯一标识,明文传输。
|
||||||
Environment string // 环境
|
Environment string // 环境
|
||||||
KeyAgent string
|
KeyAgent string
|
||||||
MongoDb *dorm.MongoClient // 日志数据库
|
|
||||||
PgsqlDb *gorm.DB // 日志数据库
|
|
||||||
DatabaseName string // 库名
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Client 乐刷
|
// Client 乐刷
|
||||||
type Client struct {
|
type Client struct {
|
||||||
client *gorequest.App // 请求客户端
|
client *gorequest.App // 请求服务
|
||||||
log *golog.ApiClient // 日志服务
|
config struct {
|
||||||
config *ConfigClient // 配置
|
agentId string // 服务商编号,由乐刷分配的接入方唯一标识,明文传输。
|
||||||
|
environment string // 环境
|
||||||
|
keyAgent string
|
||||||
|
}
|
||||||
|
log struct {
|
||||||
|
status bool // 状态
|
||||||
|
client *golog.ApiClient // 日志服务
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(config *ConfigClient) (*Client, error) {
|
func NewClient(config *ConfigClient) (*Client, error) {
|
||||||
|
|
||||||
var err error
|
c := &Client{}
|
||||||
c := &Client{config: config}
|
|
||||||
|
|
||||||
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.client = gorequest.NewHttp()
|
||||||
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
|
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
|
package pconline
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/dtapps/go-library/utils/dorm"
|
|
||||||
"github.com/dtapps/go-library/utils/golog"
|
"github.com/dtapps/go-library/utils/golog"
|
||||||
"github.com/dtapps/go-library/utils/gorequest"
|
"github.com/dtapps/go-library/utils/gorequest"
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConfigClient struct {
|
|
||||||
MongoDb *dorm.MongoClient // 日志数据库
|
|
||||||
PgsqlDb *gorm.DB // 日志数据库
|
|
||||||
DatabaseName string // 库名
|
|
||||||
}
|
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
client *gorequest.App // 请求客户端
|
client *gorequest.App // 请求服务
|
||||||
log *golog.ApiClient // 日志服务
|
log struct {
|
||||||
config *ConfigClient // 配置
|
status bool // 状态
|
||||||
|
client *golog.ApiClient // 日志服务
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(config *ConfigClient) (*Client, error) {
|
func NewClient() (*Client, error) {
|
||||||
|
|
||||||
var err error
|
c := &Client{}
|
||||||
c := &Client{config: config}
|
|
||||||
|
|
||||||
c.client = gorequest.NewHttp()
|
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
|
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
|
package sendcloud
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/dtapps/go-library/utils/dorm"
|
|
||||||
"github.com/dtapps/go-library/utils/golog"
|
"github.com/dtapps/go-library/utils/golog"
|
||||||
"github.com/dtapps/go-library/utils/gorequest"
|
"github.com/dtapps/go-library/utils/gorequest"
|
||||||
"gorm.io/gorm"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ConfigClient struct {
|
type ConfigClient struct {
|
||||||
ApiUser string // API_USER
|
ApiUser string // API_USER
|
||||||
ApiKey string // API_KEY
|
ApiKey string // API_KEY
|
||||||
MongoDb *dorm.MongoClient // 日志数据库
|
|
||||||
PgsqlDb *gorm.DB // 日志数据库
|
|
||||||
DatabaseName string // 库名
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Client struct {
|
type Client struct {
|
||||||
client *gorequest.App // 请求客户端
|
client *gorequest.App // 请求服务
|
||||||
log *golog.ApiClient // 日志服务
|
config struct {
|
||||||
config *ConfigClient // 配置
|
apiUser string // API_USER
|
||||||
|
apiKey string // API_KEY
|
||||||
|
}
|
||||||
|
log struct {
|
||||||
|
status bool // 状态
|
||||||
|
client *golog.ApiClient // 日志服务
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewClient(config *ConfigClient) (*Client, error) {
|
func NewClient(config *ConfigClient) (*Client, error) {
|
||||||
|
|
||||||
var err error
|
c := &Client{}
|
||||||
c := &Client{config: config}
|
|
||||||
|
|
||||||
c.client = gorequest.NewHttp()
|
c.config.apiUser = config.ApiUser
|
||||||
|
c.config.apiKey = config.ApiKey
|
||||||
|
|
||||||
if c.config.PgsqlDb != nil {
|
c.client = gorequest.NewHttp()
|
||||||
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
|
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