diff --git a/services/big-data/client.go b/services/big-data/client.go index 945293a..7ff5e3d 100644 --- a/services/big-data/client.go +++ b/services/big-data/client.go @@ -10,7 +10,7 @@ const ( ) var HOST requests.Host = requests.Host{ - Default: "dms-api.gaore.com", + Default: "dms-api", } type Client struct { @@ -36,3 +36,24 @@ func (c *Client) GetUserProfile(req *GetUserProfileRequest) (response *GetUserPr err = c.DoAction(req, response) return } + +// GetUserLoginLog 用户登录日志查询 +func (c *Client) GetUserLoginLog(req *GetUserLoginLogRequest) (response *GetUserLoginLogResponse, err error) { + response = CreateGetUserLoginLogResponse() + err = c.DoAction(req, response) + return +} + +// GetRoleCreateLog 角色创建日志查询 +func (c *Client) GetRoleCreateLog(req *GetRoleCreateLogRequest) (response *GetRoleCreateLogResponse, err error) { + response = CreateGetRoleCreateLogResponse() + err = c.DoAction(req, response) + return +} + +// GetUserLoginLogOsOptions 登录日志 OS 选项查询 +func (c *Client) GetUserLoginLogOsOptions(req *GetUserLoginLogOsOptionsRequest) (response *GetUserLoginLogOsOptionsResponse, err error) { + response = CreateGetUserLoginLogOsOptionsResponse() + err = c.DoAction(req, response) + return +} diff --git a/services/big-data/get_role_create_log.go b/services/big-data/get_role_create_log.go new file mode 100644 index 0000000..ba034ad --- /dev/null +++ b/services/big-data/get_role_create_log.go @@ -0,0 +1,142 @@ +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" +) + +// GetRoleCreateLogParam 角色创建日志查询参数 +// 说明:数值区间用 *int64,未设置(nil)时不参与筛选;切片为空表示不限定该条件 +type GetRoleCreateLogParam struct { + Uid string `json:"uid"` + EventTime []string `json:"event_time"` // 区间 [开始, 结束] + GameSign string `json:"game_sign"` + GameId string `json:"game_id"` + RoleName string `json:"role_name"` + RoleId string `json:"role_id"` + ServerName string `json:"server_name"` + ServerId string `json:"server_id"` + RoleLevelMin *int64 `json:"role_level_min"` + RoleLevelMax *int64 `json:"role_level_max"` + PayAmtAccMin *int64 `json:"pay_amt_acc_min"` + PayAmtAccMax *int64 `json:"pay_amt_acc_max"` + Page int `json:"page"` + PageSize int `json:"page_size"` + XDebug string `json:"x_debug"` // 测试环境调试头,正式调用可留空 +} + +// GetRoleCreateLogRequest 角色创建日志查询请求 +type GetRoleCreateLogRequest struct { + *requests.JsonRequest + Uid string `position:"Json" field:"uid"` + EventTime []string `position:"Json" field:"event_time"` + GameSign string `position:"Json" field:"game_sign"` + GameId string `position:"Json" field:"game_id"` + RoleName string `position:"Json" field:"role_name"` + RoleId string `position:"Json" field:"role_id"` + ServerName string `position:"Json" field:"server_name"` + ServerId string `position:"Json" field:"server_id"` + RoleLevelMin *int64 `position:"Json" field:"role_level_min"` + RoleLevelMax *int64 `position:"Json" field:"role_level_max"` + PayAmtAccMin *int64 `position:"Json" field:"pay_amt_acc_min"` + PayAmtAccMax *int64 `position:"Json" field:"pay_amt_acc_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"` +} + +// getRoleCreateLogBody 自定义请求体序列化结构,绕开 core 的反射序列化(JsonParams): +// - 数值字段 *int64 + omitempty:未设置(nil)时该字段不出现在 JSON 中,避免 0 被 DMS 当成真实筛选条件; +// - event_time 切片统一为非 nil 空数组 []:避免 nil 被序列化成 null 触发 DMS 类型校验失败; +// - 标量字符串用 omitempty:空串时不出现在 JSON 中。 +type getRoleCreateLogBody struct { + Uid string `json:"uid,omitempty"` + EventTime []string `json:"event_time"` + GameSign string `json:"game_sign,omitempty"` + GameId string `json:"game_id,omitempty"` + RoleName string `json:"role_name,omitempty"` + RoleId string `json:"role_id,omitempty"` + ServerName string `json:"server_name,omitempty"` + ServerId string `json:"server_id,omitempty"` + RoleLevelMin *int64 `json:"role_level_min,omitempty"` + RoleLevelMax *int64 `json:"role_level_max,omitempty"` + PayAmtAccMin *int64 `json:"pay_amt_acc_min,omitempty"` + PayAmtAccMax *int64 `json:"pay_amt_acc_max,omitempty"` + Page int `json:"page"` + PageSize int `json:"page_size"` +} + +// GetBodyReader 覆盖 JsonRequest 默认实现,使用自定义结构序列化 body。 +// 鉴权头(Authorization / x-debug)仍由 core 的 InitParam 按 Header 字段设置,不受影响。 +func (request *GetRoleCreateLogRequest) GetBodyReader() io.Reader { + body := getRoleCreateLogBody{ + Uid: request.Uid, + EventTime: emptyStrSlice(request.EventTime), + GameSign: request.GameSign, + GameId: request.GameId, + RoleName: request.RoleName, + RoleId: request.RoleId, + ServerName: request.ServerName, + ServerId: request.ServerId, + RoleLevelMin: request.RoleLevelMin, + RoleLevelMax: request.RoleLevelMax, + PayAmtAccMin: request.PayAmtAccMin, + PayAmtAccMax: request.PayAmtAccMax, + Page: request.Page, + PageSize: request.PageSize, + } + b, err := json.Marshal(body) + if err != nil { + return strings.NewReader("") + } + return bytes.NewReader(b) +} + +// GetRoleCreateLogResponse 角色创建日志查询响应(返回不做处理,data 原样透出) +type GetRoleCreateLogResponse struct { + *responses.BaseResponse + Code int `json:"code"` + Message string `json:"message"` + Data json.RawMessage `json:"data"` +} + +// CreateGetRoleCreateLogRequest 创建角色创建日志查询请求 +// token 为 GetToken 返回的 data.token,直接放入 Authorization 头 +func CreateGetRoleCreateLogRequest(token string, param GetRoleCreateLogParam) *GetRoleCreateLogRequest { + req := &GetRoleCreateLogRequest{ + JsonRequest: &requests.JsonRequest{}, + Uid: param.Uid, + EventTime: param.EventTime, + GameSign: param.GameSign, + GameId: param.GameId, + RoleName: param.RoleName, + RoleId: param.RoleId, + ServerName: param.ServerName, + ServerId: param.ServerId, + RoleLevelMin: param.RoleLevelMin, + RoleLevelMax: param.RoleLevelMax, + PayAmtAccMin: param.PayAmtAccMin, + PayAmtAccMax: param.PayAmtAccMax, + Page: param.Page, + PageSize: param.PageSize, + Authorization: token, + XDebug: param.XDebug, + } + req.InitWithApiInfo(HOST, VERSION, "/api/internal/v1/get_role_create_log") + req.Method = requests.POST + req.Scheme = requests.HTTPS + return req +} + +// CreateGetRoleCreateLogResponse 创建角色创建日志查询响应 +func CreateGetRoleCreateLogResponse() *GetRoleCreateLogResponse { + return &GetRoleCreateLogResponse{ + BaseResponse: &responses.BaseResponse{}, + } +} diff --git a/services/big-data/get_user_login_log.go b/services/big-data/get_user_login_log.go new file mode 100644 index 0000000..2a5757b --- /dev/null +++ b/services/big-data/get_user_login_log.go @@ -0,0 +1,126 @@ +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" +) + +// GetUserLoginLogParam 用户登录日志查询参数 +// 说明:切片为空表示不限定该条件;标量字符串为空时不参与筛选 +type GetUserLoginLogParam struct { + Uid string `json:"uid"` + EventTime string `json:"event_time"` // 形如 "2026-06" + GameSign string `json:"game_sign"` + ServerGroupId []string `json:"server_group_id"` + GameId string `json:"game_id"` + Os []string `json:"os"` + OsTwo []string `json:"os_two"` + Ip string `json:"ip"` + DeviceId string `json:"device_id"` + Page int `json:"page"` + PageSize int `json:"page_size"` + XDebug string `json:"x_debug"` // 测试环境调试头,正式调用可留空 +} + +// GetUserLoginLogRequest 用户登录日志查询请求 +type GetUserLoginLogRequest struct { + *requests.JsonRequest + Uid string `position:"Json" field:"uid"` + EventTime string `position:"Json" field:"event_time"` + GameSign string `position:"Json" field:"game_sign"` + ServerGroupId []string `position:"Json" field:"server_group_id"` + GameId string `position:"Json" field:"game_id"` + Os []string `position:"Json" field:"os"` + OsTwo []string `position:"Json" field:"os_two"` + Ip string `position:"Json" field:"ip"` + DeviceId string `position:"Json" field:"device_id"` + 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"` +} + +// getUserLoginLogBody 自定义请求体序列化结构,绕开 core 的反射序列化(JsonParams): +// - 切片字段统一为非 nil 空数组 []:避免 nil 被序列化成 null 触发 DMS 类型校验失败; +// - 标量字符串用 omitempty:空串时不出现在 JSON 中,避免被 DMS 当成真实筛选条件。 +type getUserLoginLogBody struct { + Uid string `json:"uid,omitempty"` + EventTime string `json:"event_time,omitempty"` + GameSign string `json:"game_sign,omitempty"` + ServerGroupId []string `json:"server_group_id"` + GameId string `json:"game_id,omitempty"` + Os []string `json:"os"` + OsTwo []string `json:"os_two"` + Ip string `json:"ip,omitempty"` + DeviceId string `json:"device_id,omitempty"` + Page int `json:"page"` + PageSize int `json:"page_size"` +} + +// GetBodyReader 覆盖 JsonRequest 默认实现,使用自定义结构序列化 body。 +// 鉴权头(Authorization / x-debug)仍由 core 的 InitParam 按 Header 字段设置,不受影响。 +func (request *GetUserLoginLogRequest) GetBodyReader() io.Reader { + body := getUserLoginLogBody{ + Uid: request.Uid, + EventTime: request.EventTime, + GameSign: request.GameSign, + ServerGroupId: emptyStrSlice(request.ServerGroupId), + GameId: request.GameId, + Os: emptyStrSlice(request.Os), + OsTwo: emptyStrSlice(request.OsTwo), + Ip: request.Ip, + DeviceId: request.DeviceId, + Page: request.Page, + PageSize: request.PageSize, + } + b, err := json.Marshal(body) + if err != nil { + return strings.NewReader("") + } + return bytes.NewReader(b) +} + +// GetUserLoginLogResponse 用户登录日志查询响应(返回不做处理,data 原样透出) +type GetUserLoginLogResponse struct { + *responses.BaseResponse + Code int `json:"code"` + Message string `json:"message"` + Data json.RawMessage `json:"data"` +} + +// CreateGetUserLoginLogRequest 创建用户登录日志查询请求 +// token 为 GetToken 返回的 data.token,直接放入 Authorization 头 +func CreateGetUserLoginLogRequest(token string, param GetUserLoginLogParam) *GetUserLoginLogRequest { + req := &GetUserLoginLogRequest{ + JsonRequest: &requests.JsonRequest{}, + Uid: param.Uid, + EventTime: param.EventTime, + GameSign: param.GameSign, + ServerGroupId: param.ServerGroupId, + GameId: param.GameId, + Os: param.Os, + OsTwo: param.OsTwo, + Ip: param.Ip, + DeviceId: param.DeviceId, + Page: param.Page, + PageSize: param.PageSize, + Authorization: token, + XDebug: param.XDebug, + } + req.InitWithApiInfo(HOST, VERSION, "/api/internal/v1/get_user_login_log") + req.Method = requests.POST + req.Scheme = requests.HTTPS + return req +} + +// CreateGetUserLoginLogResponse 创建用户登录日志查询响应 +func CreateGetUserLoginLogResponse() *GetUserLoginLogResponse { + return &GetUserLoginLogResponse{ + BaseResponse: &responses.BaseResponse{}, + } +} diff --git a/services/big-data/get_user_login_log_os_options.go b/services/big-data/get_user_login_log_os_options.go new file mode 100644 index 0000000..5cbe21b --- /dev/null +++ b/services/big-data/get_user_login_log_os_options.go @@ -0,0 +1,43 @@ +package big_data + +import ( + "encoding/json" + + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses" +) + +// GetUserLoginLogOsOptionsRequest 登录日志 OS 选项查询请求(无请求体,仅鉴权头) +type GetUserLoginLogOsOptionsRequest struct { + *requests.JsonRequest + Authorization string `position:"Header" field:"Authorization"` + XDebug string `position:"Header" field:"x-debug"` +} + +// GetUserLoginLogOsOptionsResponse 登录日志 OS 选项查询响应(返回不做处理,data 原样透出) +type GetUserLoginLogOsOptionsResponse struct { + *responses.BaseResponse + Code int `json:"code"` + Message string `json:"message"` + Data json.RawMessage `json:"data"` +} + +// CreateGetUserLoginLogOsOptionsRequest 创建登录日志 OS 选项查询请求 +// token 为 GetToken 返回的 data.token,直接放入 Authorization 头 +func CreateGetUserLoginLogOsOptionsRequest(token string) *GetUserLoginLogOsOptionsRequest { + req := &GetUserLoginLogOsOptionsRequest{ + JsonRequest: &requests.JsonRequest{}, + Authorization: token, + } + req.InitWithApiInfo(HOST, VERSION, "/api/internal/v1/get_user_login_log/os_options") + req.Method = requests.POST + req.Scheme = requests.HTTPS + return req +} + +// CreateGetUserLoginLogOsOptionsResponse 创建登录日志 OS 选项查询响应 +func CreateGetUserLoginLogOsOptionsResponse() *GetUserLoginLogOsOptionsResponse { + return &GetUserLoginLogOsOptionsResponse{ + BaseResponse: &responses.BaseResponse{}, + } +} diff --git a/services/big-data/get_user_profile.go b/services/big-data/get_user_profile.go index 7e960b9..f4b4789 100644 --- a/services/big-data/get_user_profile.go +++ b/services/big-data/get_user_profile.go @@ -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"` @@ -21,13 +25,13 @@ type GetUserProfileParam struct { 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"` - PayAmtAccMax int64 `json:"pay_amt_acc_max"` - LastPayAmountMin int64 `json:"last_pay_amount_min"` - LastPayAmountMax int64 `json:"last_pay_amount_max"` + 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"` 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