7
0

Compare commits

..

2 Commits

Author SHA1 Message Date
liangzy
6bfb0c851c Merge remote-tracking branch 'origin/master' 2020-08-11 18:16:57 +08:00
liangzy
30878e899d 添加注释 2020-08-11 18:16:37 +08:00
3 changed files with 40 additions and 4 deletions

29
services/jedi/README.md Normal file
View File

@ -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)
}
}
```

View File

@ -1,6 +1,9 @@
package jedi package jedi
import "golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk" import (
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk"
"strings"
)
const ( const (
HOST = "jedi" HOST = "jedi"
@ -12,6 +15,9 @@ type Client struct {
} }
func (c *Client) SendSms(req *SendSmsRequest) (response *SendSmsResponse, err error) { 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() response = CreateSendSmsResponse()
err = c.DoAction(req, response) err = c.DoAction(req, response)
return return

View File

@ -10,6 +10,7 @@ type SendSmsRequest struct {
User string `position:"Query" field:"user" default:"" ` User string `position:"Query" field:"user" default:"" `
Code string `position:"Query" field:"code" default:"" ` Code string `position:"Query" field:"code" default:"" `
Params string `position:"Query" field:"params" default:"" ` Params string `position:"Query" field:"params" default:"" `
ParamsArray []string
} }
type SendSmsResponseData struct { type SendSmsResponseData struct {