feat(passport):封装用户注册信息获取
This commit is contained in:
parent
4c4cebea5d
commit
4ab822a1b6
@ -87,3 +87,11 @@ func (c *Client) GetUserLabels(req *GetUserLabelsRequest) (response *GetUserLabe
|
|||||||
err = c.DoAction(req, response)
|
err = c.DoAction(req, response)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserRegInfo
|
||||||
|
// 获取用户注册信息
|
||||||
|
func (c *Client) GetUserRegInfo(req *GetUserRegInfoRequest) (response *GetUserRegInfoResponse, err error) {
|
||||||
|
response = CreateGetUserRegInfoResponse()
|
||||||
|
err = c.DoAction(req, response)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
package passport
|
package passport
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 单元测试
|
// 单元测试
|
||||||
@ -109,3 +112,58 @@ func TestUpdateUserState(t *testing.T) {
|
|||||||
// 记录文本结果
|
// 记录文本结果
|
||||||
t.Logf("resp code:%+v, msg:%s", resp.Code, resp.Msg)
|
t.Logf("resp code:%+v, msg:%s", resp.Code, resp.Msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 测试获取用户注册信息
|
||||||
|
func TestGetUserRegInfo(t *testing.T) {
|
||||||
|
req := CreateGetUserRegInfoRequest("xc21225964")
|
||||||
|
if err := requests.InitParam(req); err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if req.GetMethod() != requests.POST || req.GetActionName() != "/remote_login.php" {
|
||||||
|
t.Errorf("get user reg info req: method=%s path=%s", req.GetMethod(), req.GetActionName())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if req.GetFormParams()["act"] != "info" {
|
||||||
|
t.Errorf("unexpected act param: %q", req.GetFormParams()["act"])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if req.GetFormParams()["do"] != "get_user_reg_info" {
|
||||||
|
t.Errorf("unexpected do param: %q", req.GetFormParams()["do"])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if req.GetFormParams()["user_name"] != "xc21225964" {
|
||||||
|
t.Errorf("unexpected user_name param: %q", req.GetFormParams()["user_name"])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if req.GetFormParams()["time"] == "" || req.GetFormParams()["sign"] == "" {
|
||||||
|
t.Errorf("unexpected sign params: time=%q sign=%q", req.GetFormParams()["time"], req.GetFormParams()["sign"])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.GetUserRegInfo(req)
|
||||||
|
if err != nil {
|
||||||
|
if resp != nil {
|
||||||
|
fmt.Printf("%s\n", resp.GetHttpContentString())
|
||||||
|
fmt.Printf("%#+v\n", resp)
|
||||||
|
}
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if resp == nil {
|
||||||
|
t.Errorf("get user reg info response is nil")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if resp.Code != 1 || resp.Msg != "获取成功" || resp.Data.RegTime <= 0 {
|
||||||
|
t.Errorf("get user reg info response: code=%d msg=%s data=%+v", resp.Code, resp.Msg, resp.Data)
|
||||||
|
fmt.Printf("%#+v\n", resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
fmt.Printf("%#+v\n", resp)
|
||||||
|
fmt.Printf("%#+v\n", resp.Data)
|
||||||
|
}
|
||||||
|
|||||||
46
services/passport/user_reg_info.go
Normal file
46
services/passport/user_reg_info.go
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package passport
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetUserRegInfoRequest struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUserRegInfoResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data struct {
|
||||||
|
RegTime int64 `json:"reg_time"`
|
||||||
|
GameId int64 `json:"game_id"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateGetUserRegInfoRequest 获取用户注册信息
|
||||||
|
func CreateGetUserRegInfoRequest(userName string) (req *GetUserRegInfoRequest) {
|
||||||
|
ts, sign := GetSign()
|
||||||
|
req = &GetUserRegInfoRequest{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/remote_login.php")
|
||||||
|
req.FormParams = map[string]string{
|
||||||
|
"act": "info",
|
||||||
|
"do": "get_user_reg_info",
|
||||||
|
"user_name": userName,
|
||||||
|
"time": fmt.Sprintf("%v", ts),
|
||||||
|
"sign": sign,
|
||||||
|
}
|
||||||
|
req.Method = requests.POST
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetUserRegInfoResponse() (response *GetUserRegInfoResponse) {
|
||||||
|
response = &GetUserRegInfoResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user