2025-05-28 16:45:20 +08:00
|
|
|
|
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) {
|
2025-05-28 17:24:23 +08:00
|
|
|
|
ts, sign := GetSign()
|
2025-05-28 16:45:20 +08:00
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
}
|
2025-05-28 17:24:23 +08:00
|
|
|
|
|
|
|
|
|
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"` // 角色名
|
2025-05-29 15:34:59 +08:00
|
|
|
|
RoleServer string `json:"role_server"` // 角色服务器名
|
2025-05-28 17:24:23 +08:00
|
|
|
|
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 获取玩家角色列表
|
2025-08-12 17:10:23 +08:00
|
|
|
|
func CreateGetUserRoleListRequest(uid int, gameId int, roleId int, roleServer string) (req *GetUserRoleListRequest) {
|
2025-05-28 17:24:23 +08:00
|
|
|
|
ts, sign := GetSign()
|
|
|
|
|
|
|
|
|
|
req = &GetUserRoleListRequest{
|
|
|
|
|
RpcRequest: &requests.RpcRequest{},
|
|
|
|
|
}
|
|
|
|
|
req.InitWithApiInfo(HOST, VERSION, "/remote_login.php")
|
|
|
|
|
req.FormParams = map[string]string{
|
2025-08-12 17:10:23 +08:00
|
|
|
|
"act": "info",
|
|
|
|
|
"do": "user_role",
|
|
|
|
|
"method": "get",
|
|
|
|
|
"uid": fmt.Sprintf("%d", uid),
|
|
|
|
|
"game_id": fmt.Sprintf("%d", gameId),
|
|
|
|
|
"role_id": fmt.Sprintf("%d", roleId),
|
|
|
|
|
"role_server": roleServer,
|
|
|
|
|
"time": fmt.Sprintf("%v", ts),
|
|
|
|
|
"sign": sign,
|
2025-05-28 17:24:23 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
req.Method = requests.POST
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func CreateGetUserRoleListResponse() (response *GetUserRoleListResponse) {
|
|
|
|
|
response = &GetUserRoleListResponse{
|
|
|
|
|
BaseResponse: &responses.BaseResponse{},
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
2025-09-02 17:17:36 +08:00
|
|
|
|
|
|
|
|
|
type GetUserGameSignRequest struct {
|
|
|
|
|
*requests.RpcRequest
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type GetUserGameSignResponse struct {
|
|
|
|
|
*responses.BaseResponse
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Msg string `json:"msg"`
|
|
|
|
|
Data struct {
|
|
|
|
|
List []UserGameSign `json:"list"`
|
|
|
|
|
} `json:"data"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type UserGameSign struct {
|
|
|
|
|
Id string `json:"id"`
|
|
|
|
|
AgentId string `json:"agent_id"`
|
|
|
|
|
SiteId string `json:"site_id"`
|
|
|
|
|
Uid string `json:"uid"`
|
|
|
|
|
UserName string `json:"user_name"`
|
|
|
|
|
GameId string `json:"game_id"`
|
|
|
|
|
GameSign string `json:"game_sign"`
|
|
|
|
|
Oaid string `json:"oaid"`
|
|
|
|
|
Imei string `json:"imei"`
|
|
|
|
|
Imei2 string `json:"imei2"`
|
|
|
|
|
Ua string `json:"ua"`
|
|
|
|
|
FirstLoginIp string `json:"first_login_ip"`
|
|
|
|
|
FirstLoginTime string `json:"first_login_time"`
|
|
|
|
|
LastLoginIp string `json:"last_login_ip"`
|
|
|
|
|
LastLoginTime string `json:"last_login_time"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// CreateGetUserGameSignRequest 获取用户登录过的游戏大类
|
|
|
|
|
func CreateGetUserGameSignRequest(userName, gameSign, orderBy string) (req *GetUserGameSignRequest) {
|
|
|
|
|
ts, sign := GetSign()
|
|
|
|
|
|
|
|
|
|
req = &GetUserGameSignRequest{
|
|
|
|
|
RpcRequest: &requests.RpcRequest{},
|
|
|
|
|
}
|
|
|
|
|
req.InitWithApiInfo(HOST, VERSION, "/remote_login.php")
|
|
|
|
|
req.FormParams = map[string]string{
|
|
|
|
|
"act": "info",
|
|
|
|
|
"do": "get_user_game_sign",
|
|
|
|
|
"username": userName,
|
|
|
|
|
"game_sign": gameSign,
|
|
|
|
|
"order_by": orderBy,
|
|
|
|
|
"time": fmt.Sprintf("%v", ts),
|
|
|
|
|
"sign": sign,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
req.Method = requests.POST
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func CreateGetUserGameSignResponse() (response *GetUserGameSignResponse) {
|
|
|
|
|
response = &GetUserGameSignResponse{
|
|
|
|
|
BaseResponse: &responses.BaseResponse{},
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|