From 30878e899dc1bcf311bf7b1392e52e5b127ad3f9 Mon Sep 17 00:00:00 2001 From: liangzy Date: Tue, 11 Aug 2020 18:16:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- services/jedi/README.md | 29 +++++++++++++++++++++++++++++ services/jedi/client.go | 8 +++++++- services/jedi/send_sms.go | 7 ++++--- 3 files changed, 40 insertions(+), 4 deletions(-) create mode 100644 services/jedi/README.md diff --git a/services/jedi/README.md b/services/jedi/README.md new file mode 100644 index 0000000..3f24bbd --- /dev/null +++ b/services/jedi/README.md @@ -0,0 +1,29 @@ + + +### 发送短信调用示例 +```go +import ( + "fmt" + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/services/jedi" +) + +func main() { + c, err := jedi.NewClientWithAccessKey("accessKeyId", "accessKeySecret", "xxx.xxx.com") + if err != nil { + return + } + + req := jedi.CreateSendSmsRequest() + // sso统一用户名uid, 多个用户用逗句隔开 + req.User = "liangzy,liaoks" + // 公共模板的代码模板 + req.Code = "d7kt5IwP" + // 模板参数,模板里有多少个模板参数就传入几个替换字符串, + req.ParamsArray = []string{"www", "线上", "好人"} + if resp, err := c.SendSms(req); err == nil { + grlogs.Informational(fmt.Sprintf("%+v", resp.GetHttpContentString())) + } else { + grlogs.Error(err) + } +} +``` \ No newline at end of file diff --git a/services/jedi/client.go b/services/jedi/client.go index 9c35a99..4c6ddd1 100644 --- a/services/jedi/client.go +++ b/services/jedi/client.go @@ -1,6 +1,9 @@ package jedi -import "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk" +import ( + "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk" + "strings" +) const ( HOST = "jedi" @@ -12,6 +15,9 @@ type Client struct { } func (c *Client) SendSms(req *SendSmsRequest) (response *SendSmsResponse, err error) { + if req.ParamsArray != nil && len(req.ParamsArray) > 0 { + req.Params = strings.Join(req.ParamsArray, ",,,") + } response = CreateSendSmsResponse() err = c.DoAction(req, response) return diff --git a/services/jedi/send_sms.go b/services/jedi/send_sms.go index 5584423..54fe727 100644 --- a/services/jedi/send_sms.go +++ b/services/jedi/send_sms.go @@ -7,9 +7,10 @@ import ( type SendSmsRequest struct { *requests.RpcRequest - User string `position:"Query" field:"user" default:"" ` - Code string `position:"Query" field:"code" default:"" ` - Params string `position:"Query" field:"params" default:"" ` + User string `position:"Query" field:"user" default:"" ` + Code string `position:"Query" field:"code" default:"" ` + Params string `position:"Query" field:"params" default:"" ` + ParamsArray []string } type SendSmsResponseData struct {