64 lines
1.6 KiB
Go
64 lines
1.6 KiB
Go
|
package passport
|
||
|
|
||
|
import (
|
||
|
"crypto/md5"
|
||
|
"fmt"
|
||
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
||
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/responses"
|
||
|
"strings"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
type RegDeviceRequest struct {
|
||
|
*requests.RpcRequest
|
||
|
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:""`
|
||
|
}
|
||
|
|
||
|
func (b *RegDeviceRequest) getSign() {
|
||
|
b.time = time.Now().Unix()
|
||
|
rawStr := fmt.Sprintf("%d%s", b.time, KEY)
|
||
|
sign := md5.Sum([]byte(rawStr))
|
||
|
b.sign = fmt.Sprintf("%x", sign)
|
||
|
}
|
||
|
|
||
|
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()
|
||
|
req.users = strings.Join(users, ",")
|
||
|
req.do = "get_reg_device_by_username"
|
||
|
req.act = "info"
|
||
|
req.initRemoteLoginRequest()
|
||
|
return
|
||
|
}
|
||
|
|
||
|
func CreateRegDeviceResponse() (resp *RegDeviceResponse) {
|
||
|
return &RegDeviceResponse{
|
||
|
BaseResponse: &responses.BaseResponse{},
|
||
|
}
|
||
|
}
|