feat(asdk): 添加认证接口实现
This commit is contained in:
parent
2e5667bc4b
commit
abd73aa4b5
34
services/asdk/auth.go
Normal file
34
services/asdk/auth.go
Normal file
@ -0,0 +1,34 @@
|
||||
package asdk
|
||||
|
||||
import (
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||
)
|
||||
|
||||
type AuthReq struct {
|
||||
*requests.RpcRequest
|
||||
}
|
||||
|
||||
type AuthResp struct {
|
||||
*responses.BaseResponse
|
||||
Code int `json:"code"`
|
||||
Msg string `json:"msg"`
|
||||
Data struct {
|
||||
Uid int64 `json:"uid"`
|
||||
UserName string `json:"user_name"`
|
||||
} `json:"data"`
|
||||
TraceId string `json:"trace_id"`
|
||||
}
|
||||
|
||||
func CreateAuthReq(token string) *AuthReq {
|
||||
req := &AuthReq{
|
||||
RpcRequest: &requests.RpcRequest{},
|
||||
}
|
||||
|
||||
req.InitWithApiInfo(HOST, VERSION, "/api/auth")
|
||||
req.Method = requests.POST
|
||||
req.FormParams = map[string]string{
|
||||
"token": token,
|
||||
}
|
||||
return req
|
||||
}
|
||||
@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
|
||||
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils"
|
||||
"time"
|
||||
)
|
||||
@ -45,3 +46,11 @@ func (c *Client) CreateKickUserReq(req *KickUserReq) (resp *KickUserResp, err er
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (c *Client) Auth(req *AuthReq) (resp *AuthResp, err error) {
|
||||
resp = &AuthResp{
|
||||
BaseResponse: &responses.BaseResponse{},
|
||||
}
|
||||
err = c.DoAction(req, resp)
|
||||
return
|
||||
}
|
||||
|
||||
@ -24,3 +24,15 @@ func TestKickUser(t *testing.T) {
|
||||
}
|
||||
fmt.Println(resp.Code, resp.Msg, resp.Data)
|
||||
}
|
||||
|
||||
func TestAuth(t *testing.T) {
|
||||
client, err := NewClient()
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
resp, err := client.Auth(CreateAuthReq("t1w6rnlqxlYeSM3wAqVRljKDGVSTr9th"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Log(resp)
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user