新增查用户注册设备方法
This commit is contained in:
parent
f0fe02d420
commit
710f74a50c
40
services/passport/client.go
Normal file
40
services/passport/client.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package passport
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk"
|
||||||
|
"golib.gaore.com/GaoreGo/haiwai-common-sdk-go/sdk/requests"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
VERSION = "2023-04-18"
|
||||||
|
KEY = "#gr*%com#"
|
||||||
|
)
|
||||||
|
|
||||||
|
var Host = requests.Host{
|
||||||
|
Default: "passport.gaore.com.hk",
|
||||||
|
Func: func(s string, area string) string {
|
||||||
|
if area != "" {
|
||||||
|
fmt.Println("passport.gaore.com." + area)
|
||||||
|
return "passport.gaore.com." + area
|
||||||
|
}
|
||||||
|
return "passport.gaore.com.hk"
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
type Client struct {
|
||||||
|
sdk.Client
|
||||||
|
ident string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) GetRegDeviceByUsers(req *RegDeviceRequest) (resp *RegDeviceResponse, err error) {
|
||||||
|
resp = CreateRegDeviceResponse()
|
||||||
|
err = c.DoAction(req, resp)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewClient(area string, env ...string) (client *Client, err error) {
|
||||||
|
client = new(Client)
|
||||||
|
err = client.InitWithArea(area, env...)
|
||||||
|
return
|
||||||
|
}
|
21
services/passport/client_test.go
Normal file
21
services/passport/client_test.go
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package passport
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestInfo(t *testing.T) {
|
||||||
|
client, err := NewClient("hk")
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req := CreateRegDeviceRequest("dv35054132", "zf43712598")
|
||||||
|
|
||||||
|
resp, err := client.GetRegDeviceByUsers(req)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
|
fmt.Println(resp.Data)
|
||||||
|
}
|
63
services/passport/info.go
Normal file
63
services/passport/info.go
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
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{},
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user