7
0

feat(asdk): 添加认证接口实现

This commit is contained in:
余 欣怀 2026-01-29 16:23:37 +08:00
parent 2e5667bc4b
commit abd73aa4b5
3 changed files with 55 additions and 0 deletions

34
services/asdk/auth.go Normal file
View 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
}

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk" "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/requests"
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses"
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils" "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils"
"time" "time"
) )
@ -45,3 +46,11 @@ func (c *Client) CreateKickUserReq(req *KickUserReq) (resp *KickUserResp, err er
} }
return return
} }
func (c *Client) Auth(req *AuthReq) (resp *AuthResp, err error) {
resp = &AuthResp{
BaseResponse: &responses.BaseResponse{},
}
err = c.DoAction(req, resp)
return
}

View File

@ -24,3 +24,15 @@ func TestKickUser(t *testing.T) {
} }
fmt.Println(resp.Code, resp.Msg, resp.Data) 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)
}