Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
45e449df11
36
services/ip/client.go
Normal file
36
services/ip/client.go
Normal file
@ -0,0 +1,36 @@
|
||||
package ip
|
||||
|
||||
import (
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
)
|
||||
|
||||
const (
|
||||
VERSION = "2025-06-24"
|
||||
)
|
||||
|
||||
var HOST = requests.Host{
|
||||
Default: "ip",
|
||||
}
|
||||
|
||||
type Client struct {
|
||||
sdk.Client
|
||||
}
|
||||
|
||||
func NewClient() (client *Client, err error) {
|
||||
client = new(Client)
|
||||
err = client.Init()
|
||||
return
|
||||
}
|
||||
|
||||
func (client *Client) CreateGetIpRequest(req *IpRequest) (resp *IpResponse, err error) {
|
||||
resp = CreateIpResponse()
|
||||
err = client.DoAction(req, resp)
|
||||
return
|
||||
}
|
||||
|
||||
func (client *Client) CreateGetIpsRequest(req *IpsRequest) (resp *IpsResponse, err error) {
|
||||
resp = CreateIpsResponse()
|
||||
err = client.DoAction(req, resp)
|
||||
return
|
||||
}
|
48
services/ip/client_test.go
Normal file
48
services/ip/client_test.go
Normal file
@ -0,0 +1,48 @@
|
||||
package ip
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// 测试获取单个ip地区信息
|
||||
func TestGetIp(t *testing.T) {
|
||||
client, newErr := NewClient()
|
||||
if newErr != nil {
|
||||
panic(newErr)
|
||||
}
|
||||
req := CreateIpRequest(IpParam{
|
||||
Ip: "114.234.202.136",
|
||||
})
|
||||
res, doErr := client.CreateGetIpRequest(req)
|
||||
if doErr != nil {
|
||||
panic(doErr)
|
||||
}
|
||||
if res.Code != 0 {
|
||||
t.Error("查询多个ip失败")
|
||||
}
|
||||
fmt.Printf(fmt.Sprintf("%v", res))
|
||||
}
|
||||
|
||||
// 测试获取多个ip地区信息
|
||||
func TestGetIps(t *testing.T) {
|
||||
client, newErr := NewClient()
|
||||
if newErr != nil {
|
||||
panic(newErr)
|
||||
}
|
||||
req := CreateIpsRequest(IpsParam{
|
||||
Ips: []string{
|
||||
"2001:ee0:5208:e600:4c51:3189:28a4:b668",
|
||||
"114.234.202.136",
|
||||
},
|
||||
})
|
||||
res, err := client.CreateGetIpsRequest(req)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
if res.Code != 0 {
|
||||
t.Error("查询多个ip失败")
|
||||
}
|
||||
fmt.Printf(fmt.Sprintf("%v", res))
|
||||
}
|
100
services/ip/ip.go
Normal file
100
services/ip/ip.go
Normal file
@ -0,0 +1,100 @@
|
||||
package ip
|
||||
|
||||
import (
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||
)
|
||||
|
||||
type IpInfo struct {
|
||||
Ip string `json:"ip"`
|
||||
City string `json:"city"`
|
||||
Province string `json:"province"`
|
||||
Country string `json:"country"`
|
||||
Isp string `json:"isp"`
|
||||
Owner string `json:"owner"`
|
||||
Continent string `json:"continent"`
|
||||
Accuracy string `json:"accuracy"`
|
||||
Adcode string `json:"adcode"`
|
||||
Areacode string `json:"areacode"`
|
||||
Asnumber string `json:"asnumber"`
|
||||
Radius string `json:"radius"`
|
||||
Latwgs string `json:"latwgs"`
|
||||
Lngwgs string `json:"lngwgs"`
|
||||
Source string `json:"source"`
|
||||
Timezone string `json:"timezone"`
|
||||
Zipcode string `json:"zipcode"`
|
||||
District string `json:"district"`
|
||||
}
|
||||
|
||||
// IpsParam
|
||||
// 单个ip请求参数
|
||||
type IpParam struct {
|
||||
Ip string `json:"ip"`
|
||||
}
|
||||
type IpRequest struct {
|
||||
*requests.JsonRequest
|
||||
Ip string `position:"Json" field:"ip"`
|
||||
}
|
||||
|
||||
// IpResponse
|
||||
// 单个ip返回参数
|
||||
type IpResponse struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data IpInfo `json:"data"`
|
||||
}
|
||||
|
||||
// CreateIpRequest
|
||||
// 同时支持ipv4、ipv6格式查询
|
||||
func CreateIpRequest(param IpParam) (req *IpRequest) {
|
||||
req = &IpRequest{
|
||||
JsonRequest: &requests.JsonRequest{},
|
||||
Ip: param.Ip,
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/v1/getIp")
|
||||
req.Method = requests.POST
|
||||
return
|
||||
}
|
||||
func CreateIpResponse() (resp *IpResponse) {
|
||||
resp = &IpResponse{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 多个ip请求参数
|
||||
type IpsParam struct {
|
||||
Ips []string `json:"ips"`
|
||||
}
|
||||
type IpsRequest struct {
|
||||
*requests.JsonRequest
|
||||
Ips []string `position:"Json" field:"ips"`
|
||||
}
|
||||
|
||||
// IpsResponse
|
||||
// 多个ip返回参数
|
||||
type IpsResponse struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data map[string]IpInfo `json:"data"`
|
||||
}
|
||||
|
||||
// CreateIpsRequest
|
||||
// 同时支持ipv4、ipv6格式查询
|
||||
func CreateIpsRequest(param IpsParam) (req *IpsRequest) {
|
||||
req = &IpsRequest{
|
||||
JsonRequest: &requests.JsonRequest{},
|
||||
Ips: param.Ips,
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/v1/getIps")
|
||||
req.Method = requests.POST
|
||||
return
|
||||
}
|
||||
func CreateIpsResponse() (resp *IpsResponse) {
|
||||
resp = &IpsResponse{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
return
|
||||
}
|
@ -49,3 +49,13 @@ func (c *Client) GetAgentList(req *GetAgentListReq) (resp *GetAgentListResp, err
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetUserRoleRegPage 获取用户角色注册分页列表
|
||||
func (c *Client) GetUserRoleRegPage(req *UserRoleRegReq) (resp *UserRoleRegResp, err error) {
|
||||
resp = CreateUserRoleRegPageResp()
|
||||
err = c.DoAction(req, resp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -78,3 +78,23 @@ func TestClient_GetAgentList(t *testing.T) {
|
||||
t.Log("GetAgentList test passed")
|
||||
}
|
||||
}
|
||||
|
||||
// TestClient_GetUserRoleRegPage 查询用户角色注册分页
|
||||
func TestClient_GetUserRoleRegPage(t *testing.T) {
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
req := CreateUserRoleRegPageReq(UserRoleRegParam{
|
||||
Page: 1,
|
||||
PageSize: 10,
|
||||
RoleId: "-1",
|
||||
RoleName: "",
|
||||
})
|
||||
|
||||
resp, err := client.GetUserRoleRegPage(req)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println(resp.Code, resp.Msg, resp.Data)
|
||||
}
|
||||
|
@ -57,3 +57,59 @@ func CreateSetUserNewGameAuthResp() *SetUserNewGameAuthResp {
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------
|
||||
|
||||
// UserRoleReg 玩家汇总角色创建记录
|
||||
type UserRoleReg struct {
|
||||
UserName string `json:"user_name"`
|
||||
Uid string `json:"uid"`
|
||||
RoleId string `json:"role_id"`
|
||||
RoleName string `json:"role_name"`
|
||||
GameSign string `json:"game_sign"`
|
||||
Id string `json:"id"`
|
||||
CreatedAt string `json:"created_at"`
|
||||
}
|
||||
type UserRoleRegPage struct {
|
||||
Page int `json:"page"`
|
||||
TotalCount int `json:"total_count"`
|
||||
PageSize int `json:"page_size"`
|
||||
Data []UserRoleReg `json:"data"`
|
||||
}
|
||||
|
||||
type UserRoleRegParam struct {
|
||||
Page int `json:"page"`
|
||||
PageSize int `json:"page_size"`
|
||||
RoleId string `json:"role_id"`
|
||||
RoleName string `json:"role_name"`
|
||||
}
|
||||
type UserRoleRegReq struct {
|
||||
*requests.RpcRequest
|
||||
}
|
||||
type UserRoleRegResp struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data UserRoleRegPage `json:"data"`
|
||||
}
|
||||
|
||||
func CreateUserRoleRegPageReq(param UserRoleRegParam) *UserRoleRegReq {
|
||||
req := &UserRoleRegReq{
|
||||
&requests.RpcRequest{},
|
||||
}
|
||||
req.InitWithApiInfo(HOST, VERSION, "/user/getRoleRegPage")
|
||||
req.Method = requests.POST
|
||||
req.FormParams = map[string]string{
|
||||
"page": fmt.Sprintf("%v", param.Page),
|
||||
"page_size": fmt.Sprintf("%v", param.PageSize),
|
||||
"role_id": param.RoleId,
|
||||
"role_name": param.RoleName,
|
||||
}
|
||||
|
||||
return req
|
||||
}
|
||||
func CreateUserRoleRegPageResp() *UserRoleRegResp {
|
||||
return &UserRoleRegResp{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user