【passport服务】查询用户角色列表
This commit is contained in:
		
							parent
							
								
									055fb8abb9
								
							
						
					
					
						commit
						9591e794f0
					
				@ -32,3 +32,11 @@ func (c *Client) GetUserList(req *GetUserListRequest) (response *GetUserListResp
 | 
			
		||||
	err = c.DoAction(req, response)
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetUserRoleList
 | 
			
		||||
// 获取用户角色列表
 | 
			
		||||
func (c *Client) GetUserRoleList(req *GetUserRoleListRequest) (response *GetUserRoleListResponse, err error) {
 | 
			
		||||
	response = CreateGetUserRoleListResponse()
 | 
			
		||||
	err = c.DoAction(req, response)
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -17,3 +17,17 @@ func TestGetUserList(t *testing.T) {
 | 
			
		||||
	t.Logf("resp code:%+v", resp.Code)
 | 
			
		||||
	t.Logf("resp data:%+v", resp.Data)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func TestGetUserRoleList(t *testing.T) {
 | 
			
		||||
	client, err := NewClient()
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Error(err)
 | 
			
		||||
	}
 | 
			
		||||
	req := CreateGetUserRoleListRequest(63610626, 2850)
 | 
			
		||||
	resp, err := client.GetUserRoleList(req)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		t.Error(err)
 | 
			
		||||
	}
 | 
			
		||||
	t.Logf("resp code:%+v", resp.Code)
 | 
			
		||||
	t.Logf("resp data:%+v", resp.Data)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -28,11 +28,7 @@ type UserInfo struct {
 | 
			
		||||
 | 
			
		||||
// 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)
 | 
			
		||||
	ts, sign := GetSign()
 | 
			
		||||
 | 
			
		||||
	req = &GetUserListRequest{
 | 
			
		||||
		RpcRequest: &requests.RpcRequest{},
 | 
			
		||||
@ -56,3 +52,62 @@ func CreateGetUserListResponse() (response *GetUserListResponse) {
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetUserRoleListRequest struct {
 | 
			
		||||
	*requests.RpcRequest
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type GetUserRoleListResponse struct {
 | 
			
		||||
	*responses.BaseResponse
 | 
			
		||||
	Code int            `json:"code"`
 | 
			
		||||
	Msg  string         `json:"msg"`
 | 
			
		||||
	Data []UserRoleInfo `json:"data"`
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type UserRoleInfo struct {
 | 
			
		||||
	Uid        string `json:"uid"`         // uid
 | 
			
		||||
	GameId     string `json:"game_id"`     // 子游戏id
 | 
			
		||||
	RoleId     string `json:"role_id"`     // 角色id
 | 
			
		||||
	RoleName   string `json:"role_name"`   // 角色名
 | 
			
		||||
	AddTime    string `json:"add_time"`    // 创建时间戳
 | 
			
		||||
	UpdateTime string `json:"update_time"` // 更新时间戳
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// GetSign 封装一个方法,获取当天时间戳和api签名
 | 
			
		||||
func GetSign() (ts int64, sign string) {
 | 
			
		||||
	ts = time.Now().Unix()
 | 
			
		||||
	hash := md5.New()
 | 
			
		||||
	hash.Write([]byte(fmt.Sprintf("%v%v", ts, appKey)))
 | 
			
		||||
	hashBytes := hash.Sum(nil)
 | 
			
		||||
	sign = hex.EncodeToString(hashBytes)
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// CreateGetUserRoleListRequest 获取玩家角色列表
 | 
			
		||||
func CreateGetUserRoleListRequest(uid int, gameId int) (req *GetUserRoleListRequest) {
 | 
			
		||||
	ts, sign := GetSign()
 | 
			
		||||
 | 
			
		||||
	req = &GetUserRoleListRequest{
 | 
			
		||||
		RpcRequest: &requests.RpcRequest{},
 | 
			
		||||
	}
 | 
			
		||||
	req.InitWithApiInfo(HOST, VERSION, "/remote_login.php")
 | 
			
		||||
	req.FormParams = map[string]string{
 | 
			
		||||
		"act":     "info",
 | 
			
		||||
		"do":      "user_role",
 | 
			
		||||
		"method":  "get",
 | 
			
		||||
		"uid":     fmt.Sprintf("%d", uid),
 | 
			
		||||
		"game_id": fmt.Sprintf("%d", gameId),
 | 
			
		||||
		"time":    fmt.Sprintf("%v", ts),
 | 
			
		||||
		"sign":    sign,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	req.Method = requests.POST
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func CreateGetUserRoleListResponse() (response *GetUserRoleListResponse) {
 | 
			
		||||
	response = &GetUserRoleListResponse{
 | 
			
		||||
		BaseResponse: &responses.BaseResponse{},
 | 
			
		||||
	}
 | 
			
		||||
	return
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
		Reference in New Issue
	
	Block a user