You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-library/service/wnfuwu/user.go

45 lines
1.3 KiB

package wnfuwu
import (
"context"
"github.com/dtapps/go-library/utils/gojson"
"github.com/dtapps/go-library/utils/gorequest"
)
type UserResponse struct {
Errno int64 `json:"errno"` // 错误码0代表成功非0代表失败
Errmsg string `json:"errmsg"` // 错误描述
Data struct {
Id int64 `json:"id"` // userid
Username string `json:"username"` // 名称
Balance string `json:"balance"` // 余额
} `json:"data,omitempty"`
}
type UserResult struct {
Result UserResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
}
func newUserResult(result UserResponse, body []byte, http gorequest.Response) *UserResult {
return &UserResult{Result: result, Body: body, Http: http}
}
// User 查询用户信息
// https://www.showdoc.com.cn/dyr/9227004018562421
func (c *Client) User(ctx context.Context, notMustParams ...gorequest.Params) (*UserResult, error) {
// 参数
params := gorequest.NewParams()
params.Set("userid", c.GetUserId())
// 请求
request, err := c.request(ctx, apiUrl+"/index/user", params)
if err != nil {
return newUserResult(UserResponse{}, request.ResponseBody, request), err
}
// 定义
var response UserResponse
err = gojson.Unmarshal(request.ResponseBody, &response)
return newUserResult(response, request.ResponseBody, request), err
}