diff --git a/README.md b/README.md index abf9ea7..4732b0f 100644 --- a/README.md +++ b/README.md @@ -171,4 +171,9 @@ func CreateDemoTestResponse() *DemoTestResponse { } } +``` + +终端调试打开方式, 需要在系统环境变量上加入 +``` +DEBUG=sdk,signer ``` \ No newline at end of file diff --git a/sdk/requests/request.go b/sdk/requests/request.go index c0e6200..551cc79 100644 --- a/sdk/requests/request.go +++ b/sdk/requests/request.go @@ -91,7 +91,7 @@ type AcsRequest interface { GetStringToSign() string GetBodyReader() io.Reader - addHeaderParam(key, value string) + AddHeaderParam(key, value string) addQueryParam(key, value string) addFormParam(key, value string) } @@ -217,7 +217,7 @@ func (request *baseRequest) SetStringToSign(stringToSign string) { request.stringToSign = stringToSign } -func (request *baseRequest) addHeaderParam(key, val string) { +func (request *baseRequest) AddHeaderParam(key, val string) { request.Headers[key] = val } @@ -300,7 +300,7 @@ func addParam(request AcsRequest, position, key, value string) (err error) { if len(value) > 0 { switch position { case Header: - request.addHeaderParam(key, value) + request.AddHeaderParam(key, value) case Query: request.addQueryParam(key, value) case Body: diff --git a/services/www/client.go b/services/www/client.go new file mode 100644 index 0000000..51f6dfa --- /dev/null +++ b/services/www/client.go @@ -0,0 +1,44 @@ +package www + +import ( + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" +) + +const ( + VERSION = "2020-09-24" +) + +var HOST requests.Host = requests.Host{ + Default: "apisdk.9ooo.cn", + Func: func(s string) string { + var a = map[string]string{ + requests.RELEASE: "apisdk.9ooo.cn", + requests.PRE: "apisdk.9ooo.cn", + requests.TEST: "apisdk.9ooo.cn", + } + return a[s] + }, +} + +type Client struct { + sdk.Client +} + +func NewClientWithAccessKey(accesskey, secrect, source string) (client *Client, err error) { + client = &Client{} + err = client.InitWithAccessKey(accesskey, secrect, source) + return +} + +func NewClientWithAliAppcode(accesskey, secrect string, env ...string) (client *Client, err error) { + client = &Client{} + err = client.InitWithAliAppcode(accesskey, secrect, env...) + return +} + +func (c *Client) GetUserInfo(req *GetPwdRequest) (response *GetPwdResponse, err error) { + response = CreateGetPwdResponse() + err = c.DoAction(req, response) + return +} diff --git a/services/www/client_test.go b/services/www/client_test.go new file mode 100644 index 0000000..5a9833c --- /dev/null +++ b/services/www/client_test.go @@ -0,0 +1,21 @@ +package www + +import ( + "fmt" + "testing" +) + +func TestClient_GetUserInfo(t *testing.T) { + + c, err := NewClientWithAliAppcode("203874304", "9e5489a82dd641729186cdad166d81a3") + if err != nil { + t.Error(err) + } + + req := CreateGetPwdRequest() + req.UserName = "ttom666" + + resp, _ := c.GetUserInfo(req) + fmt.Println(resp.GetHttpContentString()) + fmt.Println(resp.GetHttpHeaders()) +} diff --git a/services/www/get_pwd.go b/services/www/get_pwd.go new file mode 100644 index 0000000..880d14a --- /dev/null +++ b/services/www/get_pwd.go @@ -0,0 +1,37 @@ +package www + +import ( + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/requests" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/responses" +) + +type GetPwdRequest struct { + *requests.RpcRequest + UserName string `position:"Query" field:"user_name" default:"-" ` +} + +type GetPwdResponse struct { + *responses.BaseResponse + Ret int `json:"ret"` + Msg string `json:"msg"` + Data struct { + UserName string `json:"user_name"` + UserPwd string `json:"user_pwd"` + } `json:"data"` +} + +func CreateGetPwdRequest() (req *GetPwdRequest) { + req = &GetPwdRequest{ + RpcRequest: &requests.RpcRequest{}, + } + req.InitWithApiInfo(HOST, VERSION, "/api/limit/getPwd.php") + req.Method = requests.GET + return +} + +func CreateGetPwdResponse() (response *GetPwdResponse) { + response = &GetPwdResponse{ + BaseResponse: &responses.BaseResponse{}, + } + return +} diff --git a/services/www/get_token.go b/services/www/get_token.go new file mode 100644 index 0000000..0da909b --- /dev/null +++ b/services/www/get_token.go @@ -0,0 +1 @@ +package www