【passport服务】查询用户列表
This commit is contained in:
parent
3652d43f34
commit
055fb8abb9
34
services/passport/client.go
Normal file
34
services/passport/client.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package passport
|
||||||
|
|
||||||
|
import (
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
VERSION = "2025-05-28"
|
||||||
|
// 对称加密密钥
|
||||||
|
appKey = "#gr*%com#"
|
||||||
|
)
|
||||||
|
|
||||||
|
var HOST requests.Host = requests.Host{
|
||||||
|
Default: "passport.gaore.com",
|
||||||
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
sdk.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClient() (client *Client, err error) {
|
||||||
|
client = new(Client)
|
||||||
|
err = client.Init()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserList
|
||||||
|
// 获取用户列表
|
||||||
|
func (c *Client) GetUserList(req *GetUserListRequest) (response *GetUserListResponse, err error) {
|
||||||
|
response = CreateGetUserListResponse()
|
||||||
|
err = c.DoAction(req, response)
|
||||||
|
return
|
||||||
|
}
|
19
services/passport/client_test.go
Normal file
19
services/passport/client_test.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package passport
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
// 单元测试
|
||||||
|
|
||||||
|
func TestGetUserList(t *testing.T) {
|
||||||
|
client, err := NewClient()
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
req := CreateGetUserListRequest("ws45265737")
|
||||||
|
resp, err := client.GetUserList(req)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
t.Logf("resp code:%+v", resp.Code)
|
||||||
|
t.Logf("resp data:%+v", resp.Data)
|
||||||
|
}
|
58
services/passport/userinfo.go
Normal file
58
services/passport/userinfo.go
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package passport
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/md5"
|
||||||
|
"encoding/hex"
|
||||||
|
"fmt"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||||
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetUserListRequest struct {
|
||||||
|
*requests.RpcRequest
|
||||||
|
}
|
||||||
|
|
||||||
|
type GetUserListResponse struct {
|
||||||
|
*responses.BaseResponse
|
||||||
|
Code int `json:"code"`
|
||||||
|
Msg string `json:"msg"`
|
||||||
|
Data []UserInfo `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserInfo struct {
|
||||||
|
UserName string `json:"user_name"` // 用户名
|
||||||
|
Uid string `json:"uid"` // uid
|
||||||
|
Telephone string `json:"telephone"` // 手机号
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateGetUserListRequest 获取玩家用户列表
|
||||||
|
func CreateGetUserListRequest(userName string) (req *GetUserListRequest) {
|
||||||
|
ts := time.Now().Unix()
|
||||||
|
hash := md5.New()
|
||||||
|
hash.Write([]byte(fmt.Sprintf("%v%v", ts, appKey)))
|
||||||
|
hashBytes := hash.Sum(nil)
|
||||||
|
sign := hex.EncodeToString(hashBytes)
|
||||||
|
|
||||||
|
req = &GetUserListRequest{
|
||||||
|
RpcRequest: &requests.RpcRequest{},
|
||||||
|
}
|
||||||
|
req.InitWithApiInfo(HOST, VERSION, "/remote_login.php")
|
||||||
|
req.FormParams = map[string]string{
|
||||||
|
"act": "info",
|
||||||
|
"do": "get_user_list",
|
||||||
|
"user_names": userName,
|
||||||
|
"time": fmt.Sprintf("%v", ts),
|
||||||
|
"sign": sign,
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Method = requests.POST
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func CreateGetUserListResponse() (response *GetUserListResponse) {
|
||||||
|
response = &GetUserListResponse{
|
||||||
|
BaseResponse: &responses.BaseResponse{},
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user