2024-12-04 14:39:53 +08:00

48 lines
1.7 KiB
Go

package sms
import (
"shylinux.com/x/ice"
"shylinux.com/x/community/src/renzhengshouquan"
"shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud"
"shylinux.com/x/community/src/renzhengshouquan/external/tencentcloud/sms/model"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
sdk "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/sms/v20210111"
)
type sms struct {
renzhengshouquan.Table
tencentcloud.Tencentcloud
order string `data:"17"`
fields string `data:"sign_name AS sign_name,template_id,app_id,user_uid"`
create string `name:"create sign_name* template_id* app_id*" role:"worker"`
remove string `name:"remove" role:"worker"`
list string `name:"list auth_uid uid auto" role:"worker"`
send string `name:"send mobile* verify*" role:"worker"`
}
func (s sms) List(m *ice.Message, arg ...string) {
s.ValueList(m, arg).Action().Display("")
}
func (s sms) Send(m *ice.Message, arg ...string) {
msg := s.Select(m.Spawn(), model.AUTH_UID, s.GetAuthUID(m))
request := sdk.NewSendSmsRequest()
request.SignName = common.StringPtr(msg.Append(model.SIGN_NAME))
request.TemplateId = common.StringPtr(msg.Append(model.TEMPLATE_ID))
request.SmsSdkAppId = common.StringPtr(msg.Append(model.APP_ID))
request.PhoneNumberSet = common.StringPtrs([]string{m.Option(model.MOBILE)})
request.TemplateParamSet = common.StringPtrs([]string{m.Option(model.VERIFY)})
response, err := s.newClient(m).SendSms(request)
s.ParseResponse(m, response, err)
}
func init() { ice.TeamCtxCmd(sms{}) }
func init() { renzhengshouquan.SmsVendor = sms{} }
func (s sms) newClient(m *ice.Message, arg ...string) *sdk.Client {
c, _ := sdk.NewClient(s.NewCredential(m), "ap-guangzhou", s.NewProfile(m))
return c
}