Documentation ¶
Index ¶
- type RedisModel
- type SMS
- func (s *SMS) GenerateCode(mobile string, action string) (string, string, error)
- func (s *SMS) GetSMSConfigs() (*conf.SMSConfig, error)
- func (s *SMS) Send(action string, mobile string, validationCode string) error
- func (s *SMS) Validate(mobile string, action string, key string, code string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RedisModel ¶
type RedisModel struct { Mobile string `json:"mobile"` Key string `json:"key"` Code string `json:"code"` Action string `json:"action"` CreateTime time.Time `json:"createTime"` }
RedisModel is redis tool for transform data from redis to struct
func (*RedisModel) Marshal ¶
func (r *RedisModel) Marshal() ([]byte, error)
Marshal is difined to marshal data to bytes 转化字节用户redis存储
func (*RedisModel) Unmarshal ¶
func (r *RedisModel) Unmarshal(data []byte) error
Unmarshal can be used for json data unmarshal 解码字节码,用于redis校验
type SMS ¶
type SMS struct{}
SMS is SMS tool model
func (*SMS) GenerateCode ¶
GenerateCode is defined to create a new sms code in random 生成短信验证码并存储在redis中,验证码有效时间为一个小时,验证码1小时后将被redis清除
生成的验证码使用key来查询 返回:生成的验证码 验证码存储的redis key 错误信息
func (*SMS) GetSMSConfigs ¶
GetSMSConfigs is defined to get sms configs from yaml 获取验证码模板和相关配置信息
func (*SMS) Send ¶
Send is a method defined to send sms through api gateway 我们使用了253.com的短信api验证接口,如果你需要修改,那么修改sendSMS,而不是修改这里
253短信验证码接口的文档 https://github.com/cl253/chuanglan253-go
请千万不要直接修改这里,这里什么都没做,简单验证了参数
Click to show internal directories.
Click to hide internal directories.