2023-04-18 18:52:00 +08:00
|
|
|
package passport
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"crypto/md5"
|
|
|
|
|
"fmt"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
2026-03-20 16:31:43 +08:00
|
|
|
|
|
|
|
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
|
|
|
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/responses"
|
2023-04-18 18:52:00 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type RegDeviceRequest struct {
|
|
|
|
|
*requests.RpcRequest
|
2026-03-20 16:31:43 +08:00
|
|
|
Do string `position:"Body" field:"do" default:""`
|
|
|
|
|
Act string `position:"Body" field:"act" default:""`
|
|
|
|
|
Time int64 `position:"Body" field:"time" default:"0"`
|
|
|
|
|
Sign string `position:"Body" field:"sign" default:""`
|
|
|
|
|
Users string `position:"Body" field:"username" default:""`
|
2023-04-18 18:52:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *RegDeviceRequest) getSign() {
|
2026-03-20 16:31:43 +08:00
|
|
|
b.Time = time.Now().Unix()
|
|
|
|
|
rawStr := fmt.Sprintf("%d%s", b.Time, KEY)
|
2023-04-18 18:52:00 +08:00
|
|
|
sign := md5.Sum([]byte(rawStr))
|
2026-03-20 16:31:43 +08:00
|
|
|
b.Sign = fmt.Sprintf("%x", sign)
|
2023-04-18 18:52:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (b *RegDeviceRequest) initRemoteLoginRequest() {
|
|
|
|
|
b.InitWithApiInfo(Host, VERSION, "/remote_login.php")
|
|
|
|
|
b.Method = requests.POST
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type RegDeviceResponse struct {
|
|
|
|
|
*responses.BaseResponse
|
|
|
|
|
Code int `json:"code"`
|
|
|
|
|
Msg string `json:"msg"`
|
|
|
|
|
Data []struct {
|
|
|
|
|
DeviceId string `json:"imei"`
|
|
|
|
|
Idfa string `json:"imei2"`
|
|
|
|
|
ChannelDeviceId string `json:"channel_device_id"`
|
|
|
|
|
Uid int64 `json:"uid"`
|
|
|
|
|
UserName string `json:"user_name"`
|
|
|
|
|
} `json:"data"`
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func CreateRegDeviceRequest(users ...string) (req *RegDeviceRequest) {
|
|
|
|
|
req = &RegDeviceRequest{
|
|
|
|
|
RpcRequest: &requests.RpcRequest{},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
req.getSign()
|
2026-03-20 16:31:43 +08:00
|
|
|
req.Users = strings.Join(users, ",")
|
|
|
|
|
req.Do = "get_reg_device_by_username"
|
|
|
|
|
req.Act = "info"
|
2023-04-18 18:52:00 +08:00
|
|
|
req.initRemoteLoginRequest()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func CreateRegDeviceResponse() (resp *RegDeviceResponse) {
|
|
|
|
|
return &RegDeviceResponse{
|
|
|
|
|
BaseResponse: &responses.BaseResponse{},
|
|
|
|
|
}
|
|
|
|
|
}
|