From 1eee556d3b3b85ad3ce90b21e4a586503eb0dee7 Mon Sep 17 00:00:00 2001 From: yxh Date: Fri, 24 Dec 2021 16:31:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=82=E9=85=8D=E6=8F=92=E4=BB=B6=E5=AE=89?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/plugins/mail.go | 7 ++++++ app/common/plugins/sms.go | 14 +++++++++++ app/common/service/form_token.go | 40 ++++++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 app/common/plugins/mail.go create mode 100644 app/common/plugins/sms.go create mode 100644 app/common/service/form_token.go diff --git a/app/common/plugins/mail.go b/app/common/plugins/mail.go new file mode 100644 index 0000000..dbb96be --- /dev/null +++ b/app/common/plugins/mail.go @@ -0,0 +1,7 @@ +package plugins + +type ICommonQQMail interface { + SendMail(mailTo []string, subject string, body string) error +} + +var CommonQQMail ICommonQQMail diff --git a/app/common/plugins/sms.go b/app/common/plugins/sms.go new file mode 100644 index 0000000..94c036d --- /dev/null +++ b/app/common/plugins/sms.go @@ -0,0 +1,14 @@ +package plugins + +type ICommonSmsWyyx interface { + SendSMSTemplate(params IWyyxReq) (string, error) +} + +// 网易云信 +var CommonSmsWyyx ICommonSmsWyyx + +// 入参 +type IWyyxReq struct { + Mobiles []string `v:"required#电话号码不能为空"` + Params []string `v:"required#短信参数不能为空"` +} diff --git a/app/common/service/form_token.go b/app/common/service/form_token.go new file mode 100644 index 0000000..c2bf9d9 --- /dev/null +++ b/app/common/service/form_token.go @@ -0,0 +1,40 @@ +/** + * 表单令牌 + * @Company: 云南奇讯科技有限公司 + * @Author: yxf + * @Description: + * @Version: 1.0.0 + * @Date: 2021/9/15 17:47 + */ + +package service + +import ( + "github.com/gogf/gf/util/guid" + "time" +) + +type formTokenService struct{} + +var FormToken = new(formTokenService) + +func (s *formTokenService) New(action string) (key string) { + key = guid.S() + cache := Cache.New() + cache.Set(key, action, time.Hour) + return key +} + +func (s *formTokenService) Verify(key string, action string) bool { + cache := Cache.New() + value := cache.Get(key) + if value != nil && value == action { + return true + } + return false +} + +func (s *formTokenService) Remove(key string) interface{} { + cache := Cache.New() + return cache.Remove(key) +}