utils

package
v0.0.0-...-2949144 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 27, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Scname                  = "NAME"
	Sccompanyname           = "COMPANY_NAME"
	Sccompanyaddress        = "COMPANY_ADDRESS"
	Sccompanyconcattel      = "COMPANY_CONCAT_TEL"
	Sccompanyconcatqq       = "COMPANY_CONCAT_QQ"
	Sccompanyconcatwx       = "COMPANY_CONCAT_WX"
	Scsmssignname           = "sms_signname"
	Scsmsapi                = "sms_api"
	Scsmsuid                = "sms_uid"
	Scsmskey                = "sms_key"
	Scfrontregsmsverify     = "front_reg_sms_verify"
	ScBaiduApiKey           = "baidu_api_key"
	ScBaiduSecretKey        = "baidu_secret_key"
	ScAliyunAccessKeyId     = "aliyun_access_key_id"
	ScAliyunAccessKeySecret = "aliyun_access_key_secret"
	ScAliyunAuthSecret      = "aliyun_auth_secret_" // 阿里云认证服务的秘钥,每个App不同,添加后缀 App编号,如:aliyun_auth_secret_s
)

站点配置code

View Source
const (
	CODE_OK         = 1
	CODE_NEED_LOGIN = 11
	CODE_ERROR      = 21
)
View Source
const (
	PayTypeAlipay    = "alipay"
	PayTypeWechatPay = "wechatpay"
	PayTypeApplePay  = "applepay"
)
View Source
const (
	AppChannelWxa = "wxa" // 微信小程序
)

Variables

View Source
var SiteConfigCodeMap = map[string]string{
	"DIY":  "自定义",
	Scname: "站点名称",
}

Functions

func Decode

func Decode(data []byte, to interface{}) error

------------------- Decode 用gob进行数据解码

func DelCache

func DelCache(key string) error

func Encode

func Encode(data interface{}) ([]byte, error)

-------------------- Encode 用gob进行数据编码

func GenInviteCode

func GenInviteCode(id int64) string

ID转化为推广码

func GetCache

func GetCache(key string, to interface{}) error

func GetCpt

func GetCpt() *captcha.Captcha

func GetSiteConfigCodeMap

func GetSiteConfigCodeMap() map[string]string

func InitCache

func InitCache()

func InitCaptcha

func InitCaptcha()

func InitMail

func InitMail(s string, h string, p int, u string, pw string)

使用当前邮件工具时,必须先调用initial文件夹下的InitMailConf初始化。

func ReverseInviteCode

func ReverseInviteCode(ic string) int64

推广码转化为ID

func SendMailVerifyCode

func SendMailVerifyCode(to string) error

发送验证码,5分钟有效

func SendSmsVerifyCode

func SendSmsVerifyCode(sender SmsSender) (string, error)

*

  • 发送验证码,1分钟有效
  • return 发送的验证码,异常

func SetCache

func SetCache(key string, value interface{}, timeoutSecond int) error

func VerifyMailVerifyCode

func VerifyMailVerifyCode(key string, vc string) bool

func VerifySmsVerifyCode

func VerifySmsVerifyCode(mobile string, vc string) bool

Types

type MailSender

type MailSender struct {
	//From string // 发件人,可空,为空时取app.conf中的配置
	To      []string // 收件人列表,不可空
	Cc      string   // 抄送,可空
	Subject string   // 主题,可空,默认:无主题
	Body    string   // 内容,内容,不可空
	Attach  string   // 附件,可空
}

func (*MailSender) Send

func (this *MailSender) Send() error

发送邮件,一次性全部发送

func (*MailSender) SendSeparate

func (this *MailSender) SendSeparate() (int, error)

拆分收件人,一人发送一次;返回成功发送数量

type SmsSender

type SmsSender struct {
	Api     string // api方;1:http://sms.webchinese.cn; 阿里云模板ID()
	Uid     string
	Key     string
	Mobile  string
	Company string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL