45 lines
1.0 KiB
Go
45 lines
1.0 KiB
Go
package controller
|
||
|
||
import (
|
||
"SciencesServer/app/handle"
|
||
"SciencesServer/utils"
|
||
"errors"
|
||
)
|
||
|
||
type Sms struct{}
|
||
|
||
type SmsHandle func() *Sms
|
||
|
||
func (c *Sms) captchaCallback(mobile, code string) error {
|
||
//content := fmt.Sprintf("【汇安科技】您的验证码是%s,三分钟内有效", code)
|
||
// 发送短信
|
||
//_ = platform.NewSms().Send()(platform.SmsSendModeForGroup, &platform.SmsParam{
|
||
// Mobile: []string{mobile}, Content: content,
|
||
//})
|
||
// 执行保存数据库
|
||
//mSysSmsLogs := model.NewSysSmsLogs()
|
||
//mSysSmsLogs.Mobile = mobile
|
||
//mSysSmsLogs.Content = content
|
||
//mSysSmsLogs.Usage = model2.SysSmsLogsUsageForCaptcha
|
||
//
|
||
//return model2.Create(mSysSmsLogs.SysSmsLogs)
|
||
return nil
|
||
}
|
||
|
||
// Captcha 验证码事件
|
||
func (c *Sms) Captcha(mobile string) error {
|
||
if !utils.ValidateMobile(mobile) {
|
||
return errors.New("手机格式不正确")
|
||
}
|
||
if err := handle.NewCaptcha().Sms(6, mobile, c.captchaCallback); err != nil {
|
||
return errors.New("操作错误")
|
||
}
|
||
return nil
|
||
}
|
||
|
||
func NewSms() SmsHandle {
|
||
return func() *Sms {
|
||
return &Sms{}
|
||
}
|
||
}
|