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"` // 区间 [开始, 结束] 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"` 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: emptyStrSlice(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{}, } }