lib

package
v0.0.0-...-803c7bf Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2023 License: AGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Log         *zap.SugaredLogger
	DBCfg       MysqlCfgParam
	RedisCfg    = &RedisCfgParam{}
	RedisClient *redis.Client
	ServerCfg   HttpServerParam
	EmailCfg    = &EmailCfgParam{}
	DB          *sqlx.DB
)
View Source
var ImageCompress imageCompress = (*imageCompressImpl)(nil)
View Source
var Jwt jwtInterface = (*jwtImpl)(nil)

Jwt操作

View Source
var MysqlUtil mysqlUtil = (*mysqlUtilImpl)(nil)
View Source
var (
	Trans ut.Translator
)

Functions

func InitValidateTrans

func InitValidateTrans(validate *validator.Validate) ut.Translator

func RandCheckCode

func RandCheckCode(n int) string

随机验证码

func RandString

func RandString(base string, n int) string

RandString randomly generate a specified length string based on the given string 依据给定字符串生成给定长度的随机字符串

func TransError

func TransError(err error) string

func UID

func UID() string

获取UUID (转大写,不带-)

Types

type EmailCfgParam

type EmailCfgParam struct {
	Name     string `toml:"name" xml:"name" json:"name"`             // 发送者名称
	MailAddr string `toml:"mailAddr" xml:"mailAddr" json:"mailAddr"` // 发送者邮箱地址 youemail@email.com
	SmtpAddr string `toml:"smtpAddr" xml:"smtpAddr" json:"smtpAddr"` // 邮箱服务器地址(包含端口号)非SSL协议: 例如网易的 smtp.163.com:25
	HostAddr string `toml:"hostAddr" xml:"hostAddr" json:"hostAddr"` // 登录授权时服务器地址,不包含端口号: 例如网易的 smtp.163.com
	Password string `toml:"password" xml:"password" json:"password"` // 发送者邮箱授权密钥
	IsStatus bool   // 是否启用
}

邮箱配置

func (*EmailCfgParam) Send

func (ep *EmailCfgParam) Send(to string, title, message string) error

发送邮件方法 (正文方式)

func (*EmailCfgParam) SendHtml

func (ep *EmailCfgParam) SendHtml(to string, title, html string) error

发送邮件方法 (网页方式)

type HttpServerParam

type HttpServerParam struct {
	JwtKey    string `json:"jwtKey" toml:"jwtKey" yaml:"jwtKey" xml:"jwtKey"`
	Port      string `json:"port" toml:"port" yaml:"port" xml:"port"`
	UseHttps  bool   `json:"useHttps" toml:"useHttps" yaml:"useHttps" xml:"useHttps"`
	HttpsKey  string `json:"httpsKey" toml:"httpsKey" yaml:"httpsKey" xml:"httpsKey"`
	HttpsPem  string `json:"httpsPem" toml:"httpsPem" yaml:"httpsPem" xml:"httpsPem"`
	HttpsHost string `json:"httpsHost" toml:"httpsHost" yaml:"httpsHost" xml:"httpsHost"`
}

type JwtUserInfoClaims

type JwtUserInfoClaims struct {
	Uid      string `json:"uid"`
	Username string `json:"username"`
	HeadPic  string `json:"headPic"`
	Email    string `json:"email"`
	Status   int    `json:"status"`
	jwt.RegisteredClaims
}

func (JwtUserInfoClaims) Valid

func (JwtUserInfoClaims) Valid() error

type MysqlCfgParam

type MysqlCfgParam struct {
	Host      string `toml:"host"`      // 数据库地址 127.0.0.1:3306
	User      string `toml:"user"`      // 数据库用户名
	Password  string `toml:"password"`  // 数据库密码
	Database  string `toml:"database"`  // 数据库名
	Charset   string `toml:"charset"`   // 数据库字符集 utf8mb4
	ParseTime string `toml:"parseTime"` // 是否分析时间 True
	Loc       string `toml:"loc"`       // loc Local
}

Mysql 配置参数

type RedisCfgParam

type RedisCfgParam struct {
	Host     string `toml:"host"`     // 地址 127.0.0.1:6379
	Password string `toml:"password"` // 密码
	DB       int    `toml:"db"`       // 默认连接库
}

Redis配置

func (*RedisCfgParam) NewClient

func (rc *RedisCfgParam) NewClient() *redis.Client

获取Redis Client

Jump to

Keyboard shortcuts

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