Documentation ¶
Overview ¶
*
- Copyright 2015 @ 56x.net.
- name : notify
- author : jarryliu
- date : 2016-07-06 18:36
- description :
- history :
Index ¶
Constants ¶
View Source
const ( TypeSiteMessage = iota TypeEmailMessage TypePhoneMessage )
Variables ¶
View Source
var ( ErrNoSuchNotifyItem = domain.NewError( "err_no_such_notify_item", "通知项不存在") ErrNotSettingSmsProvider = domain.NewError( "err_not_setting_sms_provider", "未配置短信服务商") ErrNoSuchSmsProvider = domain.NewError( "err_not_such_sms_provider", "不存在短信服务商") )
View Source
var ( // 类型字典 NotifyTypeMap = map[int]string{ TypeSiteMessage: "站内信", TypeEmailMessage: "邮件", TypePhoneMessage: "短信", } // 类型顺序 NotifyTypeIndex = []int{ TypeSiteMessage, TypeEmailMessage, TypePhoneMessage, } // 默认通知项 DefaultNotifyItems = NotifyItemSet{ &NotifyItem{ Key: "注册通知", TplId: -1, NotifyBy: TypeSiteMessage, Content: "您好,恭喜您已注册成为会员!", Tags: map[string]string{}, }, &NotifyItem{ Key: "验证手机", TplId: -1, ReadonlyBy: true, NotifyBy: TypePhoneMessage, Content: "您好,本次{operation}验证码为{code},有效期为{minutes}分钟。", Tags: map[string]string{ "operation": "操作,如找回密码,重置手机等", "code": "验证码", "minutes": "有效时间", }, }, &NotifyItem{ Key: "验证邮箱", TplId: -1, ReadonlyBy: true, NotifyBy: TypeEmailMessage, Content: "您好,本次{operation}验证码为{code},有效期为{minutes}分钟。", Tags: map[string]string{ "operation": "操作,如找回密码,重置手机等", "code": "验证码", "minutes": "有效时间", }, }, } )
Functions ¶
Types ¶
type INotifyManager ¶
type INotifyManager interface { // 获取所有的通知项 GetAllNotifyItem() []NotifyItem // 获取通知项配置 GetNotifyItem(key string) NotifyItem // 保存通知项设置 SaveNotifyItem(item *NotifyItem) error // 保存短信API SaveSmsApiPerm(s *SmsApiPerm) error // 获取短信API信息 GetSmsApiPerm(provider int) *SmsApiPerm // 发送手机短信 SendPhoneMessage(phone string, msg PhoneMessage, data []string, templateId string) error // 发送邮件 SendEmail(to string, msg *MailMessage, data []string) error }
type INotifyRepo ¶
type INotifyRepo interface { // 获取通知服务 Manager() INotifyManager // 获取所有的通知项 GetAllNotifyItem() []NotifyItem // 获取通知项 GetNotifyItem(key string) *NotifyItem // 保存通知项 SaveNotifyItem(v *NotifyItem) error }
type MailMessage ¶
邮件消息
type NotifyItem ¶
type NotifyItem struct { Key string // 发送方式 NotifyBy int // 不允许修改发送方式 ReadonlyBy bool // 模板编号 TplId int // 内容 Content string // 模板包含的标签 Tags map[string]string }
通知项
type SiteMessage ¶
type SiteMessage struct { // 主题 Subject string `json:"subject"` // 信息内容 Message string `json:"message"` }
站内信
type SmsApiPerm ¶
type SmsApiPerm struct { // 短信提供商,1:通用HTTP接口,2:腾讯云短信,3:阿里云短信,4:创蓝短信 Provider int // 接口KEY Key string // 接口密钥 Secret string /** 签名 */ Signature string // 默认模板编号 TemplateId string // Http接口 Extra *SmsExtraSetting }
短信接口参数设置
Click to show internal directories.
Click to hide internal directories.