dms运营sdk修改
This commit is contained in:
parent
fa12a66f44
commit
939f4fd22b
@ -10,7 +10,7 @@ const (
|
||||
)
|
||||
|
||||
var HOST requests.Host = requests.Host{
|
||||
Default: "dms-api.gaore.com",
|
||||
Default: "dms-api",
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
|
||||
@ -1,13 +1,17 @@
|
||||
package big_data
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"strings"
|
||||
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||
)
|
||||
|
||||
// GetUserProfileParam 用户筛选/圈选查询参数
|
||||
// 说明:金额类筛选用 *int64,未设置(nil)时不参与筛选;切片为空表示不限定该条件
|
||||
type GetUserProfileParam struct {
|
||||
UserName []string `json:"user_name"`
|
||||
UserName2 []string `json:"user_name2"`
|
||||
@ -24,10 +28,10 @@ type GetUserProfileParam struct {
|
||||
RegisterDate []string `json:"register_date"` // 区间 [开始, 结束]
|
||||
LastLoginDate []string `json:"last_login_date"` // 区间 [开始, 结束]
|
||||
LastPayDate []string `json:"last_pay_date"` // 区间 [开始, 结束]
|
||||
PayAmtAccMin int64 `json:"pay_amt_acc_min"`
|
||||
PayAmtAccMax int64 `json:"pay_amt_acc_max"`
|
||||
LastPayAmountMin int64 `json:"last_pay_amount_min"`
|
||||
LastPayAmountMax int64 `json:"last_pay_amount_max"`
|
||||
PayAmtAccMin *int64 `json:"pay_amt_acc_min"`
|
||||
PayAmtAccMax *int64 `json:"pay_amt_acc_max"`
|
||||
LastPayAmountMin *int64 `json:"last_pay_amount_min"`
|
||||
LastPayAmountMax *int64 `json:"last_pay_amount_max"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
XDebug string `json:"x_debug"` // 测试环境调试头,正式调用可留空
|
||||
@ -51,16 +55,92 @@ type GetUserProfileRequest struct {
|
||||
RegisterDate []string `position:"Json" field:"register_date"`
|
||||
LastLoginDate []string `position:"Json" field:"last_login_date"`
|
||||
LastPayDate []string `position:"Json" field:"last_pay_date"`
|
||||
PayAmtAccMin int64 `position:"Json" field:"pay_amt_acc_min"`
|
||||
PayAmtAccMax int64 `position:"Json" field:"pay_amt_acc_max"`
|
||||
LastPayAmountMin int64 `position:"Json" field:"last_pay_amount_min"`
|
||||
LastPayAmountMax int64 `position:"Json" field:"last_pay_amount_max"`
|
||||
PayAmtAccMin *int64 `position:"Json" field:"pay_amt_acc_min"`
|
||||
PayAmtAccMax *int64 `position:"Json" field:"pay_amt_acc_max"`
|
||||
LastPayAmountMin *int64 `position:"Json" field:"last_pay_amount_min"`
|
||||
LastPayAmountMax *int64 `position:"Json" field:"last_pay_amount_max"`
|
||||
Page int `position:"Json" field:"page"`
|
||||
PageSize int `position:"Json" field:"page_size"`
|
||||
Authorization string `position:"Header" field:"Authorization"`
|
||||
XDebug string `position:"Header" field:"x-debug"`
|
||||
}
|
||||
|
||||
// getUserProfileBody 自定义请求体序列化结构,绕开 core 的反射序列化(JsonParams):
|
||||
// - 金额字段 *int64 + omitempty:未设置(nil)时该字段不出现在 JSON 中,避免 0 被 DMS 当成真实筛选条件;
|
||||
// - 切片字段统一为非 nil 空数组 []:避免 nil 被序列化成 null 触发 DMS 类型校验失败。
|
||||
type getUserProfileBody struct {
|
||||
UserName []string `json:"user_name"`
|
||||
UserName2 []string `json:"user_name2"`
|
||||
Uid []string `json:"uid"`
|
||||
RoleId []string `json:"role_id"`
|
||||
RoleName []string `json:"role_name"`
|
||||
RoleNameLike string `json:"role_name_like,omitempty"`
|
||||
LabelId []int `json:"label_id"`
|
||||
WeworkTag []string `json:"wework_tag"`
|
||||
OrderId []string `json:"order_id"`
|
||||
TradeOrderId []string `json:"trade_order_id"`
|
||||
GameSign []string `json:"game_sign"`
|
||||
GameId []string `json:"game_id"`
|
||||
RegisterDate []string `json:"register_date"`
|
||||
LastLoginDate []string `json:"last_login_date"`
|
||||
LastPayDate []string `json:"last_pay_date"`
|
||||
PayAmtAccMin *int64 `json:"pay_amt_acc_min,omitempty"`
|
||||
PayAmtAccMax *int64 `json:"pay_amt_acc_max,omitempty"`
|
||||
LastPayAmountMin *int64 `json:"last_pay_amount_min,omitempty"`
|
||||
LastPayAmountMax *int64 `json:"last_pay_amount_max,omitempty"`
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
}
|
||||
|
||||
// GetBodyReader 覆盖 JsonRequest 默认实现,使用自定义结构序列化 body。
|
||||
// 鉴权头(Authorization / x-debug)仍由 core 的 InitParam 按 Header 字段设置,不受影响。
|
||||
func (request *GetUserProfileRequest) GetBodyReader() io.Reader {
|
||||
body := getUserProfileBody{
|
||||
UserName: emptyStrSlice(request.UserName),
|
||||
UserName2: emptyStrSlice(request.UserName2),
|
||||
Uid: emptyStrSlice(request.Uid),
|
||||
RoleId: emptyStrSlice(request.RoleId),
|
||||
RoleName: emptyStrSlice(request.RoleName),
|
||||
RoleNameLike: request.RoleNameLike,
|
||||
LabelId: emptyIntSlice(request.LabelId),
|
||||
WeworkTag: emptyStrSlice(request.WeworkTag),
|
||||
OrderId: emptyStrSlice(request.OrderId),
|
||||
TradeOrderId: emptyStrSlice(request.TradeOrderId),
|
||||
GameSign: emptyStrSlice(request.GameSign),
|
||||
GameId: emptyStrSlice(request.GameId),
|
||||
RegisterDate: emptyStrSlice(request.RegisterDate),
|
||||
LastLoginDate: emptyStrSlice(request.LastLoginDate),
|
||||
LastPayDate: emptyStrSlice(request.LastPayDate),
|
||||
PayAmtAccMin: request.PayAmtAccMin,
|
||||
PayAmtAccMax: request.PayAmtAccMax,
|
||||
LastPayAmountMin: request.LastPayAmountMin,
|
||||
LastPayAmountMax: request.LastPayAmountMax,
|
||||
Page: request.Page,
|
||||
PageSize: request.PageSize,
|
||||
}
|
||||
b, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
return strings.NewReader("")
|
||||
}
|
||||
return bytes.NewReader(b)
|
||||
}
|
||||
|
||||
// emptyStrSlice 将 nil 切片转成非 nil 空切片,避免序列化成 JSON null
|
||||
func emptyStrSlice(s []string) []string {
|
||||
if s == nil {
|
||||
return []string{}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// emptyIntSlice 同 emptyStrSlice,针对 label_id 等 []int 字段
|
||||
func emptyIntSlice(s []int) []int {
|
||||
if s == nil {
|
||||
return []int{}
|
||||
}
|
||||
return s
|
||||
}
|
||||
|
||||
// GetUserProfileResponse 用户筛选/圈选查询响应(返回不做处理,data 原样透出)
|
||||
type GetUserProfileResponse struct {
|
||||
*responses.BaseResponse
|
||||
|
||||
Loading…
Reference in New Issue
Block a user